Integrate the mParticle iOS SDK before starting with MoEngage Kit Integration. Refer to the developer documentation and Kit integration documentation for more information. Skip this step if mParticle iOS SDK is already integrated into the application.
MoEngage Kit Integration
SDK Installation
Installing using SPM
- Navigate to Project's settings -> Package Dependencies -> Add Package
- Enter the URL https://github.com/moengage/mparticle-apple-integration-moengage.git and select the branch as master or required version to install the package.
- Click on Add Package.
- Select mParticle-MoEngage product for your app target.
Installing using CocoaPods
Add the kit dependency to your app's Podfile as shown below:
pod 'mParticle-MoEngage','~> 1.0.0'
Configure MoEngage SDK
- Disable MoEngageSDK method swizzling by setting MoEngageAppDelegateProxyEnabled as false/NO in app's Info.plist.
- Get Workspace ID (earlier App ID) from the Settings Page Dashboard --> Settings --> Account --> General and configure the MoEngage SDK in the AppDelegate's didFinishLaunchingWithOptions callback before initializing the mParticle Kit.
import MoEngageSDK
import mParticle_Apple_SDK
import mParticle_MoEngage
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Add your MoEngage Workspace ID and Data center.
let sdkConfig = MoEngageSDKConfig(appId: "YOUR WorkspaceID", dataCenter: DATA_CENTER)
// MoEngage SDK configuration
MoEngageConfigurator.configureDefaultInstance(sdkConfig: sdkConfig)
// Initialize mParticle
let mParticleOptions = MParticleOptions(key: "YOU MPARTICLE API KEY", secret: "YOUR MPARTICLE API SECRET")
MParticle.sharedInstance().start(with: mParticleOptions)
// Rest of the implementation of method
//-------
return true
}
@import MoEngageSDK;
@import mParticle_Apple_SDK;
@import mParticle_MoEngage;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Add your MoEngage Workspace ID and Data center.
MoEngageSDKConfig* sdkConfig = [[MoEngageSDKConfig alloc] initWithAppId:@"YOUR Workspace ID" dataCenter: DATA_CENTER];
// MoEngage SDK configuration
[MoEngageConfigurator configureDefaultInstanceWithSdkConfig:sdkConfig];
// Initialize mParticle
MParticleOptions* mParticleOptions = [MParticleOptions optionsWithKey:@"YOU MPARTICLE API KEY" secret:@"YOUR MPARTICLE API SECRET"];
[[MParticle sharedInstance] startWithOptions:mParticleOptions];
//Rest of the implementation of method
//-------
}
Install / Update Differentiation :
Since you might integrate us when your app is already on the App Store, we would need to know whether your app update would be an actual UPDATE or an INSTALL.
To differentiate between those, use one of the methods below:
//For Fresh Install of App
MoEngageSDKAnalytics.sharedInstance.appStatus(.install)
// For Existing user who has updated the app
MoEngageSDKAnalytics.sharedInstance.appStatus(.update)
//For Fresh Install of App
[[MoEngageSDKAnalytics sharedInstance]appStatus:MoEngageAppStatusInstall];
// For Existing user who has updated the app
[[MoEngageSDKAnalytics sharedInstance]appStatus:MoEngageAppStatusUpdate];
For more info on this refer to the following link.
Handling Push Notifications
Configuring with mParticle SDK
mParticle SDK provides a way to handle the registration of push token and receive push notifications at the mParticle SDK. Refer Push integration doc for the configuration option.
Configuring with MoEngage SDK or with Application
Check the MoEngage Push integration doc to configure with MoEngage SDK or if you want to handle it independently.
For more information on features provided in MoEngage iOS SDK refer to the following links:
mParticle SDK Usage
Refer to the developer documentation for detailed usage.
User Management
Check IDSync documentation from the mParticle developer integration document to manage the user state in the application.
Event Tracking
Use logEvent to track the custom and commerce events from mParticle SDK. mParticle SDK will send the event to MoEngage Kit (if configured from mParticle Dashboard) with associated profiles.
User Attribute Tracking
mParticle SDK provides setUserAttributeList to set the user attributes. Either you can set the mParticle standard attributes or custom attributes both are passed to MoEngage Kit and mapped accordingly at MoEngage SDK.
Sample Implementation
Refer to this GitHub repository for a sample implementation.