如何使 fcm 推送通知过期或设置生命周期?

Md *_*din 5 android push-notification firebase-cloud-messaging

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

   {
      "to":"REGISTRATION_ID",  // "to" replaces "registration_ids"
     "notification": {
        "title": "Portugal vs. Denmark”,
        "body”: "5 to 1”
      },
      "time_to_live":"600"
}
Run Code Online (Sandbox Code Playgroud)

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

小智 5

您应该按照本文档使用以下内容:设置消息的生命周期。

"android": {
  "ttl":"600s"
}
Run Code Online (Sandbox Code Playgroud)

代替

"time_to_live":"600"
Run Code Online (Sandbox Code Playgroud)