我尝试使用iOS上的自定义分析系统跟踪推送通知打开和解雇,但我无法收到任何UNNotificationDismissActionIdentifier
个响应。
我在通知中心注册的代码:
if([[[UIDevice currentDevice] systemVersion] integerValue] >= 10){
UNNotificationCategory* generalCategory = [UNNotificationCategory
categoryWithIdentifier:@"GENERAL"
actions:@[]
intentIdentifiers:@[]
options:UNNotificationCategoryOptionCustomDismissAction];
// Register the notification categories.
UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
[center setNotificationCategories:[NSSet setWithObjects:generalCategory, nil]];
[center setDelegate:self];
};
当我发送推送通知时,我将类别设置为GENERAL。当我收到通知并向右滑动以解除通知时,我不会收到任何代表回调。
customDismissAction是否仅适用于本地通知?
答案 0 :(得分:2)
陷入同样的问题。 documentation提到这需要成为远程通知的APS有效负载的一部分。在找到/拾取它之前,我不得不仔细阅读它。确保在推送有效负载时添加您想要的任何类别,并在注册解除操作时使其匹配。因此,如果您使用示例“GENERAL”,则有效负载应包含该类别
"aps" : {
"category" : "GENERAL",
"alert" : {
"body" : "Some message",
},
etc...
}