2016-10-28 57 views
2

这是我在Stack Overflow上的第一个问题!Firebase云消息传递未能检索实例ID

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

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

回答

2

它看起来你有没有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); 
}); 
+1

这在丁目进行此处未示出 – daslicht

+0

对话框接缝我没有看到任何对话框 – Nirri

相关问题