Ama*_*Zee 3 javascript firebase firebase-cloud-messaging
这是我关于 Stack Overflow 的第一个问题!
我正在尝试使用“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: (...) ....
Run Code Online (Sandbox Code Playgroud)
您似乎尚未申请接收通知的权限:
该方法
messaging.requestPermission()会显示一个同意对话框,让用户授予您的应用在浏览器中接收通知的权限。如果权限被拒绝,FCM 注册令牌请求会导致错误。Run Code Online (Sandbox Code Playgroud)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); });
| 归档时间: |
|
| 查看次数: |
8740 次 |
| 最近记录: |