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 MOFlutterInitializer instance in applicationdidFinishLaunchingWithOptions() method as shown below:

📘

Set Correct Data Center:

Make sure to set the correct Data Center while initializing the SDK. For more info refer to the following link

// Import SDK frameworks
import moengage_flutter
import MoEngage

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {

    // Call SDK Initialize method
    // Update your SDK Config here.
    var sdkConfig : MOSDKConfig
    let yourAppID = "Your MoEngage App ID" //App ID: You can be obtain it from App Settings in MoEngage Dashboard.
    if let config = MoEngage.sharedInstance().getDefaultSDKConfiguration()      {
        sdkConfig = config
        sdkConfig.moeAppID = yourAppID
    }
    else{
        sdkConfig = MOSDKConfig.init(appID: yourAppID)
    }
    
    // Set Correct Data Center here
    sdkConfig.moeDataCenter = DATA_CENTER_01 //DATA_CENTER_01,DATA_CENTER_02,DATA_CENTER_03
    
    // 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
    
    MOFlutterInitializer.sharedInstance.initializeWithSDKConfig(sdkConfig, andLaunchOptions: launchOptions)
    
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
// Import SDK frameworks
#import <MoEngage/MoEngage.h>
#import <moengage_flutter/moengage_flutter-Swift.h>
  
@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  
    // Call SDK Initialize method
    // Update your SDK Config here.
    NSString* yourAppID = @"Your MoEngage App ID"; //App ID: You can be obtain it from App Settings in MoEngage Dashboard.
    MOSDKConfig* sdkConfig = [[MoEngage sharedInstance] getDefaultSDKConfiguration];
    if (sdkConfig == nil) {
        sdkConfig = [[MOSDKConfig alloc] initWithAppID:yourAppID];
    }
    else{
        sdkConfig.moeAppID = yourAppID;
    }

    // Set Correct Data Center here
    sdkConfig.moeDataCenter = DATA_CENTER_01; //DATA_CENTER_01,DATA_CENTER_02,DATA_CENTER_03
  
    // 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;
    
    [MOFlutterInitializer.sharedInstance initializeWithSDKConfig:sdkConfig andLaunchOptions:launchOptions];
    
    [GeneratedPluginRegistrant registerWithRegistry:self];
    // Override point for customization after application launch.
    return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@end