使用离子推送的多次推送通知

Dan*_*ncu 0 android push-notification google-cloud-messaging ionic-framework firebase-cloud-messaging

发送两个通知时,第二个通知将覆盖通知中心中的第一个通知.根据文档,这应该只在使用标签时发生:

"tag":指示每条通知消息是否在通知中心上生成新条目.如果未设置,则每个请求都会创建一个新通知.如果已设置,并且已显示具有相同标记的通知,则新通知将替换现有通知.

然而,无论我是否为标签设置了值,这种情况一直发生在我身上.

我甚至尝试设置一个随机标签&collapse_key(据我所知,在这种情况下我不应该相关,但我试了一下).仍然没有帮助.这是我发送的通知对象的示例:

{  
   "tokens":[  
      "my-device-token"
   ],
   "profile":"my-profile-tag",
   "notification":{  
      "message":"message",
      "android":{  
         "payload":{  
            "collapse_key":9918519,
            "tag":2825928
         }
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

小智 5

我解决了这个问题.您需要在"android"中的"data"中添加"notId".例:

"notification": {
    "title": "testing stack notification ",
    "message":"is it working",
    "android": {               
        "data": {
            "title": "testing stack notification",
            "message": "is it working",
            "style": "inbox",
            "summaryText": "yes its %n% notifications",
            "notId": "123456"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)