Overview
This document describes the Pendo iOS SDK Public APIs.
Pendo Class Public API
Return type |
Public API method - Swift |
Public API method - Objective-C |
Description |
static PendoManager |
shared() |
sharedManager |
Returns a shared instance of the PendoManager. |
Void |
initSDK(appKey: String, initParams: PendoInitParams?) |
initSDK:(NSString *_Nonnull)appKey initParams:(PendoInitParams *_Nullable)initParams |
Initializes the Pendo SDK using the specified app key and params. |
Void |
initSDKWithoutVisitor(appKey: String) |
initSDKWithoutVisitor:(NSString *_Nonnull)appKey |
Initializes the Pendo SDK without visitor and account data, using the specified app key. |
Void |
switchVisitor(visitorId: String?, accountId: String?, visitorData: [String: Any]?, accountData: [String: Any]?) |
switchVisitor:(NSString *_Nullable)visitorId accountId:(NSString *_Nullable)accountId visitorData:(NSDictionary *_Nullable)visitorData accountData:(NSDictionary *_Nullable)accountData |
Ends the current session when there is an active session then starts a new session with the new visitor and account information. Passing nil as the visitorId will generate an anonymous visitor id. Must be called after the SDK was initialized. |
Void |
endSession() |
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. |
Void |
clearVisitor() |
clearVisitor |
Ends the active session starts a new session with an anonymous visitor. Must be called after the SDK was initialized. |
Void |
setVisitorData(visitorData: [String: Any]) |
setVisitorData:(NSDictionary *_Nonnull)visitorData |
Update the visitor metadata. Must be called after the SDK was initialized. |
Void |
setAccountData(accountData: [String: Any]) |
setAccountData:(NSDictionary *_Nonnull)accountData |
Update the account metadata Must be called after the SDK was 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 was initialized. |
Void |
dismissVisibleGuides() |
dismissVisibleGuides |
Dismisses all visible guide. |
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 was initialized. |
Void |
resumeGuides() |
resumeGuides |
Resumes showing guides during the active session. Should only be used after pauseGuides. Must be called after the SDK was 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.
|
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
initSDK
orinitSdkWithoutVisitor
should only be called once during the application lifecycle (select one of the two options)initSDK
andswitchVisitor
have similar functionalities that initiate multiple backend calls and guide retrieval. These APIs should never be called sequentially.initSDK
andswitchVisitor
may take time to complete, depending on network connectivity. NSNotificationCenter should be used to receive notifications when Pendo SDK initialization completes.switchVisitor
should only be used to switch a visitorID and/or AccountID. No action will be taken if Visitor and Account ID did not change.- clearVisitor or endSession API should be used when a user logs out of their application.
Initialization when Visitor is known on App Launch
initSDK
should be used in the AppDelegate application(_:didFinishLaunchingWithOptions:)
when a visitor (identified or anonymous) is known during app launch.
Identified Visitor
Objective-C
@import Pendo;
In the applicationapplication(_:didFinishLaunchingWithOptions:)
method, add the following code:
PendoInitParams *initParams = [[PendoInitParams alloc] init];
[initParams setVisitorId:@"John Smith"];
//set visitor metadata
[initParams setVisitorData:@{@"Age":@27, @"Country":@"USA", @"Gender":@"Male"}];
[initParams setAccountId:@"Acme"];
//set account metadata
[initParams setAccountData:@{@"Tier":@1, @"Timezone":@"EST", @"Size":@"Enterprise"}];
Swift
import Pendo
In the application(_:didFinishLaunchingWithOptions:)
method, add the following code:
let initParams = PendoInitParams()
initParams.visitorId = "John Smith"
//set visitor metadata
initParams.visitorData = ["Age": "27", "Country": "USA", "Gender": "Male"]
initParams.accountId = "Acme"
//set account metadata
initParams.accountData = ["Tier": "1", "Timezone": "EST", "Size": "Enterprise"]
Anonymous visitor
Objective-C
PendoInitParams *initParams = nil;
Swift
let initParams = nil
Initialize the SDK - Objective-C
NSString * appKey = @"YOUR_API_KEY";
[[PendoManager sharedManager] initSDK: appKey
initParams: initParams];
Initialize the SDK - Swift
let appKey = "YOUR_API_KEY"
PendoManager.shared().initSDK(
appKey,
initParams: initParams)
Initialization when Visitor is not known during App Launch
When the visitor (identified or anonymous) is known during a later time in the application lifecycle,
initSdkWithoutVisitor
in the AppDelegate application(_:didFinishLaunchingWithOptions:) and call switchVisitor
when the user is identified.
Objective-C
@import Pendo;
In the application(_:didFinishLaunchingWithOptions:)
method of the application, add the following code:
NSString * appKey = @"YOUR_API_KEY";
[[PendoManager sharedManager] initSDKWithoutVisitor:appKey];
Swift
import Pendo
In the application(_:didFinishLaunchingWithOptions:)
method of the application, add the following code:
let appKey = "YOUR_API_KEY"
PendoManager.shared().initSDKWithoutVisitor(appKey)
Add the following code to Application class 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 switchVisitor() method - This code will start the mobile session and retrieve all guides based on the provided information.
Objective-C
[[PendoManager sharedManager] switchVisitor: visitorId
accountId: accountId
visitorData: visitorData
accountData: accountData];
Swift
PendoManager.shared().switchVisitor(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. |
SwitchVisitor
switchVisitor
can be used during the application lifetime to replace the current visitor.
Call this API will end the current session and start a new session with the new visitor and retrieve all guides based on the new information
- visitorId: visitor identifier (e.g. John Smith)
- visitorData: visitor metadata
- accountId: affiliation of the visitor to a specific company or group (e.g. Acme Inc)
- accountData: account metadata
Passing nil
as the visitorId
will generate an anonymous visitor id.