Skip to main content

Firebase Integration

Elite Quiz uses Firebase for authentication, real-time database operations, and cloud storage. This guide will walk you through integrating Firebase with your app.

Creating a Firebase Project

  1. Go to the Firebase Console
  2. Click on "Add project" and follow the prompts to create a new project
  3. Enter a project name and accept the Firebase terms
  4. Choose whether to enable Google Analytics (recommended)
  5. Complete the project setup

Create Firebase 1

Create Firebase 2

After creating the project, you'll be taken to the Firebase project dashboard:

Create Firebase 3

Adding Your App to Firebase

Adding Android App

  1. In the Firebase console, click on the Android icon to add an Android app
  2. Enter your app's package name (the one you configured in the previous section)
  3. Enter an app nickname (optional)
  4. Enter your app's SHA-1 signing certificate (for Google Sign-In to work properly)
  5. Click "Register app"

Add Android

  1. Download the google-services.json file
  2. Click "Next" and follow the remaining setup instructions

Add Android 2

Add Android 3

Add Android 4

Add Android 5

Add Android 6

  1. Place the google-services.json file in the android/app directory of your Flutter project

Adding iOS App

  1. In the Firebase console, click on the iOS icon to add an iOS app
  2. Enter your app's Bundle ID (found in the ios/Runner.xcodeproj/project.pbxproj file)
  3. Enter an app nickname (optional)
  4. Enter your App Store ID (optional)
  5. Click "Register app"

Add iOS

  1. Download the GoogleService-Info.plist file
  2. Click "Next" and follow the remaining setup instructions

Add iOS 2

Add iOS 3

Add iOS 4

Add iOS 5

Add iOS 6

  1. Place the GoogleService-Info.plist file in the ios/Runner directory of your Flutter project

Enabling Firebase Authentication

Elite Quiz supports multiple authentication methods. Here's how to enable them:

  1. In the Firebase console, go to Authentication > Sign-in method
  2. Enable the authentication methods you want to use:
    • Email/Password
    • Google
    • Facebook
    • Phone
    • Apple (for iOS)

Add Firebase Auth

Configuring Google Sign-In

Google Sign-In is enabled by default when you add Firebase Authentication. Make sure you've added your SHA-1 fingerprint to your Firebase project.

Configuring Facebook Sign-In

To enable Facebook authentication:

  1. Create a Facebook Developer account and app at developers.facebook.com
  2. Configure your Facebook app for authentication
  3. Add the Facebook App ID and App Secret to Firebase Authentication

Auth 1

Configuring Phone Authentication

To enable Phone authentication:

  1. In the Firebase console, go to Authentication > Sign-in method
  2. Enable Phone authentication
  3. Add your test phone numbers if using in development

Auth 2

Setting Up Firebase for Battles

Elite Quiz uses Firebase Realtime Database for real-time battle functionality. To set this up:

  1. In the Firebase console, go to Realtime Database
  2. Click "Create Database"
  3. Choose a location (preferably close to your target audience)
  4. Start in test mode, then adjust security rules later

Connecting to Admin Panel

The final step is to connect your app to your Admin Panel:

  1. Open the file lib/utils/constant.dart in your project
  2. Look for the BASE_URL constant and update it with your Admin Panel URL:
const String BASE_URL = "https://your-admin-panel-url.com/api/";

Make sure to include the trailing slash at the end of the URL.

Testing Firebase Integration

After completing all the steps above, restart your app and test the following:

  1. User registration and login
  2. Social authentication methods (Google, Facebook, etc.)
  3. Real-time battle functionality

If any issues occur, check the Firebase console logs and your app logs for detailed error messages.