有没有办法使用google的firebase发送静音APNS?似乎如果应用程序在后台,它将始终向用户显示通知.
谢谢?
push-notification apple-push-notifications firebase silentpush firebase-cloud-messaging
从文档:
thread-id|string| 当显示通知时,系统可视地将具有相同线程标识符的通知组合在一起.对于远程通知,threadIdentifier属性的值设置为此请求标头的值.
我们的推送通知有效负载:
{
aps = {
alert = {
body = "Leeroy J asked you: Test Push Notification";
};
badge = 12;
sound = default;
"thread-id" = 9150;
};
n = "6kQ/0x6556";
r = 9150;
}
{
aps = {
alert = {
body = "Leeroy J re: Test Push Notification";
};
badge = 13;
sound = default;
"thread-id" = 9150;
};
n = "6l8/0x6582";
p = 7197;
r = 9150;
}
Run Code Online (Sandbox Code Playgroud)
这是消息中心的样子: …
TL; DR:需要在APNs通知有效负载JSON中设置哪些密钥才能对应对象的threadIdentifier属性UNNotificationContent?例如,"category"钥匙对应于categoryIdentifier财产.
iOS 10引入了Notification Content Extension允许我们在扩展通知时呈现视图控制器.
我们提供的视图控制器符合UNNotificationContentExtension协议,这要求我们实现该didReceive(_:)方法.
该方法的文档包括以下段落:
当您的视图控制器可见时,可以多次调用此方法.具体地说,当新的通知到达时,再次调用它的threadIdentifier值与已经显示的通知的线程标识符匹配.
threadIdentifier可以在本地通知的代码中设置该属性,但我不知道如何将其设置为从服务器发送到APN的远程通知.
该UNNotificationContent文档描述了此处的属性:http://developer.apple.com/reference/usernotifications/unnotificationcontent
以下JSON包含我尝试过的密钥("thread"和"thread-identifier"):
{
"aps" : {
"alert" : "Hello World!",
"sound" : "default",
"category" : "example-category",
"thread" : "example-thread",
"thread-identifier" : "example-thread-identifier"
}
"custom-field" : "some value",
}
Run Code Online (Sandbox Code Playgroud)
我找不到Apple提供的有关如何设置此文档的任何文档.有人可以帮忙吗?
Firebase FCM 消息支持tagAndroid,这会导致新通知用具有相同标记的旧通知替换前一个通知。有没有办法在ios上做同样的事情?
这个答案建议在数据有效负载中使用线程 ID。但这对我不起作用。
ios firebase google-cloud-messaging firebase-cloud-messaging cordova-plugin-fcm