Firebase Setup

8. Firebase Setup (Mobile)

All three apps — User, Restaurant and Driver — talk to the same Firebase project as the web panels. Create the project first — see Create Firebase Project — then register every app inside it.

Six registrations, one project. Each app needs its own Android and iOS entry, so a full Foodie setup registers six apps in the one Firebase project: User (Android + iOS), Restaurant (Android + iOS) and Driver (Android + iOS). Each produces its own google-services.json / GoogleService-Info.plist — keep them straight, as they are not interchangeable.

8.1. Register the apps

Repeat this for each of the three apps:

  1. Open the Firebase console and select your project.
  2. Click Add app → Android and enter that app’s package name; add its SHA-1 and SHA-256 fingerprints (see Generate SHA Keys) — these are required for Google and Phone sign-in. Download google-services.json.
  3. Click Add app → iOS and enter that app’s bundle identifier. Download GoogleService-Info.plist. iOS does not need SHA fingerprints.

8.2. Place the config files

  • Android: put google-services.json in android/app/.
  • iOS: open ios/Runner.xcworkspace in Xcode and drag GoogleService-Info.plist into the Runner group (tick “Copy items if needed”).

8.3. Configure with the FlutterFire CLI (alternative)

Instead of downloading the files by hand, you can let the FlutterFire CLI generate lib/firebase_options.dart for both platforms:

npm install -g firebase-tools firebase login dart pub global activate flutterfire_cli flutterfire configure --project=YOUR_PROJECT_ID

The CLI writes a firebase_options.dart holding the per-platform configuration, which main.dart passes to Firebase.initializeApp():

import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(MyApp());
}

8.4. Firebase dependencies

The Firebase plugins the app uses are already declared in pubspec.yaml — Core, Auth, Firestore, Storage and Messaging. Just fetch them:

flutter pub get
dependencies:
flutter:
sdk: flutter
firebase_core: ^3.6.0
firebase_auth: ^5.3.1
cloud_firestore: ^5.4.4
firebase_storage: ^12.3.4
firebase_messaging: ^15.1.3

8.5. Enable the sign-in providers

In the Firebase console open Authentication → Sign-in method and enable the providers Foodie uses:

  • Email/Password — standard customer, vendor and admin sign-in.
  • Phone — OTP login (requires the SHA fingerprints on Android).
  • Google — used by the apps and both web panels.
  • Apple — required by Apple if you offer other social logins on iOS.

Then open Authentication → Settings → Authorized domains and add the domains of your Website Panel and Restaurant Panel.