Action Buttons

Users may interact with your application via notification categories. Categories define a type of notification your application can send. Each category contain actions that a user can perform in response, which manifest as buttons on the push notification.

Illustration of Notification Action

The Braze iOS SDK supports default push categories, including URL handling support for each push action button. Currently, the default categories have four sets of push action buttons: Accept/Decline, Yes/No, Confirm/Cancel and More. To register Braze’s default push categories, follow the integration instructions below:

Step 1: Adding Braze Default Push Categories

Use the following code to register for Braze’s default push categories when you register for push:

1
2
3
4
5
6
7
8
9
// For UserNotification.framework (iOS 10+ only)
NSSet *appboyCategories = [ABKPushUtils getAppboyUNNotificationCategorySet];
[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:appboyCategories];

// For UIUserNotificationSettings (before iOS 10)
NSSet *appboyCategories = [ABKPushUtils getAppboyUIUserNotificationCategorySet];
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge
                                                                         categories:appboyCategories];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
1
2
3
4
5
6
7
8
// For UserNotification.framework (iOS 10+ only)
let appboyCategories = ABKPushUtils.getAppboyUNNotificationCategorySet()
UNUserNotificationCenter.current().setNotificationCategories(appboyCategories)

// For UIUserNotificationSettings (before iOS 10)
let appboyCategories = ABKPushUtils.getAppboyUIUserNotificationCategorySet()
let settings = UIUserNotificationSettings.init(types: .badge, categories: appboyCategories)
UIApplication.shared.registerUserNotificationSettings(settings)

Clicking on push action buttons with background activation mode will only dismiss the notification and will not open the app. Button click analytics for these actions will be flushed to the server the next time the user opens the app.

If you wish to create your own custom notification categories, see our action button customization documentation.

See our sample code here for UserNotification.framework and here for UIUserNotificationSettings.

Step 2: Enable Interactive Push Handling

To enable Braze’s push action button handling, including click analytics and URL routing, add the following code to your app’s application:handleActionWithIdentifier:forRemoteNotification:completionHandler: delegate method:

1
2
3
[[Appboy sharedInstance] getActionWithIdentifier:identifier
                           forRemoteNotification:userInfo
                               completionHandler:completionHandler];
1
2
3
Appboy.sharedInstance()?.getActionWithIdentifier(identifier,
                         forRemoteNotification: userInfo,
                             completionHandler: completionHandler)
WAS THIS PAGE HELPFUL?
New Stuff!