Skip to main content

Firebase Configuration

Setting up Firebase for your Handyman Service Project

Create A New Firebase Project

  1. We are creating the "Example" sample project.

    Image

  2. After completing the project, you will be presented with this type of dashboard.

    Image

  3. Go to the Project Settings and configure the Support Email.

    Image

Add App With The Package Name In Firebase Console

  1. On the Firebase console, click the Android icon.

    Image

  2. Enter Package Name (e.g., com.example.userApp) and click on register app.

    Image

  3. After registering the app, you will receive the Google JSON file, download it and save it to the android/app/ folder.

    Image

Set Up Firebase Authentication

  1. Go to Build -> Authentication tab and click on Get started.

    Image

  2. Then select the Email/Password, Google, Apple, and Phone Number one by one and enable them.

    Image

  3. Re-check if all these 3 modes of authentication are enabled or not.

    Image

  4. For Connecting Chat server

    • Click on Setting tab
    • Select Users Action
    • Disable "Email Enumeration Protection" option

    Image

Activating The Firestore Database

  1. Go to Build → Firestore Database tab and click on Get Started.

    Image

  2. When you click the Get Started button, a dialogue will appear asking you to choose a mode. Because we are testing, we will select the Start in Test Mode option and then click Next and then enable it.

    Image

  3. Change the Firestore's rules to save the data in a database.

    Image

Before Changing Rules:

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.time < timestamp.date(2022, 8, 26);
}
}
}

After Changing Rules:

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}

SHA Fingerprint

info

SHA-1 fingerprint is a unique key generated for your PC that can be used for signing. It is important to have in the add Firebase as we are using Google Login and OTP Login, and to authorize these logins, we need a SHA Fingerprint certificate

Add a SHA fingerprint to Firebase:

  1. Follow these steps if you didn't initially provide a SHA certificate fingerprint for your Firebase Android app or if you need to add an additional one:

    • In your Project settings, go to the Your apps card.

    Image

    • Select the Firebase Android app to which you want to add a SHA fingerprint.

    Image

    • Click Add fingerprint.

    Image

    • Enter or paste the SHA fingerprint, then click Save.

    Image

How to generate the SHA from Android Studio:

There are two types of SHA Fingerprint, Release SHA Fingerprint, and Debug SHA

Fingerprint. Here we will see how to generate both types of SHA Fingerprint.

Add .p8 Certificate to enable OTP Login in iOS

  1. Login into Firebase and select your project.

  2. Go to the Project Settings and select the Cloud Messaging section.

  3. Scroll down to find the Apple app configuration section and select your iOS build identifiers that you have used for the Customer App.

  4. You will see an Upload APNs auth key popup. Drag or select your support.p8 certificate.

  5. Add your Key ID and Team ID.

Enable Firebase Notification in Mobile for Both Android and iOS

Obtain Project ID From Firebase

  1. Click on Project OverviewProject SettingsGeneral

  2. In General Settings Copy the “Project ID from Firebase”

    Firebase Project ID

Obtain Firebase Service Account Json file

  1. Click on Service accounts in the project Settings.

  2. Click on Generate new Private key Button and Download the service Json file.

    Firebase Service Account Json File

Add Firebase Project ID and Service Account Json file to Admin Panel

  1. Go to the Admin Panel, select the "Setting" option in the left sidebar under the System section.

  2. Select "App Configuration Setting" and enable Firebase Notification.

  3. Add your Firebase Project ID and Upload your Firebase Service Account Json file and click on * *Save** Button.

    Handyman Service - Notification Configuration

info

If Service Account Json file upload fails due to permission issue or any other reason then,

  • Open your backend code.
  • Create folder with name "data" inside storageapp
  • Place the Service Account JSON file inside the "data" folder.

For iOS:

  1. Create APNs Certificate, please visit the documentation and follow step 3.
  2. Log in to Firebase and select your project.
  3. Go to the Project Settings and select the "Cloud Messaging" section.
  4. Scroll down to the Apple app configuration section and select your iOS build identifiers used for the Specific App.
  5. You'll get an "Upload APNs Certificates" popup, then drag or select your support.p12 certificate.

After that, add the below code in AppDelegate.swift file under ios folder in your project:

if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
Successfull !!

Great! You Have Successfully Configured Firebase!