In-App NATIV (Below SDK version 6.0.0)

In-App Messaging are custom views which you can send to a segment of users to show custom messages or give new offers or take to some specific pages. They can be created from your MoEngage account.



SDK Version

Follow this doc only if you are using MoEngage-iOS-SDK version below 6.0.0. If you are using version 6.0.0 or above then follow the doc in this link.

How to show In-App Message?

To use In-app Messaging, add the code below to the view controller(s) in which you want to show the In-app.

Swift Objective-C
MoEngage.sharedInstance().delegate = self

To handle the button action for In-App, confirm your view controller to MOInAppDelegate (optional). The method will provide the data which will help you to navigate screens or take appropriate actions.

Swift Objective-C
//This delegate will be called when an In-App is shown. You can use this to ensure not showing alerts or pop ups of your own at the same time.
func inAppShown(withCampaignID campaignID: String!) {

// The enum InAppWidget is for the different types of widgets which can be clicked in the In-App.
func inAppClicked(for widget: InAppWidget, screenName: String!, andDataDict dataDict: [AnyHashable : Any]!) {



Nudges are banner like views. They can be embedded in the current view or floated over the existing view. There are two options using which you can show the nudges.

  • First option, you can get the nudge and show it yourself .To get a nudge view, use the following code:
Swift Objective-C
// Get the nudge view using the method: 
MoEngage.sharedInstance().getNudgeViewWithCompletionBlock { (nudgeView: UIView!, campaignId: String!) in
	//If it exists, decide the frame where you wish to show it. Once you have the frame and the view, add it to self.view. 
	if((nudgeView) != nil){
		nudgeView.frame = CGRectMake(0, 64, nudgeView.frame.size.width, nudgeView.frame.size.height)
		self.view .addSubview(nudgeView)
		// Don't forget to call this method. This method tells us that the nudge view is shown to the end user.
  • Second option, you can let the SDK show the nudges. In this case, SDK can show Nudges in two positions (i.e, at top or bottom of the screen). Use the following code in the view controller(s) where you want SDK to show the nudges :
Swift Objective-C
//For showing nudges at Top of the screen


//For showing nudges at Bottom of the screen

Disable In-Apps in ViewController

If you don't want to show in app messages in a particular ViewController, use dontShowInAppInViewController: method as shown below:

Swift Objective-C
//For not showing in apps in viewController

Disabling In-Apps for App

If you do not wish to use in app messaging, set the property disableInApps. The property has to be set before the initialize call.

Swift Objective-C
MoEngage.sharedInstance().disableInApps = true

Self handled In-Apps

Self handled In-Apps are not shown by the SDK. While creating the campaign, a json payload has to be provided. The same payload will be provided in case of General InApp Campaign by the SDK on calling getSelfHandledInApp method.

Swift Objective-C
// Call this method to get the self handled in-app. This will return the json payload as NSDictionary


Self-handled InApp payload will be provided, only when In-App Messaging Rules are satisfied. If not then this method return's nil.

Getting Self Handled InApp payload in case of Smart Trigger:

For getting the Self Handled InApp payload in case of Smart Trigger, use the eventTriggeredInAppAvailableWithData: delegate method :

Swift Objective-C
 This method is called when an event triggers an in-app from the server, which is of type self handled. 
func eventTriggeredInAppAvailable(withData data: Any!) {

Tracking InApp Shown And Clicked:

For tracking In-App shown for self handled in-apps use selfHandledInAppViewShownWithCampaignID: method and provide campaign ID as parameter.

Swift Objective-C
// Call this method when you show the self handled in-app so we can update impressions. Pass the campaign id of the campaign shown.

For tracking InApp Clicked information for stats, call the following methods :

Swift Objective-C
// Call this method to track if self handled in app Primary widget is clicked.

// Call this method to track if self handled in app widget(other than Primary Widget) is clicked.

// Call this method to track dismiss actions on the inApp.

Update Delay between In-Apps

You can also change the minimum time delay between two in-apps. By default it is 15 mins.
Go to Settings in the MoEngage dashboard. Go to In-App NATIV Settings Menu.

There's a field Delay between InApp:. Change that to the desired delay.


In-App Messaging Rules

We use the following rules while showing the In-App:

Rule 1: We check for the global delay between inApps . This comes as a property from the server, and configurable under Settings > InApp Nativ in the MoEngage dashboard (The default is set to 15 mins). If min delay has crossed go to the next step, else return. This rule is not applicable on Nudges.

Rule 2: Next we check if the InApp has expired or not. If it has not, then proceed to next rule else discard this inApp and check for other active InApp campaign.

Rule 3: Next we check the campaign level delay. If the delay (interval) between showing the same in-app has passed, go to the next rule. If not, then repeat from Step 2 for the next active InApp campaign.

Rule 4: Then we check if the in-app is already been clicked. —> Check if it’s a persistent in-app, if yes, continue to Rule 5, if not, check if Primary Widget is already clicked. If already clicked, repeat from Step 2 for the next active InApp campaign.

Rule 5: At last we check for max no. of times inApp can be shown. If max no. of times is not reached show the inApp, or else repeat from Step 2 for the next active InApp campaign.




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