我已在Appdelegate中使用标识符注册了UNNotificationAction的标识符,并且还在通知扩展名的info.plist中添加了该标识符。如果我安装了该应用程序,则按钮可见。我也交叉检查了类别标识符。它在示例应用程序中可以正常工作,但是当我将其集成到应用程序中时,行为却很奇怪。
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
UNNotificationAction *action = [UNNotificationAction actionWithIdentifier:@"next"
title:actionTitle1
options:UNNotificationActionOptionNone];
UNNotificationAction *action2 = [UNNotificationAction actionWithIdentifier:@"goto"
title:actionTitle2
options:UNNotificationActionOptionNone];
UNNotificationCategory *category = [UNNotificationCategory categoryWithIdentifier:@"category_identifier"
actions:@[action,action2] intentIdentifiers:@[]
options:UNNotificationCategoryOptionNone];
NSSet *categories = [NSSet setWithObject:category];
[center setNotificationCategories:categories];
答案 0 :(得分:0)
我多次拨打 setNotificationCategories ,这就是未显示UNNotificationAction的原因。