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推送通知的任何建议或示例。
答案 0 :(得分:1)
您需要在JSON中调用category: 'shopping'
,或在NODE .js中调用notification.category = 'shopping';
对于JSON,您可能还需要在类别之前加入"mutable-content": 1
。
您正在运行哪个服务器端?
此外,这是您的应用程序代表希望?我把这整件事变成了一个名为setActions()
的函数,然后我在setActions()
内调用了DidFinishLaunchingWithOptions
此代码位于您的基地?