当应用程序处于前台时,Angular 8 firebase 推送通知不起作用

use*_*021 7 firebase-cloud-messaging angular

我正在按照此文档在我的 Angular Web 应用程序上实现 FCM。当我发送通知时,它会在应用程序未处于活动状态时成功接收。(接收后台通知)。但是如果应用程序处于活动状态,我就不会收到通知。

按照以下步骤操作:https : //dev.to/mayurkadampro/angular-8-firebase-cloud-messaging-push-notifications-97a

基本上这不会在有新消息时触发

this.angularFireMessaging.messages.subscribe(
(payload) => {
    console.log("new message received. ", payload);
    this.currentMessage.next(payload);})
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

mat*_*gll 1

我的 Vue.js 应用程序也有同样的问题。我仍然不清楚消息传递服务是如何工作的,但尝试更改输入有效负载。我想您正在使用 Postman 测试通知。

前台通知的有效负载:

{    
  "data":{ ..  },
  "to": "....",
}
Run Code Online (Sandbox Code Playgroud)

后台通知的有效负载:

{
  "notification": { ... },
  "to": ""
}
Run Code Online (Sandbox Code Playgroud)