SDK Installation

Prev Next

Suggested reading: Basic SDK Setup

This guide helps you understand the requirements for SDK setup and installation, and how to initialize it.

Required For Setup

  • An installed Mac with Xcode 
  • An iOS device. The Xcode simulator does not support push notifications, so you must test on a real device.
  • An Apple Push Services Certificate for iOS
  • An Android device or emulator with a minimum API 21
  • A Huawei Messaging Service Server Key and agconnect-services.json imported into your app (for only Huawei Devices without Google Service)
  • A Firebase Cloud Messaging Server Key and google-services.json imported into your app
  • Android Studio

Integrating Plugin to Cordova Project

1. Update the widget ID property that is specified in the config.xml file. It must be the same with the client > package_name value of the agconnect-services.json file for Huawei configuration.
2. Copy the google-services.json and agconnect-services.json files to the project’s root directory.
3. Install the Insider Cordova plugin.

npm i cordova-plugin-insider

Initialize SDK

1. Add the following to the bottom of the first JavaScript file that loads with your app. This is <project-dir>/www/js/index.js for most Cordova projects.

var app = {
    initialize: function () {
        document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
    },

    onDeviceReady: function () {
        initSDK();
    }
};

async function initSDK() {
    //Update the PARTNER_NAME and APP_GROUP_ID value below with yours.
    await window.Insider.init('PARTNER_NAME', 'APP_GROUP_ID',
        (callback) => {
            switch ((callback.result || {}).type) {
                case window.Insider.callbackType.NOTIFICATION_OPEN:
                    console.log('[INSIDER][NOTIFICATION_OPEN]: ', callback.result || {});
                    break;
                case window.Insider.callbackType.INAPP_BUTTON_CLICK:
                    console.log('[INSIDER][INAPP_BUTTON_CLICK]: ', callback.result || {});
                    break;
                case window.Insider.callbackType.TEMP_STORE_PURCHASE:
                    console.log('[INSIDER][TEMP_STORE_PURCHASE]: ', callback.result || {});
                    break;
                case window.Insider.callbackType.TEMP_STORE_ADDED_TO_CART:
                    console.log('[INSIDER][TEMP_STORE_ADDED_TO_CART]: ', callback.result || {});
                    break;
                case window.Insider.callbackType.TEMP_STORE_CUSTOM_ACTION:
                    console.log('[INSIDER][TEMP_STORE_CUSTOM_ACTION]: ', callback.result || {});
                    break;
                case window.Insider.callbackType.INAPP_SEEN:
                    console.log('[INSIDER][INAPP_SEEN]: ', callback.result || {});
                    break;
            }
        })
};

app.initialize();

2. Complete the Android and iOS native steps.

Once you complete the SDK installation, you can proceed with setting callbacks.