【问题标题】:Multiple push notifications using ionic push使用离子推送的多个推送通知
【发布时间】:2016-04-02 13:17:28
【问题描述】:

当发送两个通知时,第二个总是会覆盖通知中心的第一个。 根据docs,这应该只在使用标签时发生:

“tag”:表示每条通知消息是否产生新的 进入通知中心。如果未设置,每个请求都会创建一个 新通知。如果设置,并且具有相同标签的通知是 已显示,新通知将替换现有通知。

然而这种情况总是发生在我身上,不管我是否为标签设置了一个值。

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

{  
   "tokens":[  
      "my-device-token"
   ],
   "profile":"my-profile-tag",
   "notification":{  
      "message":"message",
      "android":{  
         "payload":{  
            "collapse_key":9918519,
            "tag":2825928
         }
      }
   }
}

【问题讨论】:

  • Ionic 对此有何回应?就像在他们的文档中一样,他们根本没有提到 notId。

标签: android ionic-framework push-notification google-cloud-messaging firebase-cloud-messaging


【解决方案1】:

我解决了这个问题。 您需要将“notId”添加到“android”中的“data”中。 示例:

"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"
        }
    }
}

【讨论】:

    【解决方案2】:

    您需要在对象中指定一个唯一的通知 ID(例如 unix 时间戳),以免覆盖前一个 - 在您的情况下:

    {  
       "tokens":[  
          "my-device-token"
       ],
       "profile":"my-profile-tag",
       "notification":{  
          "notId": <some-unique-value-here>,
          "message":"message",
          "android":{  
             "payload":{  
                "collapse_key":9918519,
                "tag":2825928
             }
          }
       }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-12
      • 1970-01-01
      相关资源
      最近更新 更多