Md Shihab Uddin
Md Shihab Uddin

Reputation: 273

how to expire fcm push notifications or set lifetime?

My application sending push notifications from the server to several user devices. Notification will valid for a certain time period in my app scenario. currently, all notifications go through my app, but I don't send this at all after given expiration time. Code to send on a user.

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

Note: "time_to_live" attribute not works.

Upvotes: 5

Views: 7866

Answers (2)

mohsen
mohsen

Reputation: 31

You should set it as numeric:

"time_to_live": 600

Upvotes: 2

Ayman
Ayman

Reputation: 183

You should use the following as per this documentation: Setting the lifespan of a message.

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

instead of

"time_to_live":"600"

Upvotes: 5

Related Questions