You need to set Insider callbacks after the SDK initializes.
Method Signature
// You set the callbacks when you init the Insider SDK.
// Callback Types
static const int NOTIFICATION_OPEN = 0;
static const int TEMP_STORE_CUSTOM_ACTION = 4;Method Example
await FlutterInsider.Instance.init(
"your_partner_name", "group.com.useinsider.InsiderDemo",
(int type, dynamic data) {
switch (type) {
case InsiderCallbackAction.NOTIFICATION_OPEN:
print("[INSIDER][NOTIFICATION_OPEN]: " + data.toString());
setState(() {
_callbackData = data.toString();
});
break;
case InsiderCallbackAction.TEMP_STORE_CUSTOM_ACTION:
print("[INSIDER][TEMP_STORE_CUSTOM_ACTION]: " + data.toString());
setState(() {
_callbackData = data.toString();
});
break;
default:
print("[INSIDER][InsiderCallbackAction]: Unregistered Action!");
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.
Method Signature
Future setForegroundPushCallback(Function callback) asyncMethod Example
FlutterInsider.Instance.setForegroundPushCallback((userInfo) {
/* You should use the following method to process the userInfo value returned
for the push in the foreground state, by the Insider.
Otherwise, push will not be handled/process by Insider. */
FlutterInsider.Instance.handleNotification(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'
}
}
Key-Value Pair (App template)
[INSIDER][CALLBACK][InsiderCallbackTypeTempStoreCustomAction]: {
data = {
InsiderDeepLinkKey = InsiderDeepLinkValue;
};
type = 4;
}
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;
}