Set callback

Prev Next

You need to set Insider callbacks after the SDK initializes.

Method Signature

+(void)registerInsiderCallbackWithSelector:(SEL)selector sender:(id)sender;


// Callback Types
InsiderCallbackTypeNotificationOpen
InsiderCallbackTypeTempStoreCustomAction

Method Examples

-(void)insiderCallback:(NSDictionary *)dict {
    
    InsiderCallbackType type = (InsiderCallbackType)[[dict objectForKey:@"type"] intValue];
    
    switch (type) {
        case InsiderCallbackTypeNotificationOpen:
            [self showAlert:dict withTitle:@"InsiderCallbackTypeNotificationOpen"];
            NSLog(@"[INSIDER][CALLBACK][InsiderCallbackTypeNotificationOpen]: %@", dict);
            break;
        case InsiderCallbackTypeTempStoreCustomAction:
            [self showAlert:dict withTitle:@"InsiderCallbackTypeTempStoreCustomAction"];
            NSLog(@"[INSIDER][CALLBACK][InsiderCallbackTypeTempStoreCustomAction]: %@", dict);
            break;
        default:
            break;
    }
}
@objc func insiderCallbackHandler(info: [String : AnyObject]){
        let type = info["type"]?.intValue ?? -1
        switch type {
        case InsiderCallbackType.notificationOpen.rawValue:
            print(info)
            break
        case InsiderCallbackType.tempStoreCustomAction.rawValue:
            print(info)
            break
        default:
            print(info)
            break
        }
    }

Push Handling by App Owner on Foreground

When the app is on the foreground, Apple has 2 different behaviors on push notifications.

  • Not showing notification as a banner
  • Showing notification as a banner

If you do not set up any additional methods, Insider SDK prefers to not show the notification banner.

If you set up Foreground Push View, then the notification banner shows.

On the other hand, if the app owner wants to handle push notification preview by themselves, the below callback can be used.  With this callback method, the application can detect incoming notifications while in the foreground state, and Insider handles the push.

Your title goes here
Do not forget that "TriggerPushProcessWithUserInfo" is crucial for logs. If it is not used properly, Insider cannot handle the push and log-related data.

Method Signature

+(void)triggerPushProcessWithUserInfo:(NSDictionary *)userInfo;

Method Examples

static NSString *APP_GROUP = @"group.com.company.product";
static NSString *INSIDER_PARTNER_NAME = @"your_partner_name";

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    UNUserNotificationCenter.currentNotificationCenter.delegate = self;
   
    [Insider initWithLaunchOptions:launchOptions partnerName:INSIDER_PARTNER_NAME appGroup:APP_GROUP];
    [Insider setForegroundPushCallback:@selector(setForegroundPushCallback:) sender:self];
    
    return true;
}

-(void)setForegroundPushCallback:(UNNotification *) notification {
    [Insider triggerPushProcessWithUserInfo:notification.request.content.userInfo];
}
let appGroup = "group.com.company.product"

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    Insider.initWithLaunchOptions(launchOptions, partnerName: "your_partner_name", appGroup: appGroup)
    Insider.setForegroundPushCallback(#selector(setForegroundPushCallback), sender: self)

    return true
}

@objc func setForegroundPushCallback(notification: UNNotification) {
    Insider.triggerPushProcess(userInfo: notification.request.content.userInfo)
}

Insider callbacks, also known as "call-after" functions, help you retrieve useful data when necessary. 

For example, let's take a look at the NotificationOpen callback. Say you have a push notification without a deep link. In this case, no callback will be fired. If you have a push notification with a key-value pair deep link, the NotificationOpen callback will be fired once you open the push notification.

The following are sample logs for different deep link types in app pushes and templates:

Key-Value Pair (Push)

[INSIDER][insiderCallbackTriggered]      I Callback Type: NOTIFICATION_OPEN, Data:{

  "type": 0,

  "data": {

    "received_at": "1748433708",

    "collapse_id": "0_70815_1748433707",

    "source": "Insider",

    "camp_type": "0",

    "key": "value",

    "sound": "Default",

    "camp_id": "70815",

    "isSetPush": true,

    "variant_id": "89159",

    "sent_at": "1748433707"

  }

}

Key-Value Pair (Message Action Button)

[INSIDER][insiderCallbackTriggered]     Callback Type: NOTIFICATION_OPEN
{

   "type": 0,

       "data": {

   "buttonId": 0,

           "source": "Insider",

           "key": "value",

           "buttonText": "key value pair button1"

}

}

Internal URL (Push)

[INSIDER][insiderCallbackTriggered]     I Callback Type: NOTIFICATION_OPEN, Data:{

  "type": 0,

  "data": {

    "received_at": "1748433708",

    "collapse_id": "0_70815_1748433707",

    "source": "Insider",

    "camp_type": "0",

    "ins_dl_internal": "https://www.test.com",

    "sound": "Default",

    "camp_id": "70815",

    "isSetPush": true,

    "variant_id": "89159",

    "sent_at": "1748433707"

  }

}

Internal URL (Message Action Button)

[INSIDER][insiderCallbackTriggered]     Callback Type: NOTIFICATION_OPEN

{

   "type": 0,

       "data": {

   "buttonId": 0,

           "source": "Insider",

           "buttonText": "test internal",

           "ins_dl_internal": "https://www.test.com"

}

}

External URL (Push)

[INSIDER][insiderCallbackTriggered]     I Callback Type: NOTIFICATION_OPEN, Data:{

  "type": 0,

  "data": {

    "received_at": "1748433708",

    "collapse_id": "0_70815_1748433707",

    "source": "Insider",

    "camp_type": "0",

    "ins_dl_external": "https://www.test.com",

    "sound": "Default",

    "camp_id": "70815",

    "isSetPush": true,

    "variant_id": "89159",

    "sent_at": "1748433707"

  }

}

External URL (Message Action Button)

[INSIDER][insiderCallbackTriggered]     Callback Type: NOTIFICATION_OPEN

{

   "type": 0,

       "data": {

   "ins_dl_external": "https://www.test.com",

           "buttonId": 0,

           "source": "Insider",

           "buttonText": "test external"

}

}

JSON (Push)

[INSIDER][insiderCallbackTriggered]     I Callback Type: NOTIFICATION_OPEN, Data:{

  "type": 0,

  "data": {

    "received_at": "1748433708",

    "collapse_id": "0_70815_1748433707",

    "source": "Insider",

    "camp_type": "0",

    "ins_dl_json": '{"test":"test2"}',

    "sound": "Default",

    "camp_id": "70815",

    "isSetPush": true,

    "variant_id": "89159",

    "sent_at": "1748433707"

  }

}

JSON (Message Action Button)

[INSIDER][insiderCallbackTriggered]     Callback Type: NOTIFICATION_OPEN

{

   "type": 0,

       "data": {

   "buttonId": 0,

           "source": "Insider",

           "buttonText": "test json",

           "ins_dl_json": '{"test":"test2"}'

}

}

URL Scheme (Push)

[INSIDER][insiderCallbackTriggered]     I Callback Type: NOTIFICATION_OPEN, Data:{

  "type": 0,

  "data": {

    "received_at": "1748433708",

    "collapse_id": "0_70815_1748433707",

    "source": "Insider",

    "camp_type": "0",

    "ins_dl_url_scheme": "test",

    "sound": "Default",

    "camp_id": "70815",

    "isSetPush": true,

    "variant_id": "89159",

    "sent_at": "1748433707"

  }

}

URL Scheme (Message Action Button)

[INSIDER][insiderCallbackTriggered]     Callback Type: NOTIFICATION_OPEN

{

   "type": 0,

       "data": {

   "buttonId": 0,

           "source": "Insider",

           "buttonText": "test url scheme",

           "ins_dl_url_scheme": 'test'

}

}

URL Scheme (App template)

[INSIDER][DEBUG][processTemplateStoreURL]: {

    action = deepLink;

    dismiss = 12;

    redirection = "https://academy.useinsider.com";

}

JSON (App template)

[INSIDER][DEBUG][processTemplateStoreURL]: {

    action = deepLink;

    custom =     {

        json = "{\"insider_key\": \"insider_value\"}";

    };

    dismiss = 12;

}