This document describes the Pendo iOS SDK Public APIs.
Pendo Class Public API - SDK Version 2.17+
Return type | Public API method - Swift | Publish API method Objective-C | Description |
Void | screenContentChanged() | screenContentChanged |
Used when Pendo is not able to tag specific components in the app, such as delayed elements or components with state change. Must be called after the SDK is initialized. |
Pendo Class Public API - SDK Version 2.10+
Return type |
Public API method - Swift |
Public API method - Objective-C |
Description |
static PendoManager |
shared() |
sharedManager |
Returns a shared instance of the PendoManager. |
Void |
setup(appKey: String) |
setup:(NSString *_Nonnull appkey) |
Initializes the Pendo SDK. Call this API in didFinishLaunchingWithOptions. This API should be used instead of initSDK and initSDKWithoutVisitor, which will be deprecated in future versions. |
Void |
startSession(visitorId: String?, accountId: String?, visitorData: [String: Any]?, accountData: [String: Any]?) |
startSession:(NSString *_Nullable)visitorId accountId:(NSString *_Nullable)accountId visitorData:(NSDictionary *_Nullable)visitorData accountData:(NSDictionary *_Nullable)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. To generate an anonymous visitor, pass nil as the visitorId. This API should be used instead of switchVisitor, which will be deprecated in future versions. Must be called after the SDK was initialized. |
Void |
endSession() |
endSession |
Ends the active session and stops collecting analytics or showing guides to the user. See Exclude Pendo mobile for specific users for more details. Must be called after the SDK is initialized. |
Void |
clearVisitor() |
clearVisitor |
Ends the active session and starts a new session with an anonymous visitor. Must be called after the SDK is initialized. |
Void |
setVisitorData(visitorData: [String: Any]) |
setVisitorData:(NSDictionary *_Nonnull)visitorData |
Update the visitor metadata. Must be called after the SDK is initialized. |
Void |
setAccountData(accountData: [String: Any]) |
setAccountData:(NSDictionary *_Nonnull)accountData |
Update the account metadata Must be called after the SDK is initialized. |
String (get) |
visitorId |
visitorId |
Property: Returns the ID of the visitor in the active session.
|
String (get) |
accountId |
accountId |
Property: Returns the ID for the account in the active session.
|
Void (set) |
accountId |
accountId |
Property: Sets the ID for the account in the active session. |
Void |
track(event: String, properties: [String: Any]?) |
track:(NSString *_Nonnull)event properties:(NSDictionary *_Nullable)properties |
Sends a track event with the specified properties. Must be called after the SDK is initialized. |
Void |
dismissVisibleGuides() |
dismissVisibleGuides |
Dismisses all visible guides. |
Void |
pauseGuides(dismissGuides: Bool) |
pauseGuides:(BOOL)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. |
Void |
resumeGuides() |
resumeGuides |
Resumes showing guides during the active session. Should only be used after pauseGuides. Must be called after the SDK is initialized. |
String |
getDeviceId() |
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.
|
Void |
enableClickAnalytics(view: id) |
(void)enableClickAnalytics:(id)view; |
This method makes the object passed in act as a taggable/clickable object by Pendo SDK. The object will no longer be treated as a taggable/clickable object once it's not visible on the screen param view passed in the object, should be of type UIVIew. API should be added in viewDidLoad |
Void |
setDebugMode(isDebugEnabled: Bool
|
setDebugMode:(BOOL)isDebugEnabled |
Use when you want to enable/disable debug log from Pendo SDK. |
Pendo Class Public API For JWT - SDK Version 2.13+
Return type | Public API method - Swift | Public API method - Objective-C | Description |
Void | startSession(jwt: String, signingKeyName: String) | startSession:(NSString *_Nonnull)jwt signingKeyName:(NSString *_Nonnull)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 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. |
Void | setVisitorData(jwt: String, signingKeyName: String) | setVisitorData:(NSString *_Nonnull)jwt signingKeyName:(NSString *_Nonnull)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.
|
Void | setAccountData(jwt: String, signingKeyName: String) | setAccountData:(NSString *_Nonnull)jwt signingKeyName:(NSString *_Nonnull)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: 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.
Return type |
Public API method - Swift |
Public API method - Objective-C |
Description |
PendoInitParams |
PendoInitParams() |
[[PendoInitParams alloc] init] |
Constructor |
Property Type |
Public Property Name |
Description |
String (set) |
visitorId |
Sets the Visitor ID for the session that will start following the initialization with this PendoInitParams object. Nil value is used for anonymous visitor |
Dictionary<String, NSObject> (set) |
visitorData |
Sets the Visitor metadata for the session that will start following the initialization with this PendoInitParams object. |
String (set) |
accountId |
Sets the Account ID for the session that will start following the initialization with this PendoInitParams object. |
Dictionary<String, NSObject> (set) |
accountData |
Sets the account's metadata for the session that will start following the initialization with this PendoInitParams object. |
Pendo Initialization Guidelines
setup
should only be called once during the application lifecycle.startSession
may take time to complete, depending on network connectivity. NSNotificationCenter 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.
SDK Initialization
setup
should be placed in the AppDelegate application(_:didFinishLaunchingWithOptions:)
Setup the SDK
Objective-C
@import Pendo;
In the applicationapplication(_:didFinishLaunchingWithOptions:)
method, add the following code:
Objective-C
NSString * appKey = @"YOUR_API_KEY";
[[PendoManager sharedManager] setup: appKey];
Swift
let appKey = "YOUR_API_KEY"
PendoManager.shared().setup(appKey)
Start mobile session
When you would like to start the session with a visitor (identified or anonymous) call startSession
. To generate an anonymous visitor, pass nil as the visitorId.
Objective-C
@import Pendo;
Add the following code to your application where your visitor is known:
Identified Visitor
Objective-C
NSString * visitorId = @"John Smith";
NSString * accountID = @"Acme Inc";
//set visitor metadata
NSDictionary * visitoraData = @{@"Age":@27, @"Country":@"USA", @"Gender":@"Male"};
//set account metadata
NSDictionary * accountData = @{@"Tier":@1, @"Size":@"Enterprise"};
Swift
let visitorId = "John Smith"
let accountID = "Acme Inc"
//set visitor metadata
let visitoraData = ["Age": "27", "Country": "USA", "Gender": "Male"]
//set account metadata
let accountData = ["Tier": "1", "Timezone": "EST", "Size": "Enterprise"]
Anonymous Visitor:
Objective-C
NSString * visitorId = nil;
NSString * accountID = nil;
NSDictionary * visitoraData = nil;
NSDictionary * accountData = nil;
Swift
let visitorId = nil
let accountId = nil
let visitoraData = nil
let accountData = nil
Call startSession() method - This code will start the mobile session and retrieve all guides based on the provided information.
Objective-C
[[PendoManager sharedManager] startSession: visitorId
accountId: accountId
visitorData: visitorData
accountData: accountData];
Swift
PendoManager.shared().startSession(visitorId,
accountId: accountId,
visitorData: visitorData,
accountData: 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.).
Objective-C
NSDictionary *eventProperties = @{@"propety1":@"value1", @"propety2":@"value2"};
[[PendoManager sharedManager] track:@"customEvent1" properties:eventProperties];
Swift
let eventProperties = ["propety1": "value1", "propety2": "value2"]
PendoManager.shared().track("customEvent1", eventProperties)
NSNotificationCenter
- You can register to Pendo notifications to be notified on Pendo's initialization progress.
- Using notifications 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 kPNDDidSuccessfullyInitializeSDKNotification . At that time, all mobile guides are processed and ready to be displayed to your users.
Notification Key Name |
Usage |
kPNDDidSuccessfullyInitializeSDKNotification |
Receive a notification when SDK initialization successfully completed. |
kPNDErrorInitializeSDKNotification |
Receive a notification when SDK initialization failed. |