Flutter Developer API Documentation

Overview

This document describes the Pendo Flutter SDK Public APIs. 

Pendo Class Public API - SDK Version 2.12+

Return type

Public API method - Dart

Description

static PendoFlutterPlugin

PendoFlutterPlugin

Returns a shared instance of the PendoFlutterPlugin.

Future<void>

setup(String appKey, [Map<String, dynamic>? appParams])

Initializes the Pendo SDK. Call this API in In the application main file (lib/main.dart).

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

Future<void>

startSession(String visitorId, String accountId, Map<String, dynamic>? visitorData, Map<String, dynamic>? 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 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.

Future<void>

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.

Future<void>

clearVisitor()

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

Must be called after the SDK was initialized.

Future<void>

setVisitorData(Map<String, dynamic> visitorData)

Update the visitor metadata. 

Must be called after the SDK was initialized.

Future<void>

setAccountData(Map<String, dynamic> accountData)

Update the account metadata

Must be called after the SDK was initialized.

Future<String?>

getVisitorId()

Property: Returns the ID of the visitor in the active session. 

 

Future<String?>

getAccountId()

 

Property: Returns the ID for the account in the active session. 

 

Future<void>

setAccountId(String accountId)

Property: Sets the ID for the account in the active session. 

Future<void>

track(String event, Map<String, dynamic> properties)

Sends a track event with the specified properties.

Must be called after the SDK was initialized.

Future<void>

dismissVisibleGuides()

Dismisses all visible guide.

Future<void>

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.

Future<void>

resumeGuides()

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

Must be called after the SDK was initialized.

Future<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.

 

Pendo Initialization Guidelines

  1. setupshould only be called once during the application lifecycle.
  2. startSessionmay take time to complete, depending on network connectivity. NSNotificationCenter 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 

setupshould be placed in the application main file (lib/main.dart)

Setup the SDK 

import 'package:pendo_sdk/pendo_sdk.dart';

Add the following code in the initState method

final String key = [YOUR_APP_KEY];
PendoFlutterPlugin.setup(key);

 

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 null as the visitorId.

import 'package:pendo_sdk/pendo_sdk.dart';

Add the following code to your application where your visitor is known: 

Identified Visitor 

final String visitorId = 'John Smith';
final String accountId = 'Acme Inc';

// Set visitor metadata
final dynamic visitorData = {'Age': '27', 'Country': 'USA', 'Gender': 'Male'};

// Set account metadata
final dynamic accountData = {'Tier': '1', 'Size': 'Enterprise'};

 

Anonymous Visitor:

final String visitorId = null;
final String accountId = null;
final dynamic visitorData = null;
final dynamic accountData = null;

Call startSession() method - This code will start the mobile session and retrieve all guides based on the provided information.

PendoFlutterPlugin.startSession(visitorId, accountId, visitorData, accountData);

Track Events Flow

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

final dynamic eventProperties = {'property1': 'value1', 'property2': 'value2'};
PendoFlutterPlugin.track("customEvent1", eventProperties);