
SDK Installation
Install using Swift Package Manager
MoEngageInApp is supported through SPM from SDK version 3.2.0. To integrate, use the GitHub url https://github.com/moengage/apple-sdk.git for SDK versions equal and above 9.23.0, or https://github.com/moengage/MoEngage-iOS-SDK.git for other SDK versions link and set the branch as master or the required version.Install using CocoaPod
InformationCocoaPods is being deprecated. MoEngage recommends using Swift Package Manager for all new integrations. For more info on CocoaPods, refer to CocoaPods Integration Guide.
pod install to install the framework.
Manual Integration
Manual Integration:To integrate the
MoEngageInApp SDK manually to your project follow this doc.How to show In-App Message?
To use In-app Messaging, importMoEngageInApps and then add the code below to the view controller(s) in which you want to show the In-app.
Non Intrusive Nudges

InApp Callbacks
To observe callbacks whenever an inApp is shown, dismissed, or clicked implement MoEngageInAppNativeDelegate. Set the delegate using the below methods.Context-Based InApps
We have introduced context-based InApps with SDK version 6.0.0. While creating InApp campaigns you can set the contexts OR tags to the campaign. SDK will check with the current context set in the App and show the inApp only when a current set context matches the campaign context.Set Current Context:
To set the current context for the InApp module use setCurrentInAppContexts(_): as shown below:Reset Context:
To reset the current context for the InApp module call invalidateInAppContexts() method:Disable In-Apps in ViewController
If you don’t want to show InApp messages in a particular ViewController, use blockInApp(forViewController:) method as shown below:Disabling In-Apps for App
If you do not wish to use InApp messaging, set the property disableInApps. The property has to be set before the initial call.Self handled In-Apps
Self handled In-Apps are not shown by the SDK. While creating the campaign, a String payload has to be provided. The same payload will be provided to the application on campaign delivery. InApp Campaigns that have trigger condition as Screen launch can be fetched using getSelfHandledInApp(completionBlock:).NoteThe above method will also be called when trying to test the self-handled campaign through a test campaign.
Self handled multiple In-Apps
Starting with MoEngage-iOS-SDK 9.19.0 version, MoEngage InApp SDK supports displaying Multiple Self Handled InApps. To get multiple self handled inApps for multiple contexts set by the user, use sdk’s getSelfHandledInApps(completionBlock:).Campaign Selection Logic
- Default Limit: By default, only 5 campaigns will be fetched.
- Priority-Based Selection: Campaigns are delivered based on their priority and last updated time. It checks for priority first and then checks the last updated time on conflicting priorities
- Exclusion criteria: Campaigns are only excluded based on specific rules like frequency capping, eligibility criteria, campaign status, or priority limits.
- Context 1: Campaign 1 (P0, T2), Campaign 2 (P1, T3), Campaign 3 (P2, T6)
- Context 2: Campaign 4 (P0, T1), Campaign 5 (P1, T5)
- Context 3: Campaign 6 (P0, T4)
- Filter campaigns by user eligibility and targeting criteria
- Sort by campaign priority (P0, P1, P2, etc.)
- For campaigns with same priority, sort by most recent update timestamp
- Return top 5 campaigns
Best Practices for Campaign Organization for multiple self handled campaigns
For optimal performance across multiple contexts on a single page, organize your campaigns like this:- Context 1 (Homepage): Campaign A (P0), Campaign B (P1)
- Context 2 (Product): Campaign C (P0), Campaign D (P1)
- Context 3 (Checkout): Campaign E (P0)
Tracking Self Handled Multiple InApps
The getSelfHandledInApps(completionBlock:) method returns MoEngageInAppSelfHandledData, which contains a list of MoEngageInAppSelfHandledCampaign objects. The statistics for each MoEngageInAppSelfHandledCampaign object must be tracked individually below APIs.Fetching Contextual Multiple Self-Handled InApps
To fetch contextual multiple self-handled inapps, set the inapp contexts using setCurrentInAppContexts() before calling getSelfHandledInApps(completionBlock:). This will return a list of contextual and non-contextual inapps(in the order of campaign priority set at the time of campaign creation).Tracking InApp Shown And Clicked:
For tracking In-App shown for self-handled in-apps use the selfHandledShown(campaignInfo:) and provide campaign instance as a parameter:In-App Messaging Rules
We use the following rules while showing the In-App: Preconditions for inApp to work:- If InApp Backend Sync was successful in the current session or not.
- Check if InApp is disabled on the current screen.
- Check Global Delay has lapsed, skip this if Ignore Global Delay set for the campaign.
- Check if the campaign has expired
- Display Rules
- Check Show Only on Screen
- Check with current contexts
- Delivery Controls
- Persistence Check(If primary action of InApp is done but still want to show the inApp)
- Check if the campaign has been shown the maximum number of times.
- Check if the campaign level delay has crossed.
- Check Device Orientation is Portrait for Native InApp and required Orientation for HTML InApp(as selected during campaign creation).