In-App Notification LifeCycle Callbacks

Callbacks

In order to use In-App notification callbacks, your application must define a class which implements the WEGInAppNotificationProtocol and set it as the notification callback delegate in the initialisation call to SDK with the appropriate API for the same.

@protocol WEGInAppNotificationProtocol <NSObject>
-(NSMutableDictionary*) notificationPrepared:(NSMutableDictionary*) inAppNotificationData 
                                  shouldStop:(BOOL*)stopRendering;

-(void) notificationShown:(NSMutableDictionary*) inAppNotificationData;

-(void) notification:(NSMutableDictionary*) inAppNotificationData 
   clickedWithAction:(NSString*) actionId;

-(void) notificationDismissed:(NSMutableDictionary*) inAppNotificationData;
@end

1. In-App Notification Prepared

-(NSMutableDictionary*) notificationPrepared:(NSMutableDictionary*) inAppNotificationData 
                                  shouldStop:(BOOL*)stopRendering;

This callback gets triggered before notification is shown. Assigning the value of stopRendering to YES (*shouldStop = YES) will not render the notification.

2. In-App Notification Shown

-(void) notificationShown:(NSMutableDictionary*) inAppNotificationData;

This callback gets triggered after the notification is shown.

3. In-App Notification Clicked

-(void) notification:(NSMutableDictionary*) inAppNotificationData 
   clickedWithAction:(NSString*) actionId;

This callback gets triggered when the user clicks the Call to Action button on the notification. The id of the button clicked is passed as the second parameter. The id of the buttons can be looked up in the inAppNotificationData dictionary.

4. In-App Notification Dismissed

-(void) notificationDismissed:(NSMutableDictionary*) inAppNotificationData;

This callback gets triggered when the user closes the notification.

Notification Callback Data (NSMutableDictionary* inAppNotificationData)

{
    "canClose": true,
    "layoutAttributes": {
        "posX": 0,
        "posY": 0,
        "TITLE_ALIGN": "CENTER",
        "image_url": "http://s3-ap-southeast-1.amazonaws.com/wk-test-static-files/76a9d10/a6b6e04d-43e9-4c09-b15f-8acffbcfcc1a.jpg",
        "TITLE_WRAP": false,
        "wvWidth": 100,
        "type": "BLOCKING",
        "wvHeight": 100,
        "fullScreen": false
    },
    "showTitle": true,
    "notificationEncId": "~13ssb59",
    "description": null,
    "canMinimize": true,
    "id": "173046a46",
    "isActive": true,
    "title": "My Title",
    "actions": [{
        "actionText": "Puma",
        "actionEId": "~64c71b",
        "actionTarget": "_top",
        "type": "DEEP_LINK",
        "actionLink": "webengage://com.webengage.inapptest/start_activity/com.webengage.inapptest.Activity1",
        "isPrime": true
    }],
    "config": {
        "titleColor": "#ffffff",
        "c2aBackgroundColor": "#411ad3",
        "c2aTextFont": "Open Sans",
        "titleFont": "Open Sans",
        "c2aTextColor": "#f7f2f2",
        "hideLogo": false
    },
    "direction": "ltr"
}

In-App Notification LifeCycle Callbacks