Prerequisites
Before you begin, ensure your project meets the following requirements:| Requirement | Version |
|---|---|
| .NET | 9.0 or higher |
| iOS Deployment Target | 13.0 or higher |
| Android Min SDK | API 21 or higher |
Installation
Option A β NuGet Package (Recommended)
Install the Userpilot MAUI SDK β a single package that automatically includes the correct platform bindings:Option B β Project Reference (For Local Development)
Add a project reference to the appropriate binding project in your.csproj file:
- For Android, add the required NuGet dependencies:
Note: You may need to pin additional AndroidX packages to resolve duplicate class errors. See the sample .csproj for the full list of recommended package versions.
Initializing
To use Userpilot, initialize the SDK during your appβs launch sequence. Replace<APP_TOKEN> with your Application Token, which can be fetched from your Environments Page.
iOS Initialization
On iOS, you must enable automatic push notification configuration in yourAppDelegate.cs before the SDK is set up. This enables method swizzling for push notification handling.
Android Initialization
On Android, initialize the SDK by passing the application context:Cross-Platform Initialization Example
You can wrap initialization with preprocessor directives for a unified flow:Using the SDK
Once initialized, the SDK provides straightforward APIs for identifying users, tracking events, and screen views.Identifying Users (Required)
This API identifies unique users and sets their properties. Once identified, all subsequent tracked events and screens will be attributed to that user. Recommended Usage:- On user authentication (login): Immediately call
Identifywhen a user signs in. - On app launch for authenticated users: If the user has a valid session, call
Identifyat app launch. - Upon property updates: Whenever user or company properties change.
- Key
idis required in company properties to identify a unique company. - Userpilot supports
String,Numeric, andDatetypes. - Send date values in ISO 8601 format.
- If you plan to use Userpilotβs localization features, pass user property
locale_codewith a value in ISO 639-1 format. - Use reserved property keys:
emailfor the userβs email.namefor the userβs or companyβs name.created_atfor the userβs or companyβs signup date.
Note: Ensure the User ID source is consistent across Web, Android, and iOS. While properties are optional, setting them enhances Userpilotβs segmentation capabilities.
Tracking Screens (Required)
CallingScreen is crucial for unlocking Userpilotβs core engagement and analytics capabilities. When a user navigates to a particular screen, invoking Screen records that view and triggers any eligible in-app experiences.
Tracking Events
Log any meaningful action the user performs. Events can be button clicks, form submissions, or any custom activity you want to analyze. Optionally, pass metadata as a JSON string.Anonymous Users
If a user is not authenticated, callAnonymous to track events without a user ID. This is useful for pre-signup flows or guest sessions.
Note: Anonymous users count towards your Monthly Active Users usage. Consider your MAU limits before using this API.
Trigger Experiences
Triggers a specific experience programmatically using its unique ID. This API allows you to manually initiate an experience within your application.End Experience
Ends the currently active experience (if any).Logging Out
When a user logs out, callLogout to clear the current user context. This ensures subsequent events are no longer associated with the previous user.
Configurations (Optional)
The following parameters can be passed during SDK initialization via theSetup method:
| Parameter | Type | Description |
|---|---|---|
| logging | Boolean | Enable or Disable logs for SDK Default: false |
| disableRequestPushNotificationsPermission | Boolean | Disable request push notifications permission by SDK. Default: false |
| useInAppBrowser | Boolean | Configuration to indicate when to open the URL inside CustomTabsIntent or not. (Android only) Default: false |
Callbacks
If you have additional configuration needs, you can register callback delegates to receive navigation events, analytics events, and experience lifecycle events.Important (iOS): On iOS, callback instances must be stored in static fields to prevent the .NET garbage collector from finalizing them. The native Swift SDK holds weak Objective-C references to these objects, which the .NET GC cannot see.
Navigation Callback
Handles deep link routes triggered by Userpilot experiences (e.g., when a user taps a CTA link inside an experience).iOS
Android
Analytics Callback
Receives callbacks whenever the SDK tracks an event, screen, or identifies a user. Useful for integrating with another analytics tool or logging events for debugging.iOS
Android
Experience Callback
Receives callbacks when Userpilot experiences (flows, surveys, NPS) start, complete, are dismissed, or progress through steps. Experience Types:Flow, Survey, NPS
Experience States: Started, Completed, Dismissed, Skipped, Submitted
iOS
Android
Note (Android): Register callbacks before calling Setup() so that events fired during initialization are not lost.
Note (iOS): Register callbacks after calling Setup(). Store callback instances in static fields to prevent GC from collecting them.
Push Notifications
Userpilot SDK supports push notifications on both iOS and Android. This section covers the full setup required for each platform.iOS Push Notification Setup
It is recommended to configure your Android push settings in the Userpilot Settings Studio before setting up push notifications in your app. To obtain the required keys and configuration details, please refer to the iOS Push Notification Guide.1. Enable Push Notifications Capability
Add theaps-environment entitlement to your Entitlements.plist file at Platforms/iOS/Entitlements.plist:
Note: Changedevelopmenttoproductionwhen publishing to the App Store.
2. Enable Background Remote Notifications
Add theremote-notification background mode to your Info.plist at Platforms/iOS/Info.plist:
3. Configure Code Signing in the .csproj
Add the signing configuration to your.csproj file to use the provisioning profile you created:
4. Enable Automatic Push Configuration
In yourAppDelegate.cs, call EnableAutomaticPushConfig() before the SDK is set up. This enables method swizzling so the Userpilot SDK automatically handles:
- Registering for remote notifications
- Receiving the device push token
- Handling notification responses
Android Push Notification Setup
It is recommended to configure your Android push settings in the Userpilot Settings Studio before setting up push notifications in your app. To obtain the required keys and configuration details, please refer to the Android Push Notification Guide.1. Firebase Project Configuration
Follow the steps in the official Google documentation on How to add Firebase to your project.2. Register google-services.json in the .csproj
Add theGoogleServicesJson build action in your .csproj so .NET MAUI processes it and generates the required Android string resources (google_app_id, gcm_defaultSenderId, etc.):
3. Add Add the Userpilot Firebase Messaging Service and Push Notification Permissions
Add the required permissions and the Userpilot Firebase Messaging Service to yourAndroidManifest.xml at Platforms/Android/AndroidManifest.xml:
4. Configure Notification Appearance
Create a resource file atPlatforms/Android/Resources/values/userpilot.xml to customize the notification appearance:
5. Handle Push Notification Intents in MainActivity
Configure yourMainActivity.cs to forward push notification intents to the Userpilot SDK. Use LaunchMode.SingleTop to ensure deep links are routed to the existing activity instance.
Using ProGuard / R8 (Android)
If you are using R8 or ProGuard for code shrinking, add the following rules to your ProGuard configuration file (e.g.,Platforms/Android/proguard.cfg):
.csproj:
π¬ Sample App
Thesample/ directory contains a full .NET MAUI sample app that demonstrates all Userpilot SDK APIs from a single page. The sample includes: