有时未在远程通知中显示UNNotificationAction

时间:2020-01-22 11:15:06

标签: ios apple-push-notifications unnotificationscontentextension

我已在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];

1 个答案:

答案 0 :(得分:0)

我多次拨打 setNotificationCategories ,这就是未显示UNNotificationAction的原因。