I am able to send, view and click on web notifications fine, and nothing appears wrong. However the console yields this when I click on a notification
Uncaught FirebaseError: Messaging: Missing App configuration value: "projectId" (messaging/missing-app-config-values).
projectId is definitely being passed to the configuration
Chrome version: Version 79.0.3945.130 (Official Build) (64-bit)
here is how I am configuring firebase:
var messaging;
if( firebase.messaging.isSupported() ){
var config = {
apiKey: "*************",
authDomain: "*************",
databaseURL: "*************",
projectId: "*************",
storageBucket: "*************",
messagingSenderId: "*************",
appId: "*************"
};
firebase.initializeApp(config);
messaging = firebase.messaging();
messaging.usePublicVapidKey("*************");
messaging.onMessage(function(payload) {
...
...
}
}
And my firebase-messeging-sw.js:
self.addEventListener('notificationclick', function(event) {
...
...
}
importScripts('https://www.gstatic.com/firebasejs/7.8.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/7.8.2/firebase-messaging.js');
firebase.initializeApp({'messagingSenderId': '***********'});
const messaging = firebase.messaging();
messaging.setBackgroundMessageHandler(function(payload) {
...
});
Any ideas?
You have to call initializeApp() before calling any other Firebase APIs. Your code is calling firebase.messaging.isSupported() first before initializeApp(). It looks like perhaps you only want to initialize Firebase if FCM is going to work, but that's simply not supported. I suggest initializing Firebase unconditionally. There is very little cost to doing so if you don't actually make use of any of the Firebase products.
I fixed this by re-getting my app's config snippet from here https://support.google.com/firebase/answer/7015592 and paste it again as my initializeApp object parameter. It was apparently caused by a Firebase upgrade.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With