Actionable Notifications

Actionable notifications let you add custom action buttons to the standard iOS push notifications. It also gives the user a quick and easy way to perform relevant tasks in response to a notification. 

How to implement Actionable Notifications?

To use actionable notifications with MoEngage SDK, you have to define the actions and group them into categories as shown in the example, and pass them as a parameter while registering for push notifications.

Swift Objective-C
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate{

    var window: UIWindow?
    

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        //--- Rest of Implementation
      
        //For registering for remote notification
        let categories = self.getCategories()
        MoEngageSDKMessaging.sharedInstance.registerForRemoteNotification(withCategories: categories, andUserNotificationCenterDelegate: appDelegate)
        
        //--- Rest of Implementation
        
        return true
    }
    
    //Example to define categories
    //This method gives categories
    func getCategories() -> Set<UNNotificationCategory>{
        
        let acceptAction = UNNotificationAction.init(identifier: "ACCEPT_IDENTIFIER", title: "Accept", options: .authenticationRequired)
        let declineAction = UNNotificationAction.init(identifier: "DECLINE_IDENTIFIER", title: "Decline", options: .destructive)
        let maybeAction = UNNotificationAction.init(identifier: "MAYBE_IDENTIFIER", title: "May Be", options: .foreground)
        
        let inviteCategory = UNNotificationCategory.init(identifier: "INVITE_CATEGORY", actions: [acceptAction,declineAction,maybeAction], intentIdentifiers: [], options: .customDismissAction)
        let categoriesSet = Set.init([inviteCategory])
        
        return categoriesSet;
    }
}

As you can see in the example Accept, Decline, and May Be actions are grouped to a category i.e,"INVITE_CATEGORY".

info

Notification Categories

MoEngage recommended not to change the actions grouped in a category across the app versions, as it will lead to users seeing different actions for the same category across different app versions.

Previous

Next

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?