【发布时间】:2020-01-22 11:15:06
【问题描述】:
我已经在 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];
【问题讨论】:
-
您如何将其实际集成到您的应用中?尝试在每次应用启动时调用它。
-
我只在 didFinishLunch 中添加了它。
标签: ios apple-push-notifications unnotificationscontentextension