【问题标题】:Set push notification Action Buttons设置推送通知操作按钮
【发布时间】:2023-03-10 23:59:01
【问题描述】:
UNNotificationAction *shopAction = [UNNotificationAction actionWithIdentifier:@"ShopNow"

                                                                        title:@"Shop Now ????️" options:UNNotificationActionOptionNone];

UNNotificationAction *dismissAction = [UNNotificationAction actionWithIdentifier:@"Dismiss"

                                                                           title:@"Dismiss" options:UNNotificationActionOptionDestructive];



UNNotificationCategory *shopCategory = [UNNotificationCategory categoryWithIdentifier:@"Shopping"

                                                                              actions:@[shopAction,dismissAction] intentIdentifiers:@[]

                                                                              options:UNNotificationCategoryOptionNone];

NSSet *categories = [NSSet setWithObjects:shopCategory, nil];

[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:categories];

我尝试了上面的代码,但在我的推送通知中没有显示按钮。提供任何关于 iOS 10 按钮推送通知的建议或示例。

【问题讨论】:

    标签: ios iphone push-notification apple-push-notifications ios10


    【解决方案1】:

    您需要在 JSON 中调用 category: 'shopping',或在 NODE .js 中调用 notification.category = 'shopping';

    对于 JSON,您可能还需要在类别之前包含 "mutable-content": 1

    你在运行什么服务器端?

    另外,希望这是在您的应用程序委托中吗?我把整个事情变成了一个函数,我称之为setActions(),然后我在DidFinishLaunchingWithOptions中调用了setActions()

    此代码驻留在您的基地中的什么位置?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-06-16
      • 1970-01-01
      • 2016-08-18
      • 2019-08-16
      • 1970-01-01
      • 1970-01-01
      • 2011-05-17
      相关资源
      最近更新 更多