Skip to main content

Include MoEngage Configuration

After the MoEngage package is imported, include MoEngageConfiguration.h file in your Asset folder
(Asset > Import New Asset). Download this configuration file from here.
Ios SDK Initialization
In your configuration file, set MoEngage App ID and Region along with other constants as shown below:

Unity App Controller Swizzling

There are two approaches using which the SDK can be initialized:
  1. Unity App Controller Subclass:
    SDK contains the MoEUnityAppController class which is the subclass of UnityAppController. Here we get a callback on AppLaunch to initialize MoEngage SDK.
  2. UnityAppController swizzling:
    Define kMoEngageUnityControllerSwizzlingEnabled in the configuration file and set it to YES to enable UnityAppController swizzling. Here application:didfinishLaunchinWithOptions: method is swizzled to initialize MoEngage SDK.
UnityAppController swizzling (2nd approach) will be required if your project has multiple implementations of UnityAppController subclasses (1st approach), here the subclass defined in the plugin might not work reliably because here only one of the subclasses in the project will get the callbacks.

Build and Replace

We make use of CocoaPods for managing native dependencies, therefore make sure the same is installed in your system.
Once required packages are imported go to File > Build Settings, switch to iOS platform, and click on Build. Select Replace in the pop-up. It’s necessary to select Replace on first-time integration, this is because we will be updating the build settings of the Xcode project for MoEngage SDK and also installing the native dependencies via CocoaPods.
IOSSDK Intialization2
After building the project in Unity Editor, open Unity-iPhone.xcworkspace in Xcode, and you are good to run the Unity-iPhone App.