iOS 10如何为远程通知设置UNotificationContent threadIdentifier
TL;DR:需要在APNs通知有效负载JSON中设置什么键来对应iOS 10如何为远程通知设置UNotificationContent threadIdentifier,ios,apple-push-notifications,unnotificationrequest,Ios,Apple Push Notifications,Unnotificationrequest,TL;DR:需要在APNs通知有效负载JSON中设置什么键来对应UNNotificationContent对象的threadIdentifier属性?e、 g.“category”键对应于categoryIdentifier属性 iOS 10引入了通知内容扩展,允许我们在扩展通知时显示视图控制器 我们提供的视图控制器符合UNNotificationContentExtension协议,该协议要求我们实现didceive(:)方法 该方法的文件包括以下段落: 当视图控制器可见时,可以多次调用此方
UNNotificationContent
对象的threadIdentifier
属性?e、 g.“category”
键对应于categoryIdentifier
属性
iOS 10引入了
通知内容扩展
,允许我们在扩展通知时显示视图控制器
我们提供的视图控制器符合UNNotificationContentExtension
协议,该协议要求我们实现didceive(:)
方法
该方法的文件包括以下段落:
当视图控制器可见时,可以多次调用此方法。具体地说,当新通知到达时,如果其threadIdentifier值与已显示通知的线程标识符匹配,则会再次调用它
可以在代码中为本地通知设置threadIdentifier
属性,但我不知道如何为从服务器发送到APN的远程通知设置该属性
UNNotificationContent
文档描述了此处的属性:
下面的JSON包含我尝试过的键(“thread”
和“thread identifier”
):
我找不到苹果关于如何设置的任何文档。有人能帮忙吗?我从苹果的一个联系人那里发现,填充此属性的正确键是
“thread id”
键
因此发送给APNs的JSON如下所示:
{
"aps" : {
"alert" : "Hello World!",
"sound" : "default",
"category" : "example-category",
"thread-id" : "my conversation blah blah"
}
"custom-field" : "some value",
}
这将填充通知内容扩展中可通过Notification.request.Content.threadIdentifier
访问的UNNotificationContent
对象的threadIdentifier
属性
通过设置此“线程id”
值,意味着内容扩展的didReceive(:)
方法将被多次调用。首先是在最初扩展通知时,然后是在新通知到达时使用相同的“thread id”
值时
我认为(希望)一旦iOS 10正式发布,这将被添加到官方文档中。说要使用apns,这篇文章是很久以前的事了。apns折叠id不是aps JSON中的密钥。它必须以HTTP头文件的形式发送,自iOS 10以来,HTTP头文件用于折叠通知。但我相信(不确定)“线程id”键应该用于在iOS 12中对消息进行分组(新分组fctinlty)
{
"aps" : {
"alert" : "Hello World!",
"sound" : "default",
"category" : "example-category",
"thread-id" : "my conversation blah blah"
}
"custom-field" : "some value",
}