MoEngage provides a platform which enables companies to deliver personalized interactions to their users through push notifications, in-app campaigns, email campaigns and other re-targeting channels.
CocoaPods is a dependency manager for Objective C & Swift projects and makes integration easier.
-
If you don't have CocoaPods installed, you can do it by executing the following line in your terminal.
sudo gem install cocoapods
-
If you don't have a Podfile, create a plain text file named Podfile in the Xcode project directory with the following content, making sure to set the platform and version that matches your app.
pod 'MoEngage-iOS-SDK'
-
Install MoEngage SDK by executing the following in the Xcode project directory.
pod install
-
Now, open your project workspace and check if MoEngage SDK is properly added.
Login to your MoEngage account, go to Settings in the left panel of the dashboard. Under App Settings, you will find your APP ID. Provide this APP ID while initializing the SDK with initializeTestWithConfig: and initializeLiveWithConfig: methods as shown below.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Create a config object
MOSDKConfig *sdkConfig = [[MOSDKConfig alloc] initWithAppID:@"Your APP ID"];
// Separate initialization methods for Test and Live Environments
#ifdef DEBUG
[[MoEngage sharedInstance] initializeTestWithConfig:sdkConfig andLaunchOptions:launchOptions];
#else
[[MoEngage sharedInstance] initializeLiveWithConfig:sdkConfig andLaunchOptions:launchOptions];
#endif
//Rest of the implementation of method
//-------
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Create a config object
let sdkConfig = MOSDKConfig.init(appID: "Your APP ID")
// Separate initialization methods for Test and Live Environments
#if DEBUG
MoEngage.sharedInstance().initializeTest(with: sdkConfig, andLaunchOptions: launchOptions)
#else
MoEngage.sharedInstance().initializeLive(with: sdkConfig, andLaunchOptions: launchOptions)
#endif
//Rest of the implementation of method
//-------
}
Thats it!! SDK is successfully integrated and initialized in the project, and ready to use.
Please refer to our developer docs to know how to make use of our SDK to track Events and User Attributes, to implement Push Notification and InApps: https://docs.moengage.com/docs/sdk-integration.
See SDK Change Log for information on every released version.