Firebase 云消息传递测试不起作用

Firebase Cloud Messaging test not working

我正在尝试让 Firebase 云消息传递正常工作。我现在只是在尝试测试。我所做的就是这个post:

中的一切

https://firebase.google.com/docs/cloud-messaging/js/client?authuser=0#retrieve-the-current-registration-token

然后在那一端你会看到这个:

messaging.getToken().then((currentToken) => {

然后我复制这个 currentToken 并通过转到 Firebase(网站)> 成长(边栏)> 云消息(边栏)> 发送你的第一条消息(按钮)> 填写来将其用作测试a 'Notification title' 和 'Notification text' > 发送测试消息(右侧蓝色按钮)> 添加我从上面复制的 currentToken 或检查之前添加的消息 > 测试(按钮)...(见下面的屏幕截图)

我假设在单击 'Test' 按钮后它应该向我的 phone 发送通知(我允许通知并从中获取令牌)。我用我的电脑测试了这个,也没有得到回应。在我的电脑和笔记本电脑上使用 Chrome 来处理重要的事情。

我在这里错过了什么?

我遗漏了在 manifest.json 中添加 gcm_sender_id 的重要部分。我完全按照这个 link 进行了操作,并且效果很好。您可以使用 Firebase Cloud Messaging 测试平台代替文章中的 Postman 方法:

https://codeburst.io/how-to-add-push-notifications-on-firebase-cloud-messaging-to-react-web-app-de7c6f04c920