Contact Us

Installation

Pendo Help CenterInstallationAndroid SDK Integration

Android SDK Integration

warning: This article contains generic instructions. For personalized instructions for your Pendo instance, please use the instructions located within your App.

Overview

This SDK version was released on January 17, 2019.

Warning: To install this version, you will need to change your older Pendo Mobile installation code. The setVisitor and userAttributes API endpoints have changed in this update. You would also need to increment your app version.

Step 1. Gradle file

In your app’s gradle file, add the following statements in order to automatically retrieve the Pendo (or Insert) SDK repository. Add to the repositories section:

repositories {
   maven {
     url "https://software.insert.io/artifactory/android-sdk-externals"
   }
   maven {
     url "https://software.insert.io/artifactory/android-release"
   }
  mavenCentral()
 }

Add a dependency:

dependencies {
    implementation group:'sdk.insert.io' , name:'insertIO', version:'1.52.52.+', changing:true
 }

Your app should be compiled with compileSdkVersion 27 or higher and minSdkVersion 14 or higher:

android {
    minSdkVersion 14
    compileSdkVersion 27
}

Step 2. Manifest file

Add the following <activity> to the manifest in the <application> tag:

<activity android:name="sdk.insert.io.activities.InsertGateActivity" android:launchMode="singleInstance">
  <intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="insert-YOUR SCHEME ID HERE"/>
  </intent-filter>
  <intent-filter>
    <action android:name="YOUR SCHEME ID HERE" />
    <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
</activity>

You must replace "YOUR SCHEME ID HERE" with your scheme id. Find your Scheme ID by following this guide

Step 3. Application class: Add Initialization Code

Find your app’s Application class. The Application class should extend android.app.Application. If you are using Multidex, the Application class must extend MultiDexApplication instead. If an Application class does not exist, you must create one.

At the top of the file, add the following import statement:

import sdk.insert.io.*;

In the onCreate method add the following line before any activity is launched:

Insert.InsertInitParams insertParams = new Insert.InsertInitParams();
insertParams.setVisitorId("John Smith");
insertParams.setAccountId("Acme Inc");

//send visitor custom data
  Map<String, String> userData = new HashMap<>();
                userData.put("age", "27");
                userData.put("country", "USA");
  insertParams.setUserData(userData);

//send account custom data
  Map<String, String> accountData = new HashMap<>();
                accountData.put("Tier", "1");
                accountData.put("Size", "Enterprise");
  insertParams.setAccountData(accountData);

// un-comment the below line to enable support for Fragments
//insertParams.setInsertOptions(new Insert.InsertOptions.Builder().setFragmentIdentificationEnabled(true).build());

Insert.initSDK(
    this,
    "YOUR API KEY",
    "YOUR COMPANY ID",
    insertParams);   // call initSDK with initParams as a fourth parameter.

You must replace "YOUR API KEY" and "YOUR COMPANY ID" with your API key and COMPANY Id. Find them by following this guide.

You can also update visitor and account IDs or custom data during the mobile session. Consider the use case of an application which provides the capability to log in again as different user. Use the following:

Insert.switchVisitor(
"New Visitor ID",
"New Account ID",
Map<String, String> newUserData,
Map<String, String> newAccountData);

This code acts as similar to the initSDK function. It will end the old session and create a new one to retrieve all guides based on the new information.

Using Proguard

If you are using Proguard within your app, add the following statements to file proguard-rules.pro

-keep class okio.** { *; }
-dontwarn okio.**
-keep class retrofit.** { *; }
-dontwarn retrofit.**
-keep class rx.** { *; }
-dontwarn rx.**
-keep class sdk.insert.** { *; }
-dontwarn sdk.insert.**
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-dontwarn org.mozilla.**
-dontwarn org.slf4j.**
-dontwarn retrofit2.**
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault
-dontwarn com.jakewharton.rxbinding.**
-keep class com.daimajia.easing.** { *; }
-keep interface com.daimajia.easing.** { *; }
-keep class org.mozilla.** { *; }
-keep class org.apache.commons.lang3.** { *; }
-keep public class * extends android.view.View {
 public (android.content.Context);
 public (android.content.Context, android.util.AttributeSet);
 public (android.content.Context, android.util.AttributeSet, int);
 public void set*(...);
}

In case you’re using the proguard-android-optimize.txt, add the following in the optimizations code line:

!code/allocation/variable

Your optimizations line should look like this:

-optimizations *other optimizations*,!code/allocation/variable

Test your changes

  • Test using Android Studio: Run the app while attached to the Android Studio. Review the device log and look for the message: Insert SDK was successfully integrated and connected to the Insert server. You can start adding insert to your app in the Insert’s web site.
  • Confirm you can see your app at subscription settings

(Optional) Custom Events

Mobile Custom Events allow your app developers to programmatically trigger guides or to be used as Segments. To use custom events in Pendo, you need first to define the events in the Pendo console follow this guide and then place the generated snippet in your app to trigger the event.

(Optional) Push notification support

Pendo provides support for push notification. In order to enable Pendo push-notification in your App, you must call an API on the Insert SDK to set the unique push. For further information on how to achieve that see our documentation.

Upgrading to a new SDK version

Perform the following steps to upgrade your SDK version:

  • In the gradle file, change the dependency to the latest SDK version. Copy the version number from the "dependencies" statement in the section above.
  • If using Proguard, make sure you have the most up to date Proguard statements as described above.
  • Pendo is version aware. To be able to distinguish the old SDK from the new, you must increment the version of your app
  • Review the release notes for any backward compatibility issues
© 2019 Pendo  |  Terms of Service  |  Privacy Policy