Android Developer API Documentation

Last Updated:

 

This document describes the Pendo Android SDK Public APIs. 

Pendo Class Public API 

Modifier and return value

API Public method (Java)

Description

static synchronized void

setDebugMode(boolean enableDebug)

Use when you want to enable/disable debug log from Pendo SDK.

This API can be called anywhere in your code and will be valid after startSession has been called.

static synchronized void

setup(Application app, String appKey
PendoOptions
options
PendoPhasesCallbackInterface 
callbacks)

Initializes the Pendo SDK. Call this API in application.onCreate. Options should always be null.

Initialization phases are denoted by the callbacks interface.

This API should be used instead of initSDK and initSDKWithoutVisitor which will be deprecated in future versions. 

static void

startSession(String visitorId, String accountId, Map<String, Object> visitorData, Map<String, Object> accountData)

Starts mobile session with provided visitor and account information. If a session is already in progress, the session will end and a new session will start.

Must be called after the SDK was initialized.

To generate an anonymous visitor, pass null as the visitorId.

This API should be used instead of switchVisitor which will be deprecated in future versions. 

static void

endSession()

Ends the active session and stops collecting analytics or showing guides to the user. More details here.

Must be called after the SDK was initialized.

static void

clearVisitor()

Ends the active session and starts a new session with an anonymous visitor.

Must be called after the SDK was initialized.
This API is deprecated as of SDK version 2.15.0. Please use startSession API with all arguments set to nil instead.

static void

setVisitorData(Map<String, Object> visitorData)

Update the visitor metadata. 

Must be called after the SDK was initialized.

static void

setAccountData(Map<String, Object> accountData)

Update the account metadata

Must be called after the SDK was initialized.

String

getVisitorId()

Returns the ID of the visitor in the active session. 

String

getAccountId()

Returns the ID for the account in the active session. 

static void

setAccountId(String accountId)

Sets the ID of the account for the active session.
This API is deprecated as of SDK version 2.15.0. Please use startSession API with the desired accountId.

static void

track(String eventName, @Nullable Map<String, Object> properties)

Sends a track event with the specified properties.

Must be called after the SDK was initialized.

static void

dismissVisibleGuides()

Dismisses all visible guides.

static synchronized void

pauseGuides(boolean dismissGuides)

Pauses any guides from showing during an active session. If dismissGuides is TRUE then all visible guides will be dismissed.

Must be called after the SDK was initialized.

static synchronized void

resumeGuides()

Resumes showing guides during the active session. Should only be used after pauseGuides. 

Must be called after the SDK was initialized.

String

getDeviceId()

Returns the device's unique Pendo-generated id. The device id is used by Pendo to generate a unique id for each anonymous visitor. This id is unique per application. 

boolean

sendClickAnalytic(View V)

Sends RAClick analytics for any view. Use when Pendo does not automatically recognize clickable features.

View must be set as 'clickable:true' in the xml/activity. API should be called in the same place the element’s action implemented upon click. (onTouchListener, onClickListener etc)

Must happen after startSession has been called.

static void

screenContentChanged()

This method manually triggers a rescan of the current screen layout hierarchy by the SDK and should only be called on rare occasions where the delayed appearance of some elements on the screen is not recognized by the SDK. I.e after entering some screen and some delay view’s visibility property has been changed from invisible to visible or a view’s color alpha has changed such that it has become visible. The next cases should not require manual rescan: a view’s visibility changes from gone to visible, a view was added dynamically to the view hierarchy, or a screen content was scrolled.


Pendo Class Public API For JWT - SDK Version 2.13+

Modifier and return value

API Public method (Java)

Description

static void

startSession(String jwt, String signingKeyName)

Starts a mobile session with the provided JWT and the key name used to sign the JWT. The JWT containing the visitor and account information should be created and signed using the key on your server-side. Call this API with the JWT and name of the signing key after obtaining the information from your server-side. If a session is already in progress, the session will end and a new session will start.

To generate an anonymous visitor, the payload must contain both a visitor and account elements with an empty string as their id.

This API can only be used once the "use signing metadata" of your application flag is enabled. 

Must be called after the SDK was initialized.

static void

setVisitorData(String jwt, String signingKeyName)

Update the visitor metadata. The JWT containing the new / updated visitor information should be created and signed using the key on your server-side. Call this API with the JWT and name of the signing key after obtaining the information from your server-side. The JWT payload should not include account information and the visitor id must match the visitor id used to start the session.

This API can only be used once the "use signing metadata" of your application flag is enabled. 

Must be called after the SDK was initialized.

static void

setAccountData(String jwt, String signingKeyName)

Update the account metadata. The JWT containing the new / updated account information should be created and signed using the key on your server-side. Call this API with the JWT and name of the signing key after obtaining the information from your server-side. The JWT payload should not include visitor information and the account id must match the account id used to start the session.

This API can only be used once the "use signing metadata" of your application flag is enabled. 

Must be called after the SDK was initialized.

 


Pendo Class Public Deprecated APIs - SDK Version 2.9 and lower 

Modifier and return value

API Public method (Java)

Description

static synchronized void

initSDK(Application app, String appKey, PendoInitParams params)

Initializes the Pendo SDK from an Application class using the specified app key and params.

static synchronized void

initSDK(Activity activity, String appKey, PendoInitParams params)

Initializes the Pendo SDK from an Activity class using the specified app key and params.

static synchronized void

initSdkWithoutVisitor(Application app, String appKey, PendoOptions options, PendoPhasesCallbackInterface calllbacks)

Initializes the Pendo SDK without visitor and account data, using the specified app key and options, in the specified application context. Options should always be null, initialization phases are denoted by the callbacks interface.

 

static void

switchVisitor(String visitorId, String accountId, Map<String, Object> visitorData, Map<String, Object> accountData)

Ends the current session when there is an active session then starts a new session with the new visitor and account information. 

Passing null as the visitorId will generate an anonymous visitor id. 

Must be called after the SDK was initialized.

Pendo Class: PendoInitParams

The following class is used in InitSDK() methods. It includes details about the visitor and the account that can later be used for segmentation and analysis within Pendo.

Make sure to send to Pendo only user and account details that are allowed by your security team and that are not considered private information. Pendo will not share these details with any 3rd party.

Modifier type and return type Public API method Description

N/A

PendoInitParams()

Constructor

PendoInitParams (this)

setVisitorId(String visitorId)

Sets the Visitor ID for the session that will start following the initialization with this PendoInitParams object.

Null value is used for anonymous visitor

PendoInitParams (this)

setVisitorData(Map<String, Object> visitorData)

Sets the Visitor metadata for the session that will start following the initialization with this PendoInitParams object.

PendoInitParams (this)

setAccountId(String accountId)

Sets the Account ID for the session that will start following the initialization with this PendoInitParams object.

PendoInitParams (this)

setAccountData(Map<String, Object> accountData)

Sets the account's metadata for the session that will start following the initialization with this PendoInitParams object.

PendoInitParams (this)

SetCallbackInterface()

Sets the PendoPhasesCallbackInterface to be called
when initialized by this PendoInitParams object

Pendo Initialization Guidelines

  1. setupshould only be called once during the application lifecycle in the application.onCreate.
  2. startSessionmay take time to complete, depending on network connectivity. CallbackInterface should be used to receive notifications when Pendo SDK initialization completes.  
  3. startSession is used to set a visitorID and/or AccountID. No action will be taken if Visitor and Account ID did not change. 
  4. endSession should be used to end the visitor session when the user logs out of the application.

SDK Initialization 

Add the following code in the Application onCreate() method :

Initialize the SDK

Kotlin 

Pendo.initSDK(
this,
"YOUR_API_KEY",
pendoParams
)

Java 

String pendoAppKey = "YOUR_API_KEY"; 
Pendo.initSDK(
this,
pendoAppKey,
pendoParams);

Initialization when Visitor is known during Activity Class onCreate() 

When a visitor (identified or anonymous) is known later in the application lifecycle, during an Activity class onCreate() (e.g. the user has to login, or has been switched, etc.). 

Add the following code in the Application onCreate() method :

Kotlin
Pendo.setup(
this,
"YOUR_API_KEY",
null
)
Java
Pendo.setup(
this,
"YOUR_API_KEY",
null);

Start mobile session

When you would like to start the session with a visitor (identified or anonymous) call startSession in your Activity onCreate method. To generate an anonymous visitor, pass null as the visitorId.

 

Identified visitor

Kotlin 

val pendoParams = Pendo.PendoInitParams()
val visitorId = "John Smith"
val accountId = "Acme Inc"

//set visitor metadata
val visitorData: MutableMap<String, Any> = HashMap()
visitorData["age"] = 27
visitorData["country"] = "USA"
pendoParams.visitorData = visitorData

//set account metadata
val accountData: MutableMap<String, Any> = HashMap()
accountData["Tier"] = 1
accountData["Type"] = "Enterprise"
pendoParams.accountData = accountData
 
Java 
String visitorId = "John Smith";
String accountID = "Acme Inc";

//set visitor metadata
Map<String, Object> visitorData = new HashMap<>();
visitorData.put("age", 27);
visitorData.put("country", "USA");
pendoParams.setUserData(visitorData);

//set account metadata
Map<String, Object> accountData = new HashMap<>();
accountData.put("Tier", 1);
accountData.put("Size", "Enterprise");
pendoParams.setAccountData(accountData);

 

Anonymous visitor

Kotlin

val visitorId: String? = null
val accountId: String? = null
val visitorData: Map<String, Any>? = null
val accountData: Map<String, Any>? = null

Java

String visitorId = null;
String accountID = null;
Map<String, Object> visitorData = null;
Map<String, Object> accountData = null;
 
Start session
Kotlin 
Pendo.startSession(
visitorId,
accountId,
visitorData,
accountData
)
Java
Pendo.startSession(
visitorId,
accountId,
visitorData,
accountData);
 

Track Events Flow

This method allows you to pass track event information using the Pendo SDK. 

Use Case Example:  Since Pendo already tracks click events (RAClick events) and screen changes (RAScreenView events), a good example would be a callback you would like to track (i.e. transaction response callbacks, such as payment completed or failed, etc.).

Kotlin
val clickEventProp: MutableMap<String, Any> = HashMap()
clickEventProp["propertyId"] = 1
clickEventProp["propety1"] = "example property"

Pendo.track("MyCustomManuallyTrackedEvent", clickEventProp)
 
Java
Map<String, Object> clickEventProp = new HashMap<>();
accountData.put("propertyId", 1);
accountData.put("propety1", "example property");

Pendo.track("MyCustomManuallyTrackedEvent", clickEventProp);
 

Pendo Callback Interfaces

You can register to callback methods while calling startSession() to be notified on Pendo's initialization progress.

Using callbacks can affect your user journey and the timing of guide display with Pendo - in case you want to make sure that Pendo processed all guides by the time the user starts using the app, you can show the app's UI only after onInitComplete(). At that time, all mobile guides are processed and ready to be displayed to your users.

 

Public Interface

Methods

Usage

PendoPhasesCallbackInterface

void onInitStarted()
void onInitComplete()
void onInitFailed()

Denotes the SDK initialization phases.

 

ProGuard

If you are using Proguard within your app follow the install instruction in your Pendo App to file the most current proguard-rules.pro