Documentation

Firebase Configuration

The mobile app uses Firebase Cloud Messaging (FCM) for push notifications. Connect your own Firebase project before building the app.

On this page
Set your package name first Firebase needs the final Android package name and iOS bundle identifier. Complete Change the package name before registering the apps, or you will have to register them again.

1. Create a Firebase project

  1. Open the Firebase Console

    Go to console.firebase.google.com and sign in with a Google account.

  2. Create the project

    Click Create a project, enter a name, and continue through the wizard.

  3. Wait for it to finish

    When the project is ready, click Continue.

2. Add the Android app

  1. Register the app

    In Project settings, click Add app → Android and enter your Android package name, for example com.yourcompany.salex.

  2. Download the config file

    Download google-services.json.

  3. Copy it into the project

    Place the file at:

    android/app/google-services.json

3. Add the iOS app

  1. Register the app

    In Project settings, click Add app → iOS and enter your iOS bundle identifier, for example com.yourcompany.salex.

  2. Download the config file

    Download GoogleService-Info.plist.

  3. Copy it into the project

    Place the file at:

    ios/Runner/GoogleService-Info.plist

    For iOS, it is best to add the file through Xcode (File → Add Files to "Runner") so it is included in the build.

iOS push notifications iOS also needs an APNs key uploaded in Firebase (Project settings → Cloud Messaging → Apple app configuration). You create the key in your Apple Developer account. Without it, notifications will not arrive on iPhones.

4. Configure with FlutterFire CLI (recommended)

FlutterFire CLI generates the Firebase settings file for every platform automatically.

dart pub global activate flutterfire_cli
firebase login
flutterfire configure

Select your Firebase project when asked and finish the prompts. The command generates:

lib/firebase_options.dart
Firebase CLI firebase login needs the Firebase CLI installed (npm install -g firebase-tools).

5. Verify initialization

Firebase must be initialized before the app starts. In lib/main.dart you should see:

await Firebase.initializeApp(
  options: DefaultFirebaseOptions.currentPlatform,
);

6. Check Cloud Messaging

  1. Open Project settings

    In the Firebase Console, click the gear icon, then Project settings.

  2. Open the Cloud Messaging tab

    Confirm that Firebase Cloud Messaging is enabled.

Push notifications are used for order updates, promotions and general announcements. On Android 13 and newer the user must tap Allow when the app asks for notification permission.

7. Test a notification

  1. Install on a real device

    Emulators are unreliable for push notifications, so use a physical phone.

  2. Log in to the app

    Allow notifications when prompted.

  3. Send a test message

    In the Firebase Console go to Messaging, create a test notification and send it to the device.

✓ Success looks like: the test notification appears on your phone.

Rebuild after adding the files:

flutter clean
flutter pub get
flutter run