Skill Level: Intermediate
This article provides notification service dynamic action categories and static action categories information.
Not what youâ€™re looking for? Check out all our available tutorials for mobile app messaging here.
Notification Service Dynamic Action Categories
In iOS 10, Apple introduced the notification service extension that allows applications to intercept and pre-process remote notifications before they are presented to the user.
For information about media attachments and dynamic action categories, see Enabling media attachment and multiple action support.
Dynamic action categories are sets of actions in mobile app messages that are dynamically generated by the SDK in real time when a special payload is received, if the device is running iOS 10 (or later). Dynamic action categories are not predefined in the application binary.
Note: Dynamic action categories are not supported in Xamarin for iOS.
Developers define actions for dynamic action categories in the â€ścategory-actionsâ€ť section of the payload. The payload includes the category-actions key, as well as a mutable-content flag in the normal aps payload. It can also include a category-name key if the name of the dynamic category must match a specific identifier. The category-name key is sometimes used for dynamic notification presentation.
- The mutable-content flag allows the applicationâ€™s notification service to process the push message before it is delivered to the user.
- The category-actions key includes a list of action buttons that are assigned to a temporary category at run time.
- The aps key includes the text, sound, and badge of the notification.
- After the temporary category is created, the SDK assigns the category name to the notification and passes the category name to the operating system so that it can be displayed to the user.
- The category-name key overrides the random category name that is generated by the SDK with a category name that you specify. Add this key to your payload when you want to use iOS 10 (and later) features that require a predefined category name.
Tip: Always include a notification-action value so a default action can be executed when the notification is opened. Category actions only open if a user expands the push message and selects an alternative action button.
Static action categories
Because all application delegate methods are forwarded to your defined appDelegateClass, you can implement any standard application delegate methods, including handling static action categories, in any way you want.Â Static action categories are compiled into the app binary itself. They are sets of predefined buttons that have predefined actions behind them. Those are entirely implemented by the developer and do not interact with the SDK at all.
Note: Static action categories are not supported in Xamarin for iOS.
If you are using simple notifications and want to create static action categories with background actions, you must turn on Remote notifications in your XCode project. Go to the Background Modes section of the Capabilities tab for your target, and select Remote notifications.
- Implement the standard method for handling the category callbacks in your AppDelegate class.
- Register the categories that you want to handle in the APNS registration call in your AppDelegate.
Need more help? Check out all of our available tutorials for mobile app messaging here.