Skip to content

Action buttons

The Braze Swift SDK provides URL handling support for push action buttons.

There are four sets of default push action buttons for Braze default push categories: Accept/Decline, Yes/No, Confirm/Cancel, and More.

A GIF of a push message being pulled down to display two customizable action buttons.

If you want to create your own custom notification categories, see action button customization.

When integrating push using the configuration.push.automation configuration option, Braze automatically registers the action buttons for the default push categories and handles the push action button click analytics and URL routing.

Manual integration

To manually enable these push action buttons, first register for the default push categories. Then, use the didReceive(_:completionHandler:) delegate method to enable push action buttons.

Step 1: Adding Braze default push categories

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

1
UNUserNotificationCenter.current().setNotificationCategories(Braze.Notifications.categories)
1
[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:BRZNotifications.categories];

Step 2: Enable interactive push handling

To enable our push action button handling, including click analytics and URL routing, add the following code to your app’s didReceive(_:completionHandler:) delegate method:

1
AppDelegate.braze?.notifications.handleUserNotification(response: response, withCompletionHandler: completionHandler)
1
2
[AppDelegate.braze.notifications handleUserNotificationWithResponse:response
                                              withCompletionHandler:completionHandler];

If you use the UNNotification framework and have implemented the Braze notification methods, you should already have this method integrated.

Push category customization

In addition to providing a set of default push categories, Braze supports custom notification categories and actions. After you register categories in your application, you can use the Braze dashboard to send these custom notification categories to your users.

These categories can then be assigned to push notifications via our dashboard to trigger the action button configurations of your design.

Example custom push category

Here’s an example that leverages the LIKE_CATEGORY displayed on the device:

A push message displaying two push action buttons "unlike" and "like".

Step 1: Register a category

To register a category in your app, use a similar approach to the following:

1
2
3
4
5
6
7
8
9
10
Braze.Notifications.categories.insert(
  .init(identifier: "LIKE_CATEGORY",
        actions: [
          .init(identifier: "LIKE_IDENTIFIER", title: "Like", options: [.foreground]),
          .init(identifier: "UNLIKE_IDENTIFIER", title: "Unlike", options: [.foreground])
        ],
        intentIdentifiers: []
       )
)
UNUserNotificationCenter.current().setNotificationCategories(Braze.Notifications.categories)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
NSMutableSet<UNNotificationCategory *> *categories = [BRZNotifications.categories mutableCopy];

UNNotificationAction *likeAction = [UNNotificationAction actionWithIdentifier:@"LIKE_IDENTIFIER"
                                                                        title:@"Like"
                                                                      options:UNNotificationActionOptionForeground];

UNNotificationAction *unlikeAction = [UNNotificationAction actionWithIdentifier:@"UNLIKE_IDENTIFIER"
                                                                          title:@"Unlike"
                                                                        options:UNNotificationActionOptionForeground];

UNNotificationCategory *likeCategory = [UNNotificationCategory categoryWithIdentifier:@"LIKE_CATEGORY"
                                                                              actions:@[likeAction, unlikeAction]
                                                                    intentIdentifiers:@[]
                                                                              options:UNNotificationCategoryOptionNone];

[categories addObject:likeCategory];
[UNUserNotificationCenter.currentNotificationCenter setNotificationCategories:categories];

Step 2: Select your categories

After you register a category, use the Braze dashboard to send notifications of that type to users.

  1. In the Braze dashboard, select Messaging > Push Notifications, then choose your iOS push campaign.
  2. Under Compose push notification, turn on Action Buttons.
  3. In the iOS Notification Category dropdown, select Enter pre-registered custom iOS Category.
  4. Finally, enter one of the categories you created earlier. The following example, uses the custom category: LIKE_CATEGORY.

The push notification campaign dashboard with the setup for custom categories.

HOW HELPFUL WAS THIS PAGE?
New Stuff!