我已经使用标识符在 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];