Firebase Setup
Overview
Firebase is essential for eBroker app's authentication and notification features. This guide will walk you through setting up Firebase for your app.
Create Firebase Project
- Visit Firebase Console
- Sign in with your Google account
- Click on "Add project" button
- Enter a project name and choose a suitable project ID
- Select your country/region and click "Create Project"
- Tap on the Flutter icon to add Flutter to your Firebase project
- Open your IDE (VS Code, Android Studio, etc.) and run these commands in the terminal:
flutter pub add firebase_core
flutter pub add firebase_auth
- Copy and paste both commands one by one like this:
Important: Make sure to change your package name first before setting up Firebase!
- Select Android, iOS, and Web platforms when prompted
- If asked to override existing Firebase settings, type "yes" and press Enter
Enable Phone Authentication
Phone authentication is critical for the app's login functionality. Follow these steps:
- In the Firebase console, go to the Authentication section
- Turn on phone login as shown below:
- Enable Firebase phone auth by tapping the switch button:
- For testing purposes, add Firebase testing phone numbers to avoid temporary blocks
Resolving "missing-client-identifier" Issues
When using real phone numbers, you might encounter a "missing-client-identifier" error. To resolve:
- Open your terminal in the project location and run:
cd android
./gradlew signinReport
- Copy the SHA1 and SHA256 keys from the result:
- Add these keys to your Firebase project settings:
Setup Notifications
- Get the server key from your Firebase project
- Go to Project Settings → Cloud Messaging → Manage API on Google Cloud Console
- Copy the server key:
- Set the key in your admin panel's Notification FCM key field:
iOS Notification Setup
For iOS devices, complete these additional steps:
- In Xcode, open your project
- Select the project icon representing your app
- Select your app's target
- Navigate to the Capabilities tab
- Enable Push Notifications
- Check Remote Notifications and Background Fetch from Enabling Background Modes
Apple's Push Notification service (APNs) supports two connection types. For token-based (.p8):
- Log in to the Apple Developer Portal
- Navigate to Certificates, IDs & Profiles > Identifiers > App IDs
- Check Capabilities > Push Notifications
- Navigate to Keys Section and add a Universal key for Notifications
- Download the .p8 file and keep it safe (it can only be downloaded once)
- Add this .p8 file to Firebase along with your Key ID and Team ID