This article describes the Pendo Android SDK Public APIs.
Note: The information here is relevant for SDK versions lower than 3.0. For API documentation for the latest Pendo SDK versions and information about the integration process, refer to our GitHub.
Pendo Class Public API
Modifier and return value | API Public method (Java) | Description |
static synchronized void |
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. |
static synchronized void | setup(Application app, String appKey, PendoOptions options, PendoPhasesCallbackInterface callbacks) |
Initializes the Pendo SDK. Call this API in application's 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. A session can be restarted by calling the startSession() API Must be called after the SDK is initialized. |
static void | clearVisitor() |
Ends the active session and starts a new session with an anonymous visitor. Must be called after the SDK is initialized.
|
static void | setVisitorData(Map<String, Object> visitorData) |
Updates the visitor metadata. Must be called after the SDK is initialized. |
static void | setAccountData(Map<String, Object> accountData) |
Updates the account metadata Must be called after the SDK is 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. 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 is 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 is initialized. |
static synchronized void | resumeGuides() |
Resumes showing guides during the active session. Should only be used after pauseGuides. Must be called after the SDK is 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 is 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 is 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 is initialized. |
Pendo initialization guidelines
-
setup
should only be called once during the application lifecycle, for example, in the application's onCreate(). -
startSession
may take time to complete, depending on network connectivity. CallbackInterface should be used to receive notifications when Pendo SDK initialization completes. startSession
is used to set a VisitorID and/or AccountID. No action will be taken if the Visitor and Account ID do not change.endSession
should be used to end the visitor session when the user logs out of the application.
SDK Initialization
Initialize the SDK
To initialize the Pendo SDK, call the Setup API. This API prepares the SDK to start a session. The session will not start until the StartSession API is called.
An example of where the Setup API can be called is in the Application’s onCreate() method.
The API Key can be found in your Pendo Subscription.
Kotlin
Pendo.setup(this,"YOUR_API_KEY",null)
Java
Pendo.setup(this,"YOUR_API_KEY",null);
Start mobile session
To start a session with a visitor (identified or anonymous), call the StartSession API. StartSession must be called after Setup and can be called anywhere in your app’s flow.
Anonymous visitor
Kotlin
val visitorId: String? = null
val accountId: String? = null
val visitorData: Map<String, Any>? = null
val accountData: Map<String, Any>? = null
Pendo.startSession(visitorId,accountId,visitorData,accountData)
Identified visitor
Kotlin
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.).