Overview
This article is designed to walk you through installing the Pendo SDK into your Xamarin app.
Note: This article is intended to walk you through installing Pendo SDK v1.52 and lower.
Requirements
- Pendo Mobile Xamarin iOS SDK works for both Xamarin.iOS and Xamarin.Forms projects.
- Pendo Mobile Subscription
Step 1. Add NuGet Package
1.1 In Visual Studio’s Solution Explorer, right-click on you iOS project target, then select "Add" - > "Add NuGet Packages…" (OR)
Alternatively, you can right-click on "Packages" inside the project file tree and choose Add Packages… option from the context menu.
1.2 Search for Insert and press Add Package.

1.3 Wait until the installation process finishes.

Step 2. Add Code
2.1 Look for a get function for Window
. If not found, add the following get
and set
methods to your AppDelegate.cs (for Xamarin.Forms project, skip this step):
public override UIWindow Window
{
get;
set;
}
2.2 Add Insert initSDK
call to your AppDelegate.cs in your finishedLaunching
method (for Xamarin.Forms project, add it below the line with LoadApplication
call):
InsertXB.InsertManager.SharedManager().InitSDK("YOUR_API_KEY", "YOUR_COMPANY_NAME", null);

_YOUR_API_KEY_
and _YOUR_COMPANY_NAME_
with your actual application values. These values can be found within the SDK installation instructions (Under "Step: 3 Add Initialization Code" of iOS SDK Integration Guide) within your app after you login.
To get access to "iOS SDK Integration Guide" you must sign in/sign up to your Pendo account, and either add a new application or select the existing application and press SDK Integration menu option.

2.3 Add OpenUrl
method to your AppDelegate.cs:
public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
{
if (url.Scheme.Contains("insert"))
{
InsertXB.InsertManager.SharedManager().InitWithUrl(url);
return true;
}
// your code here...
return true;
}

Step 3. iOS Setup
Add URL Scheme
to the project.
3.1.1 Double-click Info.plist file in Solution Explorer
3.1.2 Select Advanced tab
3.1.3 Expand URL Types section (if needed)
3.1.4 Paste _YOUR_URL_SCHEME_
into URL Schemes text field. _YOUR_URL_SCHEME_
can be found within "Step 2: Set a URL Scheme" of iOS the SDK Integration Guide inside Pendo.
To get access to "iOS SDK Integration Guide" you must sign in/sign up to your Pendo account, and either add a new application or select the existing application and press SDK Integration menu option.
3.1.5 Press Add URL Type button.


Step 4. (Optional) - HTTP Images and Videos
While Apple highly suggests using the HTTPS protocol and secure communication to internet based information, there might be times that this isn’t always possible. For example, if you are communicating with a 3rd party web service or using internet delivered ads in your app. With Insert, for example, you may want to use some native video links via HTTP, although we strongly recommend to use them only via HTTPS. That’s why optionally, you can make the following changes to your app’s Info.plist file to completely disable App Transport Security (ATS) for all domains and internet communication (for testing purposes only):
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
To make those changes and include them into your Info.plist file:
4.1.1 Double-click Info.plist file in Solution Explorer
4.1.2 Select Source tab
4.1.3 Press + on Add new entry line
4.1.4 Add NSAppTransportSecurity property with Dictionary type
4.1.5 NSAllowsArbitraryLoads entry with Boolean value and set it to Yes


Step 5. (Optional) - iPhone Simulator
Pendo Mobile iOS SDK uses web sockets and Keychain to enable pairing between iOS application and Pendo website. To use this feature with iPhone Simulator, perform the following steps.
5.1.1 Double-click Entitlements.plist file in Solution Explorer. If the file doesn’t exist in your project, create it by right-clicking on the project file and selecting Add - > New File | iOS | Entitlements.plist
5.1.2 Make sure Entitlements tab is selected
5.1.3 Scroll to Keychain section, expand it (if need so) and checkmark it.
5.1.4 Double-click project file in Solution Explorer, Project Options window opens
5.1.5 Choose Build section on the left, then choose **iOS Bundle Signing
5.1.6 Make sure iPhoneSimulator is selected under Platform at the top
5.1.7 Add Entitlements.plist file under Specify entitlements and custom settings | Custom Entitlements on the right, by clicking […] button, selecting Entitlements.plist file and pressing the OK button.


- Right-click Entitlements.plist file in Solution Explorer
- Choose Open With - > Xcode or TextEdit
- Add
$(AppIdentifierPrefix)
underkeychain-access-groups
value in front of your APPLICATION-BUNDLE-ID string.
For more information, please check out this blog post on sharing keychain access in iOS.
Step 6. (Optional) - iPhone Simulator Rich Push
Push Mobile guide uses deeplink feature, which enables you to preview or show guides in your app by simply clicking on the deep link sent via email etc. To enable this feature in iPhone Simulator the compiler arguments must be addressed.
6.1.1 Double-click project file in Solution Explorer, Project Options window opens
6.1.2 Choose Build section on the left, then choose iOS Build
6.1.3 Make sure iPhoneSimulator is selected under Platform at the top
6.1.4 Add the following line under Code Generation & Runtime | Additional mtouch arguments :
registrar:static

Step 7. Adding User Data
It is possible to send user-specific information to Pendo via the SDK. Examples are:
- Visitor ID: a user identifier (e. g. John Smith)
- Account ID: an affiliation of the user to a specific group or company (e. g. Acme Inc)
- Custom data in the form of key-value (e. g. Country=Belgium)
Custom data needs to be pre-configured using the Pendo console in order to be accepted by the backend.
To use Pendo Mobile initSDK
call with Custom data you need to modify it in your AppDelegate.cs:
InsertXB.InsertInitParams initParams = new InsertXB.InsertInitParams();
initParams.AccountId = "Acme Inc";
initParams.VisitorId = "John Smith";
initParams.UserAttributes = new NSDictionary("key1", 1 , "key2", 2 );
InsertXB.InsertManager.SharedManager().InitSDK("$APP_KEY$", "$COMPANY_NAME$", initParams);
_YOUR_API_KEY_
and _YOUR_COMPANY_NAME_
with your actual application values. These values can be found within the SDK installation instructions (Under "Step: 3 Add Initialization Code" of iOS SDK Integration Guide) within your app after you login.
To get access to "iOS SDK Integration Guide" you must sign in/sign up to your Pendo account, and either add a new application or select the existing application and press SDK Integration menu option.%}

Step 8. Push Notifications Setup
8.1 Prerequisites
8.1.1 Complete Provisioning APNs SSL Certificates creation steps for both development and production here
8.1.2 A physical iOS device. Push notifications ARE NOT supported by iPhone Simulator.
8.2 Add Push Certificates .p12 files
8.2.1 Sign in to your Pendo account, select the existing application and press App Details menu option
8.2.2 Scroll down to Push Settings section (if need so)
8.2.3 Click pencil sign on the right to edit certificate fields
8.2.4 Add both development and production certificate .p12 files created at the end of
8.2.5 Press Save button

8.3 Configure Xamarin Project After your service is configured to work with Push notifications on iOS, you can update Xamarin project settings to enable Push notification support for your Xamarin application.
8.3.1 Double-click Info.plist file in Solution Explorer
8.3.2 Make sure Application tab is selected
8.3.3 Scroll down to Background Modes section and expand it (if need so)
8.3.4 Checkmark Enable Background Modes, Modes list will expand
8.3.5 Checkmark Remote notifications
8.3.6 Double-click Entitlements.plist file in Solution Explorer
8.3.7 Make sure Entitlements tab is selected
8.3.8 Scroll to Push Notifications section, expand it (if need so) and checkmark it.

8.3.9 Double-click project file in Solution Explorer, Project Options window opens
8.3.10 Choose Build section on the left, then choose iOS Bundle Signing
8.3.11 Make sure iPhone is selected under Platform at the top
8.3.12 Choose appropriate Signing Identity and Provisioning Profile under Select or create signing identity and provisioning profile section

8.4 Add Code
8.4.1 Add the following code to your AppDelegate.cs in your finishedLaunching
method right below the line with initSDK
call:
var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet());
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
UIApplication.SharedApplication.RegisterForRemoteNotifications();
if (launchOptions != null)
{
// check for a local notification
if (launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
{
var pushPayload = launchOptions[UIApplication.LaunchOptionsRemoteNotificationKey];
if (pushPayload != null)
{
// reset our badge
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
InsertXB.InsertManager.SharedManager().DidReceiveRemoteNotification((NSDictionary)pushPayload);
}
}
}```

**8.4.2** Add the following two methods to your _AppDelegate.cs_:
```java
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
InsertXB.InsertManager.SharedManager().PushId = deviceToken;
}
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
InsertXB.InsertManager.SharedManager().DidReceiveRemoteNotification(userInfo);
}
