iOS Notifications

Adding custom notification categories for iOS

Interactive Notifications

Standard Interactive Notifications

Airship provides a set of standard Interactive Notification types (See: Built-In Interactive Notification Types). It is the type that determines which buttons and corresponding labels will be available when you send a push. See the next section for where to specify that in the push payload. You control what happens when you send the push separately, by tying each button ID to a specific action.

Custom Interactive Notification Types (Categories)

In order to define a custom Interactive Notification type, you must register a new category.

 Note

Airship reserves category IDs prefixed with ua_. Any custom categories with that prefix will be dropped.

You can use the hiddenPreviewsBodyPlaceholder argument to specify placeholder text which will be shown instead of the push notification’s body when the user has disabled notification previews for the app.

Custom categories are supported by setting the set of categories on AirshipBasePushProtocol customCategories .

Categories can be set after takeOff.

Setting Custom Categories

// Define an action for the category
let categoryAction = UNNotificationAction(identifier: "category_action",
                                               title: "Action!",
                                             options: [.authenticationRequired, .foreground, .destructive])

// Define the category
let category = UNNotificationCategory(identifier: "custom_category",
                                         actions: [categoryAction],
                               intentIdentifiers: [],
                   hiddenPreviewsBodyPlaceholder: "Sensitive Content Hidden",
                                         options: [])

// Set the custom categories
Airship.push.customCategories = [category]
// Define an action for the category
UNNotificationAction *categoryAction = [UNNotificationAction actionWithIdentifier: @"category_action"
                                                                            title:@"Action!"
                                                                          options:(UNNotificationActionOptionForeground |
                                                                                  UNNotificationActionOptionDestructive |
                                                                                  UNNotificationActionOptionAuthenticationRequired)];

// Define the category
UNNotificationCategory *category = [UNNotificationCategory categoryWithIdentifier:@"custom_category"
                                                                          actions:@[categoryAction]
                                                                intentIdentifiers:@[]
                                                                          options:UNNotificationCategoryOptionNone];

// Set the custom categories
UAirship.push.customCategories = [NSSet setWithArray:@[category]];