Skip to content

Latest commit

 

History

History
161 lines (120 loc) · 6.59 KB

native-android.md

File metadata and controls

161 lines (120 loc) · 6.59 KB

Native Android

Note

The following integration instructions are relevant for SDK 3.0 or higher.
Follow our migration instructions to upgrade from SDK 2.x to 3.0 or refer to our 2.x integration instruction.

Important

Jetpack Compose (Beta), is available starting from SDK 3.3.0. Support includes:

  • Code-based tooltips

Please see integration instructions here.

Important

Requirements:

  • Android Gradle Plugin 7.2 or higher
  • Kotlin version 1.9.0 or higher
  • JAVA version 11 or higher
  • minSdkVersion 21 or higher
  • compileSDKVersion 33 or higher

Step 1. Install Pendo SDK

  1. Add the Pendo repository to the app's build.gradle:

    repositories {
        maven {
            url "https://software.mobile.pendo.io/artifactory/androidx-release"
        }
        mavenCentral()
    }
  2. Add Pendo as a dependency to android/build.gradle file:

    dependencies {
       implementation group:'sdk.pendo.io' , name:'pendoIO', version:'3.4+', changing:true
    }
  3. Minimum and compile SDK versions:

    If applicable, set your app to be compiled with compileSdkVersion 33 or higher and minSdkVersion 21 or higher:

    android {
        minSdkVersion 21
        compileSdkVersion 33
    }
  4. Using ProGuard

    If you are using ProGuard(D8/DX only) to perform compile-time code optimization, and have {Android SDK Location}/tools/proguard/proguard-android-optimize.txt, add !code/allocation/variable to the -optimizations line in your app/proguard-rules.pro file. The optimizations line should look like this:
    -optimizations *other optimizations*,!code/allocation/variable

Step 2. Pendo SDK integration

Note

The API Key can be found in your Pendo Subscription Settings in App Details.

  1. Set up Pendo in the Application class.

    The following code is required in the onCreate method:

    import sdk.pendo.io.*;
    
    String pendoApiKey = "YOUR_API_KEY_HERE";
    
    Pendo.setup(
       this,
       pendoApiKey,
       null, // PendoOptions (use only if instructed by Pendo support)
       null  // PendoPhasesCallbackInterface (Optional)
    );
  2. Initialize Pendo in the Activity/fragment where your visitor is being identified.

    String visitorId = "VISITOR-UNIQUE-ID";
    String accountId = "ACCOUNT-UNIQUE-ID";
    
    // send Visitor Level Data
    HashMap<String, Object> visitorData = new HashMap<>();
    visitorData.put("age", 27);
    visitorData.put("country", "USA");
    
    // send Account Level Data
    HashMap<String, Object> accountData = new HashMap<>();
    accountData.put("Tier", 1);
    accountData.put("Size", "Enterprise");
    
    Pendo.startSession(
        visitorId,
        accountId,
        visitorData,
        accountData
    );

    visitorId: a user identifier (e.g. John Smith)
    visitorData: the user metadata (e.g. email, phone, country, etc.)
    accountId: an affiliation of the user to a specific company or group (e.g. Acme inc.)
    accountData : the account metadata (e.g. tier, level, ARR, etc.)
     
    This code ends the previous mobile session (if applicable), starts a new mobile session and retrieves all guides based on the provided information.
     

Tip

To begin a session for an anonymous visitor, pass null or an empty string "" as the visitor id. You can call the startSession API more than once and transition from an anonymous session to an identified session (or even switch between multiple identified sessions).

Step 3. Mobile device connectivity for tagging and testing

Note

The Scheme ID can be found in your Pendo Subscription Settings in App Details.

This step enables page tagging and guide testing capabilities.

Add the following activity to the application AndroidManifest.xml in the <Application> tag:

<activity android:name="sdk.pendo.io.activities.PendoGateActivity" android:launchMode="singleInstance" android:exported="true">
    <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="YOUR_SCHEME_ID_HERE"/>
    </intent-filter>
</activity>

Step 4. (Optional - for Jetpack Compose Beta integration only)

Continue to the beta integration instructions and complete the additional steps here

Step 5. Verify installation

  1. Test using Android Studio:
    Run the app while attached to the Android Studio.
    Review the Android Studio logcat and look for the following message:
    Pendo SDK was successfully integrated and connected to the server.
  2. In the Pendo UI, go to Settings>Subscription Settings.
  3. Select the Applications tab and then your application.
  4. Select the Install Settings tab and follow the instructions under Verify Your Installation to ensure you have successfully integrated the Pendo SDK.
  5. Confirm that you can see your app as Integrated under subscription settings.

Developer Documentation

  • API documentation available here.
  • Integration of native with Flutter components available here.
  • If for any reason you need to manually install the SDK - please refer to the manual installation page.

Troubleshooting