iOS SDK Initialization

📘

Getting your App ID

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

Once the NuGet package is integrated you will have to initialize the iOS Application with the MoEngage App ID which you get from the dashboard. In your project, go to AppDelegate.cs file and call the initialize method of MoEInitializer instance inside FinishedLaunching() as shown below:

using MoEngageXamarin.iOS;

namespace Sampleapp.iOS
{
    [Register("AppDelegate")]
    public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
    {
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
      {
          global::Xamarin.Forms.Forms.Init();
          LoadApplication(new App());
          #if DEBUG
            MoEInitializer.InitializeDevWithAppID("Your App ID", app, options);
          #else
            MoEInitializer.InitializeProdWithAppID("Your App ID", app, options);
          #endif
        
          // Rest of the implementation
          return base.FinishedLaunching(app, options);
      }
    
    // Rest of implementation
    
}

As you can see there are two separate methods for initializing the SDK InitializeDevWithAppID() and InitializeProdWithAppID() for TEST and LIVE environment of your account respectively.

MoEngage SDK makes use of the DEBUG preprocessor macro to decide whether the build is meant for TEST/LIVE Environment. Therefore you will have to make sure that Build Configuration of the App is set to RELEASE for the appstore build.

  • For Development Build: Build Configuration should be set to Debug (Data will be tracked in TEST Environment)
  • For AdHoc Build/App Store Build: Build Configuration should be set to Release (Data will be tracked in LIVE Environment)

❗️

What if Build Configuration is not set correctly?

If the build configuration is not set correctly following might happen:

  • You will see the data from the development build in LIVE environment
  • OR data from AdHoc/Production Build in TEST environment
  • You will get Bad Device Token error while trying to send a push notification to the device.

Data Redirection

❗️

IMPORTANT:

This is only required if you have registered with account in EU region.
Please make sure that you consult with MoEngage team before using this method for redirecting the data.

We support data redirection to our EU servers from our SDK. This can be done by RedirectDataToRegion() method to redirect the data to MoEDataRedirectionRegion.EU region. Make sure to call this method before initializing the SDK. Use the method as shown below:

// Call this method before SDK initialization
MoEInitializer.RedirectDataToRegion(MoEDataRedirectionRegion.EU);