iOS SDK Initialization


Microsoft is replacing Xamarin with .NET MAUI and the supported for the latest release of Xamarin is till November 2023. MoEngage will stop providing updates for the MoEngage Xamarin SDK due to the deprecation. Deprecation impacts Xamarin In-App Messaging and will stop working after June 2022. All other features will continue to work in the Xamarin SDK until November 2023.


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
	public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
    	public override bool FinishedLaunching(UIApplication app, NSDictionary options)
          LoadApplication(new App());
          #if DEBUG
            MoEInitializer.InitializeDevWithAppID("Your App ID", app, options);
            MoEInitializer.InitializeProdWithAppID("Your App ID", app, options);
          // 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



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
Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?