Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there alternative to ttl "time to live" for iOS in firebase cloud messaging?

I am sending the notifications using admin sdk.

This is my payload. I was able to set ttl (Time to Live) for Android but I am not sure how I can make it for iOS.

Basically if notification fails to send, then I dont want to resend it at all.

         const payload = {
             notification: {
                title: 'New Appointments!',
                body: '',
              },
             data: {},
             android: {
               ttl: 1000, 
             },
             apns: {
               payload: {
                 aps: {
                   badge: 1,
                  "sound":"default"
                 },
               },
             },
            };
admin.messaging().send(payload).then((response) => {})
like image 410
AlexZvl Avatar asked May 02 '18 12:05

AlexZvl


People also ask

Does Firebase Cloud Messaging work on iOS?

For Apple client apps, you can receive notification and data payloads up to 4000 bytes over the Firebase Cloud Messaging APNs interface.

Is Firebase Cloud Messaging real time?

This includes downstream messages from servers to client apps, and upstream messages from client apps to servers. Firebase is a cloud service designed to power real-time, collaborative applications.

Does firebase messaging work on iOS simulator?

'FCM does not work on the iOS simulator, you must test them using a real device. This is a restriction enforced by Apple.

Is there any limit for Firebase Cloud Messaging?

You can send up to 240 messages/minute and 5,000 messages/hour to a single device.


1 Answers

I think you're looking for apns-expiration:

A UNIX epoch date expressed in seconds (UTC). This header identifies the date when the notification is no longer valid and can be discarded.

If this value is nonzero, APNs stores the notification and tries to deliver it at least once, repeating the attempt as needed if it is unable to deliver the notification the first time. If the value is 0, APNs treats the notification as if it expires immediately and does not store the notification or attempt to redeliver it.

An example of this is seen in the FCM docs for ttl:

{
  "message":{
    "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "data":{
      "Nick" : "Mario",
      "body" : "great match!",
      "Room" : "PortugalVSDenmark"
    },
    "apns":{
      "headers":{
        "apns-expiration":"1604750400"
      }
    },
    "android":{
      "ttl":"4500s"
    },
    "webpush":{
      "headers":{
        "TTL":"4500"
      }
    }
  }
}
like image 190
AL. Avatar answered Oct 05 '22 21:10

AL.