iOS SDK Initialization

To initialize the iOS Application with the MoEngage App ID from Settings in the dashboard. In your project, go to AppDelegate file and  call the initialize method of MoECapacitorInitializer instance in applicationdidFinishLaunchingWithOptions() method as shown below:

Sample code to initialise from application:didFinishLaunchingWithOptions: method in

import UIKit
import Capacitor
import CapacitorMoengageCore
import MoEngage

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        var sdkConfig : MOSDKConfig
        let yourAppID = "" //App ID: You can be obtain it from App Settings in MoEngage Dashboard.
        if let config = MoEngage.sharedInstance().getDefaultSDKConfiguration()         {
            sdkConfig = config
            sdkConfig.moeAppID = yourAppID
            sdkConfig = MOSDKConfig.init(appID: yourAppID)
        // Set Correct Data Center here
        sdkConfig.moeDataCenter = DATA_CENTER_01 //DATA_CENTER_01,DATA_CENTER_02,DATA_CENTER_03,DATA_CENTER_04
        // Set App Group ID for sharing data between App and extensions(if Any)
        sdkConfig.appGroupID = "app group id"
        // Change these if required, by default all the below opt-outs are set to false.
        sdkConfig.optOutIDFATracking = false
        sdkConfig.optOutIDFVTracking = false
        sdkConfig.optOutDataTracking = false
        sdkConfig.optOutPushNotification = false
        sdkConfig.optOutInAppCampaign = false
MoECapacitorInitializer.sharedInstance.initializeWithSDKConfig(sdkConfig, withSDKState: true, andLaunchOptions: launchOptions); return true } }




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

How can we improve this article?