iOS

For initializing the project, you'll need to provide the WorkspaceID of your MoEngage Workspace.

info

Note

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

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

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 MOSDKConfig instance for SDK configuration
/// @param launchOptions Launch Options dictionary
- (void)initializeDefaultInstance:(NSDictionary*)launchOptions;
/// @param sdkConfig MOSDKConfig 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:

Objective-C
#import <ReactNativeMoEngage/MoEngageInitializer.h>
#import <MoEngageSDK/MoEngageSDK.h>
@implementation AppDelegate
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[MoEngageInitializer sharedInstance] initializeDefaultInstance: launchOptions]; 
    // Rest of the implementation
    return YES;
}

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 MOSDKConfig as parameter.Refer doc for more info on all the properties which can be configured using MOSDKConfig.

Objective-C
/// @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:

Objective-C
#import <ReactNativeMoEngage/MoEngageInitializer.h>
#import <MoEngageSDK/MoEngageSDK.h>
@implementation AppDelegate - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { MOSDKConfig* sdkConfig = [[MOSDKConfig alloc] initWithAppID:@"YOUR Workspace ID"]; sdkConfig.enableLogs = true; [[MoEngageInitializer sharedInstance] initializeDefaultSDKConfig:sdkConfig andLaunchOptions:launchOptions]; return YES; } @end

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.

Previous

Next

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

How can we improve this article?