Skip to main content

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

  1. Visit Firebase Console
  2. Sign in with your Google account
  3. Click on "Add project" button
  4. Enter a project name and choose a suitable project ID
  5. Select your country/region and click "Create Project"

Firebase Create Project

  1. Tap on the Flutter icon to add Flutter to your Firebase project

Firebase Flutter

  1. 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
  1. Copy and paste both commands one by one like this:

Firebase Command Run

Important: Make sure to change your package name first before setting up Firebase!

  1. Select Android, iOS, and Web platforms when prompted

Select Firebase Platforms

  1. If asked to override existing Firebase settings, type "yes" and press Enter

Override Existing Firebase

Enable Phone Authentication

Phone authentication is critical for the app's login functionality. Follow these steps:

  1. In the Firebase console, go to the Authentication section
  2. Turn on phone login as shown below:

Firebase Auth

  1. Enable Firebase phone auth by tapping the switch button:

Enable Firebase Auth

  1. For testing purposes, add Firebase testing phone numbers to avoid temporary blocks

Firebase Testing

Resolving "missing-client-identifier" Issues

When using real phone numbers, you might encounter a "missing-client-identifier" error. To resolve:

  1. Open your terminal in the project location and run:
cd android
./gradlew signinReport
  1. Copy the SHA1 and SHA256 keys from the result:

SHA Key

  1. Add these keys to your Firebase project settings:

Add SHA Key

Setup Notifications

  1. Get the server key from your Firebase project
  2. Go to Project Settings → Cloud Messaging → Manage API on Google Cloud Console

Enable FCM

FCM Server Key

  1. Copy the server key:

FCM Server Key Get

  1. Set the key in your admin panel's Notification FCM key field:

FCM Set Admin

iOS Notification Setup

For iOS devices, complete these additional steps:

  1. In Xcode, open your project
  2. Select the project icon representing your app
  3. Select your app's target
  4. Navigate to the Capabilities tab
  5. Enable Push Notifications
  6. Check Remote Notifications and Background Fetch from Enabling Background Modes

Xcode Notification

Apple's Push Notification service (APNs) supports two connection types. For token-based (.p8):

  1. Log in to the Apple Developer Portal
  2. Navigate to Certificates, IDs & Profiles > Identifiers > App IDs
  3. Check Capabilities > Push Notifications

Enable FCM Xcode

Xcode Notification 2

  1. Navigate to Keys Section and add a Universal key for Notifications
  2. Download the .p8 file and keep it safe (it can only be downloaded once)

APN Updated

  1. Add this .p8 file to Firebase along with your Key ID and Team ID

Add P8 in Firebase