vla*_*dan 15 notifications apple-push-notifications ios firebase firebase-cloud-messaging
我在iOS上遇到静音通知问题.
当我的申请处于后台时,我不会收到FCM发送的无声通知.但是,如果我尝试直接发送到APNS,则会成功收到通知.
这是发送给FCM的JSON:
{
"to" : "<token>",
"priority": "high",
"content_available": true,
"data" : {
"<key>" : "<string>",
"<key2>" : "<string>"
}
Run Code Online (Sandbox Code Playgroud)
}
这是直接发送给APNS的JSON:
{
"aps": {
"content-available": 1
},
"<key>": "<string>",
"<key>": "<string>"
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试删除"优先级"键,因为我看到有人说如果已经设置了"content_available",我不应该设置优先级.它没用.
Ala*_*rao 15
删除"通知"键值对并添加"content_available":true
它看起来像这样
{
"to" : "...",
"priority": "high",
"content_available": true,
"data" : {
....
}
}
Run Code Online (Sandbox Code Playgroud)
这应该使它成为一个静默的APNS,你需要处理相应的APNS委托方法.
您需要通过代理处理此问题有关详细信息,请参阅此firebase文档:https://firebase.google.com/docs/cloud-messaging/concept-options
我找到了一个解决方法。我在“通知”字段中为“声音”设置了一个空值,即使应用程序处于后台,也会发出无声通知。
{
"to" : "...",
"priority": "high",
"notification": {
"sound": ""
},
"data" : {
....
}
}
Run Code Online (Sandbox Code Playgroud)
我的预感是,苹果不允许具有“高”优先级的静默通知,并且以某种方式“notification”:{“sound”:“”}欺骗APNS该通知不是静默通知。
归档时间: |
|
查看次数: |
15616 次 |
最近记录: |