In-app message is a banner that can be displayed when your app is running. It may have various layout variants, because it is fully customizable by HTML. The campaign is triggered and displayed depending on the configuration settings.
WARNING: Due to operating system differences and web engines, in-app message appearance may differ between systems or not be as expected. You should test your in-app messages.
Note: In-app messages respect safe area on iOS and display cutouts on Android.
Requirements
Recommended Mobile SDK version:
Android - 5.3.0 or newer
iOS - 4.12.0 or newer
React Native - 0.12.0 or newer
Flutter - 0.5.0 or newer
If your in-app content (such as JavaScript, CSS, images, or fonts) is being loaded from your own server via HTTP and you have configured CORS policies, you need to set the contentBaseUrl to your server’s address. For example, if you’re loading resources from https://www.synerise.com/example/font.woff, you should configure contentBaseUrl to https://www.synerise.com (check this option in the Settings).
Enable the IN_APP_DEFINITIONS_COMMUNICATION_READ (Communication) permission in the Profile (formerly Client) API key used by the mobile application so the mobile application can fetch in-app messages.
Configuration
In-app message campaigns are served by the Synerise backend.
Check possible available configuration options in the Settings.
Events generated by in-app messaging
For information about events generated by in-app messaging, see the event reference.
Setting up a global control group for in-app message
For information about global control groups in in-app messages, see the global control group article.
Handling actions from in-app messages
Handling main actions from campaigns depends on the campaign type and operating system and it is described here.
Controlling behavior and actions
You may control an incoming in-app message and decide whether to show it (the display of in-app message can be triggered by occurrence of specific events). By default, the SDK allows in-app message display.
The user interface allows selecting up to 3 trigger events, however, in Android, only for 5.8.1 SDK version (released on 28.08.2023) or higher all triggers are considered altogether. For older SDK versions in Android, only the last event from the trigger list will be considered.
These limitations don’t apply in iOS.
Also, you can be notified (in the form of events) about the campaign actions in the following cases:
When the in-app message is presented.
When the in-app message disappeared.
When additional context is needed to render the campaign.
publicstaticOnInAppListenerNULL=newOnInAppListener(){// This method is called after an in-app message is loaded and Synerise SDK asks for permission to show it.
@OverridepublicbooleanshouldShow(InAppMessageDatainAppMessageData){returntrue;}// This method is called after an in-app message appears.
@OverridepublicvoidonShown(InAppMessageDatainAppMessageData){//...
}// This method is called after an in-app message disappears.
@OverridepublicvoidonDismissed(InAppMessageDatainAppMessageData){//...
}// This method is called when a individual context for an in-app message is needed.
@OverridepublicHashMap<String,Object>onContextFromAppRequired(InAppMessageDatainAppMessageData){returnnewHashMap<>();}// This method is called when the SRInApp.openUrl(url) method is used in an in-app message.
@OverridepublicvoidonHandledOpenUrl(InAppMessageDatainAppMessageData){//...
}// This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.
@OverridepublicvoidonHandledOpenDeepLink(InAppMessageDatainAppMessageData){//...
}// This method is called when the
// SRInApp.handleCustomAction(name, params) method is used in an in-app message.
@OverridepublicvoidonCustomAction(Stringidentifier,HashMap<String,Object>params,InAppMessageDatainAppMessageData){//...
}};
varinAppCallbacks:OnInAppListener=object: OnInAppListener(){// This method is called after an in-app message is loaded and Synerise SDK asks for permission to show it.
overridefunshouldShow(inAppMessageData:InAppMessageData):Boolean{returntrue}// This method is called after an in-app message appears.
overridefunonShown(inAppMessageData:InAppMessageData){//...
}// This method is called after an in-app message disappears.
overridefunonDismissed(inAppMessageData:InAppMessageData){//...
}// This method is called when a individual context for an in-app message is needed.
overridefunonContextFromAppRequired(inAppMessageData:InAppMessageData):HashMap<String,Any>{returnHashMap()}// This method is called when the SRInApp.openUrl(url) method is used in an in-app message.
overridefunonHandledOpenUrl(inAppMessageData:InAppMessageData){//...
}// This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.
overridefunonHandledOpenDeepLink(inAppMessageData:InAppMessageData){//...
}// This method is called when the
// SRInApp.handleCustomAction(name, params) method is used in an in-app message.
overridefunonCustomAction(identifier:String?,params:HashMap<String?,Any?>?,inAppMessageData:InAppMessageData?){//...
}}
// MARK: - InjectorInAppMessageDelegate// This method is called after an in-app message is loaded and Synerise SDK asks for permission to show it.funcsnr_shouldInAppMessageAppear(data:InAppMessageData)->Bool{returntrue}// This method is called after an in-app message appears.funcsnr_inAppMessageDidAppear(data:InAppMessageData){//...}// This method is called after an in-app message disappears.funcsnr_inAppMessageDidDisappear(data:InAppMessageData){//...}// This method is called when an in-app message changes size.funcsnr_inAppMessageDidChangeSize(rect:CGRect){//...}// This method is called when a individual context for an in-app message is needed.funcsnr_inAppMessageContextIsNeeded(data:InAppMessageData)->[AnyHashable:Any]?{return[]}// This method is called when the SRInApp.openUrl(url) method is used in an in-app message.funcsnr_inAppMessageHandledAction(data:InAppMessageData,url:URL){//...}// This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.funcsnr_inAppMessageHandledAction(data:InAppMessageData,deeplink:String){//...}// This method is called when the// SRInApp.handleCustomAction(name, params) method is used in an in-app message.funcsnr_inAppMessageHandledCustomAction(data:InAppMessageData,name:String,parameters:[AnyHashable:Any]){//...}
#pragma mark - SNRInjectorInAppMessageDelegate
// This method is called after an in-app message is loaded and Synerise SDK asks for permission to show it.
-(BOOL)SNR_shouldInAppMessageAppear:(SNRInAppMessageData*)data{//...
}// This method is called after an in-app message appears.
-(void)SNR_inAppMessageDidAppear:(SNRInAppMessageData*)data{//...
}// This method is called after an in-app message disappears.
-(void)SNR_inAppMessageDidDisappear:(SNRInAppMessageData*)data{//...
}// This method is called when an in-app message changes size.
-(void)SNR_inAppMessageDidChangeSize:(CGRect)rect{//...
}// This method is called when a individual context for an in-app message is needed.
-(nullableNSDictionary*)SNR_inAppMessageContextIsNeeded:(SNRInAppMessageData*)data{//...
}// This method is called when the SRInApp.openUrl(url) method is used in an in-app message.
-(void)SNR_inAppMessageHandledURLAction:(SNRInAppMessageData*)dataurl:(NSURL*)url{//...
}// This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.
-(void)SNR_inAppMessageHandledDeeplinkAction:(SNRInAppMessageData*)datadeeplink:(NSString*)deeplink{//...
}// This method is called when the
// SRInApp.handleCustomAction(name, params) method is used in an in-app message.
-(void)SNR_inAppMessageHandledCustomAction:(SNRInAppMessageData*)dataname:(NSString*)nameparameters:(NSDictionary*)parameters{//...
}
Synerise.onReady(function(){Synerise.Injector.setInAppMessageListener({// This method is called after an in-app message is loaded and Synerise SDK asks for permission to show it.
shouldPresent:function(data){returntrue;},// This method is called after an in-app message appears.
onPresent:function(data){//...
},// This method is called after an in-app message disappears.
onHide:function(data){//...
},// This method is called when a individual context for an in-app message is needed.
contextIsNeeded:function(data){return{}},// This method is called when the SRInApp.openUrl(url) method is used in an in-app message.
onOpenUrl:function(data,url){//...
},// This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.
onDeepLink:function(data,deepLink){//...
},// This method is called when Synerise handles custom action from in-app messages.
onCustomAction:function(data,name,parameters){//...
}});})
Synerise.injector.inAppMessageListener((listener){// This method is called after an in-app message appears.
listener.onPresent=(data){//...
};// This method is called after an in-app message disappears.
listener.onHide=(data){//...
};// This method is called when the SRInApp.openUrl(url) method is used in an in-app message.
listener.onOpenUrl=(data,url){//...
};// This method is called when the SRInApp.openDeeplink(url) method is used in an in-app message.
listener.onDeepLink=(data,deepLink){//...
};// This method is called when Synerise handles custom action from in-app messages.
listener.onCustomAction(data,name,parameters){//...
};});
Example
This is an in-app message campaign example with full screen presentation.
Did this article answer your question?
😕
We are sorry to hear that
Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.
😉
Awesome!
Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.