For initializing the project, you'll need to provide the Workspace ID 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 Workspace ID. |
Code Initialisation
To initialize MoEngageSDK from application:didfinishlaunchingwithoptions call any one of the below initialization methods by passing MoEngageSDKConfig as parameter. Refer doc for more info on all the properties that can be configured using MoEngageSDKConfig
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)initializeDefaultSDKConfigWithState:(MoEngageSDKConfig*)sdkConfig withSDKState:(MoEngageSDKState)sdkState andLaunchOptions:(NSDictionary*)launchOptions;
Sample code to initialize from application:didFinishLaunchingWithOptions: method:
import MoEngageSDK
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Add your MoEngage Workspace ID and Data center.
let sdkConfig = MoEngageSDKConfig(appId: "YOUR WorkspaceID", dataCenter: YOUR_DATA_CENTER)
sdkConfig.consoleLogConfig = MoEngageConsoleLogConfig(isLoggingEnabled: true, loglevel: .verbose)
MoEngageInitializer.sharedInstance().initializeDefaultSDKConfig(sdkConfig, andLaunchOptions: launchOptions)
//Rest of the implementation of method
//-------
return true
}
#import <ReactNativeMoEngage/MoEngageInitializer.h>
#import <MoEngageSDK/MoEngageSDK.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
MoEngageSDKConfig* sdkConfig = [[MoEngageSDKConfig alloc] initWithAppId:@"YOUR Workspace ID" dataCenter: YOUR_DATA_CENTER];
sdkConfig.consoleLogConfig = [[MoEngageConsoleLogConfig alloc] initWithIsLoggingEnabled:true loglevel:MoEngageLoggerTypeVerbose];
[[MoEngageInitializer sharedInstance] initializeDefaultSDKConfig:sdkConfig andLaunchOptions:launchOptions];
return YES;
}
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.