Docly Child

Firebase Configuration

Estimated reading: 6 minutes
NOTE
  1. For Firebase, you can only create one project, but you must include two apps in that project.
  2. Remember to set up the remote settings.

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
  • After registering the app, you will receive the google-services.json file; download it and save it to the android/app/ folder

Adding IOS app with the package name in firebase console.

  • On the Firebase console, click the IOS icon.
  • Enter Package Name(e.g com.iqonic.example) and click on register app
  • After registering the app, you will receive the GoogleService-Info.plist file; download it and drag and drop to xcode as location shown in image

    Here is the steps how to open ios in xcode
  • Open Xcode.
  • Select Open another Project.
  • Open the iOS directory within your app.
  • Now, click on Done button.

Setting Up Firebase Authentication

  • Go to Build->Authentication tab and click on Get started
  • Then Select the Email/Password, Google, Apple, 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
request.auth != null;
}
}
}

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

Generating The Configure Key For OTP Login In iOS

  • Select the Keys to option from the left panel
  • Select the Add Key button
  • Add Key Name and select Apple Push Notifications service (APNs) option
  • Then Select on Continue button and download the support p8 certificate
  • 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 Customer App
  • You can get Upload APNs auth key popup and drag or select your support.p8 certificate
  • Added your Key ID and Team ID

How Enable Firebase Notification in Mobile for both Android and IOS

  • Firstly, go to the Admin Panel, select the Setting option in the left sidebar under the System section.
  • Select App Configuration Setting and enable the Firebase Notification. Add your Firebase Web API Key ( Server Key ) and click on Save button.
  • For Server Key: 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