Docly Child

Firebase Configuration

Estimated reading: 4 minutes

Creating a new firebase project

  • We are creating the “Example” sample project.
  • After completing the project, you will be presented with this type of dashboard.
  • Go to the Project Settings and configure the Support Email

Adding app with the package name in firebase console.

  • On the Firebase console, click the Android icon.
  • Enter Package Name(e.g com.iqonic.example) and click on register app

Setting Up Firebase Authentication

  • Go to Build->Authentication tab and click on Get started
  • Then Select the Email/Password, Google and Phone Number one by one and Enable it.
  • Re-check if all this 3 modes of authentication are enabled or not.

Activating the Firestore Database

  • Go to Build->Firestore Database tab and click on Get Started
  • 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.
  • Change the firestore’s rules to save the data in a database.

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 true;
    }
  }
}

SHA Fingerprint

IMPORTANT

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 this logins we need a SHA Fingerprint cerificate.

Add a SHA fingerprint to Firebase

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

  1. In your Project settings, go to the Your apps card.
  1. Select the Firebase Android app to which you want to add a SHA fingerprint
  1. Click Add fingerprint
  1. Enter or paste the SHA fingerprint, then click Save

How to generate the and SHA from Andriod Studio

IMPORTANT

There are two types of SHA Fingerprint, Release SHA Fingerprint and Debug SHA Fingerprint, Here we will how to generate both type of SHA Fingerprint

1. Debug SHA Fingerprint

  • Open Android Module and wait for the build to finish
  • On the right side of the screen, look for the “gradle” option and click it
  • By clicking, you will access the menu options. Select the first tab, and a dialog will appear
  • Enter “signingReport” into the dialog box
  • After building the gradle, the SHA and SHA256 will be displayed in the console log
  • Copy the SHA and SHA256 one by one and paste them into the above-mentioned open firebase window

2. Release SHA Fingerprint

  • Launch Android Module and wait for the build to finish
  • From the file menu, Select Project Structure
  • Navigate to the module section and Select App -> Singing Configurations
  • Click on “+” icon and add new module name “release”
  • Please select the JKS that you created at the time of release here (if JKS is not created then please create first and then select.)
  • Check that the release configuration is selected in the gradle file
  • Repeat the preceding steps to run the command, and the Release SHA will be displayed in the console log

Enable Firebase Notification in Mobile for both Android and IOS

  • Firstly, go to the Admin Dashboard, Click on  the App Configuration – > Firebase in the left sidebar
  • Add your Firebase Web API Key ( Server Key )  in App ID and click on Save.

For Server Key

  • Click on  Project Overview  –> Settings – Cloud Messaging 
  • In Cloud Messaging API (Legacy), click the three dots and select “Manage in Google Cloud Console.” After the page is successfully redirected, open the Firebase Console again and Refresh the Cloud Messaging tab to find the Server Key, copy that key and set it in Admin Panel.
  • After enable it, Firebase Notification is working!
 For IOS :
  • Login into Firebase and select the your project
  • Go to the Project Settings and select the Cloud Messaging section
  • Scroll down and you can show Apple app configuration section and select your iOS build identifiers which you have used for the Specific App
  • You can get Upload APNs Certificates popup and 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
}
 
Great! You have successfully configured Firebase!

Leave a Comment

Share this Doc
CONTENTS