Overview

Skill Level: Intermediate

The 3.7.1.2.14 SDK includes a new config file option, "autoInitialize". This option is intended to assist customers who want to start the SDK at some point later than at application startup.

Prerequisites

By default, if the “autoInitialize” option is true, the SDK starts when the app starts.

If you want to start the SDK some time after the application starts (for instance, when a user presses a “Login” button), set “autoInitialize”: false.

 

Step-by-step

  1. Using

    Steps:

    1. If the new SDK file option¬†“autoInitialize” does not already exist in your MceConfig.json file, add the JSON key/value pair “autoInitialize”: false, under the JSON root object. If it does exist in MceConfig.json, make sure “autoInitialize” has the value “false”.

    2. In the code where the SDK is started, add the following immediately before calling MceApplication.init(your init args):

    if(!MceSdk.getRegistraitonClient().isSdkInitiated(context)) {
    MceApplication.firstInit(your init args);
    }
    

    so you will end up with code that looks like below:

    if(!MceSdk.getRegistraitonClient().isSdkInitiated(context)) {
        MceApplication.firstInit(your init args);
    }
    MceApplication.init(your init args);
    

    The “init args” may vary depending on how the MceApplication.init is called, but it must be the same for both firstInit and init.

    Note: If an MceSdkConfiguration in MceApplication.init is not specified, use null for its value in firstInit.

    3. If the application subclass inherits from MceApplication, no additional changes are required. If the Application subclass does *not* inherit from MceApplication, add a call to MceApplication.init in the Application class’s onCreate method:

    public void onCreate() {
            super.onCreate();
            MceApplication.init(your init args);
            // do application init stuff
        } 
    

    Note that “your init args” in this call must also match those in firstInit().

    When setting “autoInitialize”: false, the SDK will not actively initialize when you call MceApplication.init() – unless you have previously called MceApplication.firstInit().

Expected outcome

This tutorial takes you through the basic steps in configuring the SDK’s new config file option, “autoInitialize”.

Go Back to Mobile Application Messaging home page.

Join The Discussion

Your email address will not be published. Required fields are marked *