【问题标题】:how to expire fcm push notifications or set lifetime?如何使 fcm 推送通知过期或设置生命周期?
【发布时间】:2017-11-23 06:15:01
【问题描述】:

我的应用程序将推送通知从服务器发送到多个用户设备。通知将在我的应用场景中的特定时间段内有效。目前,所有通知都通过我的应用程序,但在给定的到期时间后我根本不发送。 发送给用户的代码。

   {
      "to":"REGISTRATION_ID",  // "to" replaces "registration_ids"
     "notification": {
        "title": "Portugal vs. Denmark”,
        "body”: "5 to 1”
      },
      "time_to_live":"600"
}

注意:“time_to_live”属性不起作用。

【问题讨论】:

  • 您可以在通知中添加自定义字段,并检查用户的设备是否已过期。如果有 - 那么就不要显示通知

标签: android push-notification firebase-cloud-messaging


【解决方案1】:

您应该按照本文档使用以下内容:Setting the lifespan of a message.

"android": {
  "ttl":"600s"
}

而不是

"time_to_live":"600"

【讨论】:

    【解决方案2】:

    你应该把它设置为数字:

    "time_to_live": 600
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多