Skip to main content

Overview

Starting with v10.3.0, the Flutter SDK supports file-based initialization.
To streamline the integration process and minimize initialization errors, MoEngage supports Script-Based Initialization. This approach allows you to manage App IDs and configuration settings directly within native configuration files, keeping them separate from your application logic. This article outlines how you can use the form-based interface to generate a validated code snippet for initialization and access module-specific configurations.
Alternatively, the SDK can be initialized manually. If you require this approach, please refer to the guide on Framework Initialization.
Follow these steps to generate your initialization script:
  1. Navigate to the Initialization Website.
  2. Configure the values based on your application requirements. Refer to the Configuration Parameters tables below:
  3. Click Generate Code at the bottom of the form.

Step 1: Android Configuration (XML)

For Android, initialization is handled by placing an XML configuration file in the application’s resource directory.

Android Configuration Reference

Below is the comprehensive list of keys available for moengage.xml.
TroubleshootingIf the XML file is missing or the com_moengage_core_workspace_id is empty, the SDK will throw a ConfigurationMismatchError.

Add Configuration File

Place the generated file in android/app/src/main/res/values/.

Step 2: iOS Configuration (Info.plist)

For iOS, initialization is handled by adding a configuration dictionary to your Info.plist.

iOS Configuration Reference

Below is the comprehensive list of keys available for the MoEngage dictionary.

Data Center Values

Configure the integer corresponding to your region. Incorrect values will result in data loss.

Update Info.plist

  1. Open your project’s Info.plist ( found in ios/Runner/ ).
  2. Create a new Top-Level Key named MoEngage of type Dictionary.
  3. Add the configuration file content generated in the Initialization Website.
The key IsSdkAutoInitialisationEnabled uses the British spelling (‘s’). Ensure you use the exact key name shown below, or initialization will fail.
XML Snippet Representation:

Step 3: Framework Level Initialization

After you configure the native files, the initialization code in your hybrid framework is simplified. Create MoEngageFlutter(YOUR_Workspace_ID) object and in the project’s App Widget call initialise() of MoEngageFlutter plugin in the initState() the method as shown below:

Step 4: Migration and Precedence

To migrate from manual code-based initialization to file-based approach, refer here.

Step 5: Environments (Test vs. Live)

You can configure Test/Live environments within these files.
  • Android: Use the key <string name="com_moengage_core_environment">test</string>.
  • iOS: Use <key>IsTestEnvironment</key> <true/>