Developer's Guide to Installing the Pendo Xamarin Forms 5 SDK

 

The Xamarin Forms 5 Pendo SDK is intended to be installed in the Xamarin shared project space, allowing the SDK to run simultaneously for both iOS and Android.

If you are not using Xamarin Forms 5+, or you have previously set up the Pendo SDK independently in the iOS Xamarin or Android Xamarin spaces, follow the articles Installing the Pendo Xamarin Android SDK and Installing the Pendo Xamarin iOS SDK

 

Install instructions 

  1. Select Settings > Subscription Settings > Add Another App and select the Xamarin Forms 5+ app type.

    Xamarin_forms5%2B_app.png

  2. Note that in Pendo, two applications are created under the 'Subscription Settings' page (one for Android and one for iOS).

    xamarinforms_ios_android.png

  3. Select either app and select Continue to installation.

 

Pendo Setup and Initialization

The SDK initialization has three parts, importing the SDK, setting up the SDK to communicate with Pendo's servers, and starting a recording of a session. Setting up the communication with Pendo's server should be conducted once the application launches. Once connected, you can start the session recordings.

Pendo must be initialized to identify the user, begin data collection, and display guide content. The SDK can be initialized when the visitor is authenticated and metadata is known or with an anonymous visitor. Recording a session can be conducted when the application starts, later when the visitor is identified, or at any time you need to identify the current visitor and start a new session.

Identified visitors use a defined schema to create visitor and account objects with associated metadata in Pendo. Refer to the article on Visitor and Account Metadata for additional information on how this data is defined and used in Pendo. Passingnull or "" as the visitorId will generate an anonymous visitor ID.

  • visitorId - String containing a unique User ID (e.g. "user-SFGH-56gh"), this ID should match the visitor ID for any other Pendo web or mobile apps
  • accountId - String containing unique Account ID, affiliation of the visitor to a specific company or group (e.g. Acme Inc), this ID should match the visitor ID for any other Pendo web or mobile apps
  • visitorData - Visitor metadata (e.g email, phone, country, etc.)
  • accountData - Account metadata (e.g tier, level, ARR, etc)

Step 1: Install Pendo SDK

  1. In Visual Studio Solution Explorer, right-click on your project, then select "Add" - > "Add NuGet Packages…".
  2. Search for PendoSDKXamarin with the latest version.
  3. Press Add Package.

 

Step 2: Pendo SDK integration

Open the shared application App.xaml.cs and add the following under 'using':

...
 using PendoSDKXamarin;
 ...

 namespace ExampleApp
 {
   public partial class App : Application
   {
       ....
       private static IPendoInterface Pendo = DependencyService.Get<IPendoInterface>();
       ....    

 

In the protected override void OnStart() method, add the following code:

protected override void OnStart()
{
   string appKey = "eyJhbGciOiJSUzI1NiIsImtpZCI6IiIsInR5cCI6IkpXVCJ9.eyJkYXRhY2VudGVyIjoidXMiLCJrZXkiOiIwMTRiMTExYTBlYTBiMzUxNDc1ZWM2YzhlNGU0MWVkMWIwNWE1N2VjNzliYWEzOGE0MzQ2ODc0NTcwZWY2NWY4ODc0NjNmNDQ0NTcxZmE4ZmYwYmM2Nzg4NDVlZWNiYWU0ZWQxYmQ4MzBlYzU3ZmNlODY3ZGY0MmM3MDlmNGQ3NjY4MzI4MjdjOTVkYzE5YjA4YmE5ZWQwMTk2YjlmNzU5MmVhNGE4OGE3ZTZmYWFjYjM5ZTVmNTFlMzM2ZjhhMjZiNzdhOTE0OWRkYWIxYWY5OWM2Yzg5MmVkNTNiMTJlNmQyNjk3MjQ3OTQ0OTZmZWMwNjY0M2I0MDMyMzEwMzIzLjRkZGYxOTNhNDM0NDFkNWVmYzhjZWI0NjAyYzAzNjZkLmYyOTdkZWNiMmFmYzk1YTJiOWQwODc5ZmVkMjU2ZGE3NTQ0NWVmOTYzMmY3YWJiZmIxZTgyYzI3ZDhlZTU2OTkifQ.ml6lCv_WUlg-gnTwNfkm2tN81aTUDl2CHNLp9umqHvAePnSIpM5HHiQalLDj4r7FisKBmgtovzKO7ogXskgQL6fqSQDKvM5274KV2KzbQPb89jq9c37mjDiAzAauGoFNT2z72B8LcVdWwkuF4gfMKSwslNbtmlQLYsSQwA8ILBc";
   Pendo.Setup(appKey);
   ...

 

Start the visitor's Session in the page where your visitor is being identified (e.g. login, register, etc.).

...
 using PendoSDKXamarin;
 ...

 namespace ExampleApp
 {
   class ExampleLoginClass
   {
   ...
   private static IPendoInterface Pendo = DependencyService.Get<IPendoInterface>();
   ...
   public void LogginCallBackExampleMethod()
   {
       ....
       var visitorId = "VISITOR-UNIQUE-ID";
       var accountId = "ACCOUNT-UNIQUE-ID";

       var visitorData = new Dictionary<string, object>
       {
           { "age", 27 },
           { "country", "USA" }
       };

       var accountData = new Dictionary<string, object>
       {
           { "Tier", 1 },
           { "Size", "Enterprise" }
       };

       Pendo.StartSession(visitorId, accountId, visitorData, accountData);
       ...
   }
   ...

visitorId: a user identifier (e.g. John Smith)
visitorData: the user metadata (e.g. email, phone, country, etc.)
accountId: an affiliation of the user to a specific company or group (e.g. Acme inc.)
accountData: the account metadata (e.g. tier, level, ARR, etc.)

This code ends the previous mobile session (if applicable), starts a new mobile session and retrieves all guides based on the provided information.

Tip: Passing null or "" as the visitorId generates an anonymous visitor id.

 

Step 3. Mobile device connectivity for tagging and testing

These steps enable page tagging and guide testing capabilities.

 

iOS

  1. Add Pendo URL Scheme to info.plist file:
    Under the iOS App Target > open info.plist > if URL Types doesn't exist, click on 'Add new entry' and name it 'URL types', for the type choose 'Array'. Create a new URL by clicking the + button. Under the new created Dictionary, change 'Document role' to 'URL Schemes' with type 'Array'. Expand 'URL Schemes' and add the pendo-2461ef69 under the 'Value'. Under the created Dictionary in the previous step, add new entry with the name 'URL Identifier', type 'string' and set a name of your preference under its 'Value'.
  2. Add or modify the function OpenURL:
    Open AppDelegate.cs file and add the following code under OpenUrl method:
    public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
    {
        if (url.Scheme.Contains("pendo"))
        {
            PendoForms.PendoManager.InitWithUrl(url.AbsoluteString);
            return true;
        }
        return true;
    }

 

Android

Add the following activity to the application AndroidManifest.xml in the tag:

<activity android:name="sdk.pendo.io.activities.PendoGateActivity" android:launchMode="singleInstance" android:exported="true">
 <intent-filter>
   <action android:name="android.intent.action.VIEW"/>
   <category android:name="android.intent.category.DEFAULT"/>
   <category android:name="android.intent.category.BROWSABLE"/>
   <data android:scheme="pendo-2f919a79"/>
 </intent-filter>
</activity

 

Step 4: Verify installation

  1. Using Visual Studio: Run the app and search in the device log for:
    Pendo SDK was successfully integrated and connected to the server. 

     

  2. Click to go through a verification process for the SDK integration.
  3. Confirm that you can see your app under subscription settings as Integrated.

 

Troubleshooting Xamarin Forms 5 Installation

If you previously installed the Xamarin SDK with an iOS and Android platform-specific application key, and you now want to install the new shared app, you should remove the previous installation code from the iOS Xamarin Project and Android Xamarin Project spaces and follow the instructions above. Note that the Xamarin shared project installation instructions above expect a single application key, so, when applying the instructions you should adjust the code to combine the two iOS and Android distinct application keys that you were previously using in your project as follows:

private const string KeyIOS = PENDO_IOS_KEY;
private const string KeyAndroid = PENDO_ANDROID_KEY;

private string Key() 
{
    string key = null;

    if (Device.RuntimePlatform == Device.iOS)
    {
        key = KeyIOS;
    }
    else if(Device.RuntimePlatform == Device.Android)
    {
        key = KeyAndroid;
    }

    return key;
}