Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Messaging Failing to Retrieve Instance ID

this is my first question on Stack Overflow!

I am trying to deploy my firebase application on the firebase server using the ' firebase deploy' command. While running the "messaging" example [provided by Firebase] on my local machine, I have no issues generating an instance ID. However, when I deploy the application on the Firebase server and run the app in the browser, the application is not able to retrieve the Instance ID from the FCM server. This is a snippet of the response that I am getting from the Chrome console:

No Instance ID token available. Request permission to generate one.
(index):226 Requesting permission...
(index):239 Unable to get permission to notify.  V
(index):226 Requesting permission...
(index):239 Unable to get permission to notify.  V {code: 

    "messaging/permission-blocked", 
    message: "Messaging: The required permissions were not grant… blocked instead. (messaging/permission-blocked)."}
code: "messaging/permission-blocked"message: "Messaging: The required permissions were not granted and blocked instead. (messaging/permission-blocked)."stack: (...) ....
like image 909
Aman Zee Avatar asked Mar 11 '26 02:03

Aman Zee


1 Answers

It looks like you haven't request permission to receive notifications:

The method messaging.requestPermission() displays a consent dialog to let users grant your app permission to receive notifications in the browser. If permission is denied, FCM registration token requests result in an error.

messaging.requestPermission()
.then(function() {
  console.log('Notification permission granted.');
  // TODO(developer): Retrieve a Instance ID token for use with FCM.
  // ...
})
.catch(function(err) {
  console.log('Unable to get permission to notify. ', err);
});
like image 190
Frank van Puffelen Avatar answered Mar 12 '26 15:03

Frank van Puffelen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!