Skip to content

Interactive notifications

Alexander Boldyrev edited this page Oct 31, 2024 · 3 revisions

Interactive notifications are push notifications that provide an option for end user to interact with application through button tap action. This interaction can be accomplished by using Mobile Messaging SDK predefined interactive notification categories or creating your own.

Tapping the action should trigger actionTapped event where you can act upon the received action identifier.

Predefined categories

Mobile Messaging SDK provides only one predefined interaction category for now, but this list will be extended in future.

Interactive notifications can be tested through our Single PUSH message and Multiple PUSH messages APIs by using category parameter.

A = action

Category.id A.id A.title A.foreground A.authenticationRequired A.destructive A.moRequired
mm_accept_decline mm_accept Accept true true false true
mm_decline Decline false true true true

Custom categories

Interactive notifications should be registered at the SDK initialization step by providing notificationCategories configuration:

mobileMessaging.init({
        applicationCode: ...,
        android: ...,
        ios: ...,
        notificationCategories: [{ // a list of custom interactive notification categories that your application has to support
            identifier: <String; a unique category string identifier>,
            actions: [ // a list of actions that a custom interactive notification category may consist of
                {
                    identifier: <String; a unique action identifier>,
                    title: <String; an action title, represents a notification action button label>,
                    foreground: <Boolean; to bring the app to foreground or leave it in background state (or not)>,
                    textInputPlaceholder: <String; custom input field placeholder>,
                    moRequired: <Boolean; to trigger MO message sending (or not)>,
                    
                    // iOS only
                    authenticationRequired: <Boolean; to require device to be unlocked before performing (or not)>,
                    destructive: <Boolean; to be marked as destructive (or not)>,
                    textInputActionButtonTitle: <String; custom label for a sending button>,
                    
                    // Android only
                    icon: <String; a resource name for a special action icon>
                }
                ...
            ]
        }]
    },
    () => {
        console.log('MobileMessaging started');
    },
    error => {
        console.log('Init error', JSON.stringify(error));
    },
);
...
Clone this wiki locally