MetaFox uses Firebase to many functionalities, such Live Video, push notifications on mobile apps and web, crash analytics, etc.
In this article, we will walk you through step by step to set up Google Firebase on MetaFox site.
Create a Firebase Project
Go to the Firebase Console, and sign in with your Google account.
Click on "Add project" to create a new Firebase project.
Follow the on-screen instructions to set up your project.
Obtain Configuration for Web App
On the Dashboard of your Fireabase project, let's create a new Web App and follow the on-screen instructions to register the Web app.
After registering Web app successfully, go to the Project Settings > General tab. Choose the Web App that you just created and obtain the Firebase configuration as below
The Firebase configuration of your Web app will be as be below
// For Firebase JS SDK v7.20.0 and later, measurementId is optional const firebaseConfig = { apiKey: "AIzaSyBaSdeTWW7zVeYGtv-_XXXXXXXXXX", authDomain: "metafox-XXXXX.firebaseapp.com", projectId: "metafox-XXXXX", storageBucket: "metafox-XXXXX.appspot.com", messagingSenderId: "1087373XXXXX", appId: "1:108737343652:web:05dbe1415089c5XXXXX", measurementId: "G-XXXXX" };
We are going to configure the Firebase configuration within MetaFox site.
Let's log in to your MetaFox site with Admin user and go to AdminCP Dashboard > App Settings > Firebase
Configure Firebase settings with the related values above as the screenshot
Click the Save Changes button to apply the settings.
Enable Firebase Cloud Messaging (FCM)
In the Firebase Project Settings, navigate to the "Cloud Messaging" tab from the left sidebar. Then, follow the on-screen instructions to enable FCM
Generate Service Account
Now, in the Firebase Project Settings, navigate to the Service accounts tab and to generate New Private Key
At this step, you can download the JSON file for the Service Account.
Configure Service Account in MetaFox
Let's get back to AdminCP Dashboard of your MetaFox site. Go to App Settings > Firebase > Import Settings page
Upload the JSON file obtained in the previous step. The Firebase configuration of Service Account will be updated automatically then.
That's it! You've successfully set up Firebase on your MetaFox site.