2017-03-01 154 views
0
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推送通知的任何建議或示例。設置推送通知操作按鈕

回答

1

你需要調用你的JSON category: 'shopping',或notification.category = 'shopping';在NODE的.js

對於JSON,你可能還需要包括"mutable-content": 1,類別之前。

你在運行什麼服務器端?

此外,這是在你的應用程序委託有希望嗎?我把這個東西變成了一個func我叫setActions(),然後我叫setActions()裏面DidFinishLaunchingWithOptions

這段代碼駐留在你的基地?