Steps for iOS
In order to add your custom categories for notification so you can send push notifications with different buttons and actions behind it you can add it using method “saveUserNotificationCategories“. Here is the example code which needs to be added at AppDelegate method didFinishLaunchingWithOptions:
Objective C:
UNNotificationAction *ok = [UNNotificationAction actionWithIdentifier:@"OK"
title:NSLocalizedString(@"OK", nil)
options:UNNotificationActionOptionForeground];
UNNotificationAction *cancel = [UNNotificationAction actionWithIdentifier:@"CANCEL"
title:NSLocalizedString(@"CANCEL", nil)
options:UNNotificationActionOptionForeground];
NSArray *buttons = @[ ok, cancel ];
// create a category for message failed
UNNotificationCategory *buttonsAction = [UNNotificationCategory categoryWithIdentifier:@"ACTION_BUTTON" actions:buttons
intentIdentifiers:@[]
options:UNNotificationCategoryOptionCustomDismissAction];
[[Appoxee shared] saveUserNotificationCategories:@[buttonsAction]];
Swift:
let CUSTOM_ACTION1 = UNNotificationAction(identifier: "view_now", title: "CUSTOM_ACTION_TITLE", options: .foreground)
let CUSTOM_ACTION2 = UNNotificationAction(identifier: "skip", title: "CUSTOM_ACTION2_TITLE", options: .foreground)
let CUSTOM_CATEGORY = UNNotificationCategory(identifier: " CUSTOM_CATEGORY_NAME", actions: [CUSTOM_ACTION1, CUSTOM_ACTION2], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: "", options: .customDismissAction)
Appoxee.shared()?.saveUserNotificationCategories([CUSTOM_CATEGORY])
Â