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’s default push categories: Accept/Decline
, Yes/No
, Confirm/Cancel
, and More
.
To enable these push action buttons, first register for Braze’s default push categories. Then, use the didReceive(_:completionHandler:)
delegate method to enable push action buttons.
If you want to create your own custom notification categories, see action button customization.
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
UNUserNotificationCenter.current().setNotificationCategories(Braze.Notifications.categories)
1
[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:BRZNotifications.categories];
Clicking on push action buttons with background activation mode will only dismiss the notification and not open the app. The next time the user opens the app, the button click analytics for these actions will be flushed to the server.
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 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. Once 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:
To register categories in your application, refer to the following code snippet:
When creating a UNNotificationAction
, you may specify a list of action options. For example, adding UNNotificationActionOptions.foreground
allows your users to open the app upon clicking the action button, which is necessary for Braze on-click behaviors that navigate into your app, such as “Open App” and “Deep Link into Application”.
Refer to UNNotificationActionOptions
for further usage details.
Once you register categories in your application, use the Braze dashboard to send notifications of that type to your users. Define your custom notification category in Compose step of the push composer.
- Make sure Action Buttons are turned on.
- For iOS Notification Category, select Enter pre-registered custom iOS Category.
- Enter the category you previously defined (for example
LIKE_CATEGORY
).