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) => {})
For Apple client apps, you can receive notification and data payloads up to 4000 bytes over the Firebase Cloud Messaging APNs interface.
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.
'FCM does not work on the iOS simulator, you must test them using a real device. This is a restriction enforced by Apple.
You can send up to 240 messages/minute and 5,000 messages/hour to a single device.
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"
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With