iOS SDK Initialization

To initialise the iOS Application with the MoEngage App ID from Settings in the dashboard. In your project, go to AppDelegate file and call either of the  initialise method of MoEngageInitializer instance in applicationdidFinishLaunchingWithOptions() method as shown below:

 

Set Correct Data Center

Make sure to set the correct Data Center while initializing the SDK. For more info refer to the following link.

Swift 
/// Method to initialize MoEngage SDK
/// - Parameters:
///   - config: MOSDKConfig instance for SDK configuration
///   - launchOptions: Launch Options dictionary
func initializeDefaultInstance(_ config: MOSDKConfig, launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil)

/// Method to initialize MoEngage SDK with SDK state /// - Parameters: /// - config: MOSDKConfig instance for SDK configuration /// - sdkState: Bool indicating if SDK is Enabled/Disabled /// - launchOptions: Launch Options dictionary func initializeDefaultInstance(_ config: MOSDKConfig, sdkState: Bool = true, launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil)
Sample code to initialise in  applicationdidFinishLaunchingWithOptions() 
 
Swift Objective-C
// Import SDK frameworks
import moengage_flutter
import MoEngageSDK

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {

    let sdkConfig = MOSDKConfig(withAppID: APP ID) //App ID: You can be obtain it from App Settings in MoEngage Dashboard.
    sdkConfig.enableLogs = true
    
    MoEngageInitializer.sharedInstance.initializeDefaultInstance(sdkConfig, launchOptions: launchOptions)
GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } }
Was this article helpful?
0 out of 0 found this helpful