React Native Developer API Documentation (iOS & Android)

Last Updated:

This document describes the Pendo React Native SDK Public APIs. 

Pendo Class Public API - SDK Version 2.21+

Public API method

Description

WithPendoReactNavigation(NavigationContainer) Only for apps that use React Navigation library. This function wraps the navigation container to track the navigation state.

 

Pendo Class Public API - SDK Version 2.10+

Public API method

Description

setup(appKey: string, navigationOptions: NavigationOptions, pendoOptions?: PendoOptions)

Initializes the Pendo SDK. PendoOptions should always be null.

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

startSession(visitorId: string, accountId: string, visitorData: object, accountData: object)

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.

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

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

Must be called after the SDK was initialized.

endSession()

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

Must be called after the SDK was initialized.

clearVisitor()

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

Must be called after the SDK was initialized.

setVisitorData(visitorData: object)

Update the visitor metadata. 

Must be called after the SDK was initialized.

setAccountData(accountData: object)

Update the account metadata

Must be called after the SDK was initialized.

async getVisitorId(): Promise<string | null>

Returns the ID of the visitor in the active session. 

 

async getAccountId(): Promise<string | null>

 

Returns the ID for the account in the active session. 

 

setAccountId(accountId: string)

Sets the ID of the account for the active session.

track(name: string, params: object)

Sends a track event with the specified properties.

Must be called after the SDK was initialized.

dismissVisibleGuides()

Dismisses all visible guide.

pauseGuides(dismissGuides:boolean)

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.

resumeGuides()

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

Must be called after the SDK was initialized.

async getDeviceId(): Promise<string | null>

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.

 

withPendoRN()

Only for apps that use React Navigation library. This function wraps the navigation container to track the navigation state.

 

Pendo Class Public Deprecated APIs - SDK Version 2.9 And Lower 

Public API method

Description

initSdk(appKey: string, initParams: PendoParams, navigationOptions: NavigationOptions)

Initializes the Pendo SDK using the specified app key, visitor/account metadata and navigation library options.

initSdkWithoutVisitor(appKey: string, navigationOptions: NavigationOptions)

Initializes the Pendo SDK without visitor and account metadata, using the specified app key and navigation library options.

switchVisitor(visitorId: string, accountId: string, visitorData: object, accountData: object)

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.

switchVisitor(visitorParams: PendoParams)

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.

withPendo()

Only for apps that use React Navigation library, with RN plugin versions 2.12 and lower. This function wraps the navigation container to track the navigation state.

For RN plugin versions 2.12.1 and higher, use withPendoRN().

 

Pendo Initialization Guidelines

  • setup should only be called once during the application lifecycle. 
  • startSessionmay 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 Visitor and Account ID did not change. 
  • endSession should be used to end the visitor session when the user logs out of the application.