【问题标题】:Firebase Cloud Messaging Failing to Retrieve Instance IDFirebase 云消息传递无法检索实例 ID
【发布时间】:2016-10-28 06:00:43
【问题描述】:

这是我关于 Stack Overflow 的第一个问题!

我正在尝试使用“firebase deploy”命令在 firebase 服务器上部署我的 firebase 应用程序。在我的本地计算机上运行“消息传递”示例 [由 Firebase 提供] 时,生成实例 ID 没有问题。但是,当我在 Firebase 服务器上部署应用程序并在浏览器中运行应用程序时,应用程序无法从 FCM 服务器检索实例 ID。这是我从 Chrome 控制台获得的响应的 sn-p:

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: (...) ....

【问题讨论】:

    标签: javascript firebase firebase-cloud-messaging


    【解决方案1】:

    你好像没有request permission to receive notifications

    messaging.requestPermission() 方法会显示一个同意对话框,让用户授予您的应用在浏览器中接收通知的权限。如果权限被拒绝,FCM 注册令牌请求会导致错误。

    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);
    });
    

    【讨论】:

    • 我也没有看到对话框
    • 如果对话框未显示,请尝试最小化和最大化 Chrome 窗口。之后显示对话框
    猜你喜欢
    • 1970-01-01
    • 2018-07-27
    • 1970-01-01
    • 2019-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-12
    • 1970-01-01
    相关资源
    最近更新 更多