iOS SDK Initialization

Code Initialization

From plugin version 8.0.0 we support initialization only via code. In the version 8.0.0 we have removed the initialization of SDK support via info.plist which was supported in 7.1.1 and above.

  • Call any one of the below-given initialization methods in application:didFinishLaunchingWithOptions: method. The method accepts the MOSDKConfig instance as its parameter. Refer doc for more info on all the properties which can be configured using MOSDKConfig.
    /// @param sdkConfig MOSDKConfig instance for SDK configuration
    /// @param launchOptions Launch Options dictionary
    - (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig andLaunchOptions:(NSDictionary*)launchOptions;
    /// @param sdkConfig MOSDKConfig instance for SDK configuration
    /// @param isSdkEnabled Bool indicating if SDK is Enabled/Disabled
    /// @param launchOptions Launch Options dictionary
    - (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions;
  • Sample code to initialise from application:didFinishLaunchingWithOptions: method:
    #import "AppDelegate.h"
    #import "MainViewController.h"
    // Make sure to import "AppDelegate+MoEngage.h"
    #import "AppDelegate+MoEngage.h"
    @implementation AppDelegate
    - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
        self.viewController = [[MainViewController alloc] init];
        MOSDKConfig *sdkConfig = [[MOSDKConfig alloc] initWithAppID: @"Your MoEngage App ID"];
        sdkConfig.moeDataCenter = DATA_CENTER_01; // Possible Values DATA_CENTER_01/DATA_CENTER_02/ DATA_CENTER_03
        sdkConfig.appGroupID = "App Group ID";
        // ---
        // Update other Parameters of SDK Config
        [self initializeDefaultSDKConfig:sdkConfig andLaunchOptions:launchOptions];
        return [super application:application didFinishLaunchingWithOptions:launchOptions];

Data Center

In case your app wants to redirect data to a specific zone due to any data regulation policy please configure the zone in the MOSDKConfig object.

Refer to the Data Center documentation for more information.



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

How can we improve this article?