iOS 9.x.x

For initializing the project, you'll need to provide the AppID of your MoEngage App.

info

Note

Login to your MoEngage account, go to Settings in the left panel of the dashboard. Under App Settings, you will find your APP ID.

  • Go to Info.plist of your project.
  • Create MoEngage dictionary
  • Inside MoEngage dictionary, Add MoEngage_APP_ID key and provide AppID.

Screenshot_2022-09-22_at_8.10.20_PM.png

Following are the additional properties of SDK that can be configured in Info.plist [From Plugin Version 7.1.1]:

Property Description
APP_GROUP_ID Provide the app Group ID configured for Push Notifications and to share data between App and Extensions
DATA_CENTER Specify the Data Center(Cluster) where your account is present. Possible values are DATA_CENTER_01 / DATA_CENTER_02 / DATA_CENTER_03/ DATA_CENTER_04.
DISABLE_PERIODIC_FLUSH SDK by default syncs the data tracked periodically with the backend, in case you would want to disable the same set this property to true.
PERIODIC_FLUSH_DURATION In case you want to define the interval for periodic sync, set the value in seconds here. Please note that the value should be greater than 60 secs.
ENCRYPT_NETWORK_REQUESTS Set this property to true, in case you would want to encrypt all the network requests sent from the SDK.
ENABLE_LOGS Set this property to true, to see the console logs

 

warning

Warning

Make sure to call the below initializeSDKWithLaunchOptions: method which has been introduced from plugin version 6.0.0.

Once the AppID changes are done, go to your AppDelegate file and call any one of the below initialization method in application:didFinishLaunchingWithOptions: method:

Objective-C
/// @param sdkConfig MoEngageSDKConfig instance for SDK configuration
/// @param launchOptions Launch Options dictionary
- (void)initializeDefaultInstance:(NSDictionary*)launchOptions;
/// @param sdkConfig MoEngageSDKConfig instance for SDK configuration
/// @param isSdkEnabled Bool indicating if SDK is Enabled/Disabled
/// @param launchOptions Launch Options dictionary
- (void)initializeDefaultInstance:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions;

Sample code to initialise from application:didFinishLaunchingWithOptions: method:

Note: For swift applications add #import <ReactNativeMoEngage/MoEngageInitializer.h> in App-Bridging-Header.h file

Swift Objective-C
import MoEngageSDK  
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
      MoEngageInitializer.sharedInstance().initializeDefaultInstance(launchOptions)
      //Rest of the implementation of method
      //-------
      return true
}

Code Initialisation

To initialize MoEngageSDK from application:didFinishLaunchingWithOptions: without adding any keys to Info.plist, call any one of the below initialization method by passing MoEngageSDKConfig as parameter.Refer doc for more info on all the properties which can be configured using MoEngageSDKConfig.

Objective-C

Objective-C
/// @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 isSdkEnabled Bool indicating if SDK is Enabled/Disabled
/// @param launchOptions Launch Options dictionary
- (void)initializeDefaultSDKConfig:(MoEngageSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions;

Sample code to initialise from application:didFinishLaunchingWithOptions: method:

Swift Objective-C
import MoEngageSDK  
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
      //Add your MoEngage App ID and Data center.
       let sdkConfig = MoEngageSDKConfig(withAppID: "YOUR APPID")
       sdkConfig.enableLogs = true
       MoEngageInitializer.sharedInstance().initializeDefaultSDKConfig(sdkConfig, andLaunchOptions: launchOptions)
      //Rest of the implementation of method
      //-------
      return true
}

Previous

Next

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

How can we improve this article?