I'm using Firebase Cloud Messaging for notification in my Meteor application. I've followed this documentation(official FCM documentation for Node.js application) to integrate Firebase SDK into the Meteor project for client side. Then I've written a serviceworker file and put it in /client
directory. My /client/firebase-messaging-sw.js
file looks like bellow:
import * as firebase from "firebase";
var config = {
apiKey: "API-KEY",
authDomain: "PROJECT.firebaseapp.com",
databaseURL: "https://PROJECT.firebaseio.com",
storageBucket: "PROJECT.appspot.com",
messagingSenderId: "SENDER-ID"
};
firebase.initializeApp(config);
In componentDidMount
of my react component I wrote following snippet:
componentDidMount(){
const messaging = firebase.messaging();
messaging.requestPermission()
.then(function(){
console.log("permission granted");
return messaging.getToken();
})
.then(function(token){
console.log(token);
})
.catch(function(error){
console.log("error getting permission : " , error);
})
}
When the application runs it gets the notification permission properly, but gets a reject value in the promise due to messaging.getToken()
method.
Is there any problem in the process I followed to integrate FCM in my Meteor app? Or can anyone suggest any reference to integrate FCM in Meteor?
via mostafiz
No comments:
Post a Comment