gpt4 book ai didi

ios - Firebase 云消息传递中是否有适用于 iOS 的 ttl "time to live"的替代方案?

转载 作者:行者123 更新时间:2023-12-02 03:12:30 25 4
gpt4 key购买 nike

我正在使用 admin sdk 发送通知。

这是我的有效负载。我能够为 Android 设置 ttl(生存时间),但我不确定如何为 iOS 设置它。

基本上,如果通知发送失败,那么我根本不想重新发送它。

         const payload = {
notification: {
title: 'New Appointments!',
body: '',
},
data: {},
android: {
ttl: 1000,
},
apns: {
payload: {
aps: {
badge: 1,
"sound":"default"
},
},
},
};
admin.messaging().send(payload).then((response) => {})

最佳答案

我认为您正在寻找 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.

这方面的一个例子可以在 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"
}
}
}
}

关于ios - Firebase 云消息传递中是否有适用于 iOS 的 ttl "time to live"的替代方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50135245/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com