Skip to main content

Overview

Config-based initialization keeps your MoEngage configuration in a MoEngage dictionary in your app target’s Info.plist. You generate the dictionary from the MoEngage config generator, and the SDK initializes from it.

Prerequisites

  • MoEngage iOS SDK 10.03.2 or later. See SDK Integration.
  • Your Workspace ID, from Settings > Account > General Settings in the MoEngage dashboard.
  • Your data center. See Data Center.

Generate the Configuration

1

Choose the Platform

Go to the MoEngage config generator, select iOS, then select Continue.
2

Select Your Features

Select the modules your app needs, then select Continue.
3

Set Your Values

Enter your values.
4

Generate the Configuration

Select Generate the code. The generator lists your packages under Dependencies and the configuration under Config File. Select Copy.
Add the package products listed under Dependencies through Swift Package Manager or CocoaPods, against the targets the same section names.

Add the Configuration to Info.plist

1

Open Info.plist

Open your app target’s Info.plist. An app created with Xcode 13 or later often has no Info.plist file, because the target generates one at build time. In that case, add the dictionary under Custom iOS Target Properties on the target’s Info tab, and Xcode creates the file.
2

Add the MoEngage Dictionary

Add a top-level key named MoEngage of type Dictionary, and add the generated keys inside it.
Return to the config generator whenever a value changes or you adopt another module, and replace the dictionary with the new output. The SDK matches key names exactly and ignores any key it does not recognize, without a build or run-time warning, so a hand-typed key leaves the default in place and the SDK runs on a configuration you did not intend.

Test and Live Environments

The TEST environment serves development and testing. The LIVE environment runs campaigns against your production user base. You switch between the two environments in the dashboard. Select the environment in the generator’s MoEngage Environment field:
Verify the resolved environment before you ship. A mismatch between the build and the environment returns a Bad Device Token error on push delivery.

Set the Build Configuration

When you run the app from Xcode without archiving, confirm that the build configuration for Run mode of the app target in Edit Scheme is set to Debug, which is the default. The SDK then tracks data in the TEST environment. Xcode Edit Scheme dialog with Run mode build configuration set to Debug For the Archive section in Edit Scheme, the build configuration defaults to Release. For a development build, go to App Target > Edit Scheme > Archive > Build Configuration and select Debug before you export. Xcode Edit Scheme dialog with Archive build configuration selection