2016-10-28 51 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

相關問題