Firebase Configuration
Create Firebase Project
- Goto >> Firebase console
- Register a new account or try to log in with existing google accout.
- Once logged in, you can see firebase console dashboard. Click on Add Project.Provide a project name, and then select country and then after that click on Create Project. For example, see the below image.
- Once the project has been created, it will automatically redirect to Firebase dashboard screen.
- Now you need to add web project/application to the firebase project.
-
Goto Authentication and open " Sign-in method " Tab
-
Now go to Authentication , -> In Authentication go to settings -> In "Authorized domains", localhost and a Firebase domain are automatically added. -> Here we've to add domain name without http:// and https://
8.Goto Project settings in firebase dashboard option.
-
Goto Project settings and scroll down you will find created web App there you find config option that will have firebase settings for front end.
-
here you have to set all details
-
You need to set this details in eDemand admin panel -> Firebase Settings Page from Settings page
Where to find Vapid key
- Open the Cloud Messaging tab of the Firebase console Settings pane and scroll to the Web configuration section.
- In the Web Push certificates tab, click Generate Key Pair. The console displays a notice that the key pair was generated, and displays the public key string and date added
Or look at steps by steps images below
- Open Project settings
- Choose Cloud Messaging, scroll down to Web configuration. In Web Push certificates you can find Vapid key ( If it doesn't exists, click Generate Key Pair to create )
- You need to set this details in firebase-messaging-sw.js file
If firebase-messaging-sw.js not exist inside your root folder then create a file with firebase-messaging-sw.js name inside your project folder.
// Replace the following with your app's Firebase project configuration
firebase.initializeApp
({
apiKey: "Your apiKey",
authDomain: "Your authDomain",
projectId: "Your projectId",
storageBucket: "Your storageBucket",
messagingSenderId: "Your messagingSenderId",
appId: "Your appId",
measurementId: "Your measurementId"
});
View firebase-messaging-sw.js and put content in file as below
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase.js');
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-messaging.js');
// Initialize Firebase
var config = {
apiKey:"Your apiKey" ,
authDomain:"Your authDomain" ,
projectId:"Your projectId" ,
storageBucket:"Your storageBucket" ,
messagingSenderId:"Your messagingSenderId" ,
appId:"Your appId",
measurementId:"Your measurementId"
};
firebase.initializeApp(config);
const fcm=firebase.messaging();
fcm.getToken({
vapidKey:"your vapidey"
}).then((token)=>{
// console.log('getToken');
});
fcm.onBackgroundMessage((data)=>{
// console.log('onBackgroundMessage - ',data);
})
Upload json file In firebase configuration