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 MoEngageSDKConfig instance as its parameter. Refer doc for more info on all the properties which can be configured using MoEngageSDKConfig.
    /// @param sdkConfig MoEngageSDKConfig instance for SDK configuration
    /// @param launchOptions Launch Options dictionary
    - (void)initializeDefaultSDKConfig:(MoEngageSDKConfig*)sdkConfig andLaunchOptions:(NSDictionary*)launchOptions;
    /// @param sdkConfig MoEngageSDKConfig instance for SDK configuration
    /// @param sdkState Enum indicating if SDK is Enabled/Disabled
    /// @param launchOptions Launch Options dictionary
    - (void)initializeDefaultSDKConfig:(MoEngageSDKConfig*)sdkConfig withMoEngageSDKState:(MoEngageSDKState)sdkState 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];
        MoEngageSDKConfig *sdkConfig = [[MoEngageSDKConfig alloc] initWithAppID: @"YOUR 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?
1 out of 1 found this helpful

How can we improve this article?