MAUI Android bindings for Fairmatic Android - SDK
License
—
Deps
34
Install Size
—
Vulns
✓ 0
Published
Dec 10, 2025
$ dotnet add package FairmaticSDK.Android26 and aboveUpdate your *.csproj file to specify supported minimum sdk version
<PropertyGroup>
<SupportedOSPlatformVersion>26</SupportedOSPlatformVersion>
</PropertyGroup>
Based on your AndroidManifest.xml configuration, you might need to update allowBackup=true, dataExtractionRules, android:label & fullBackupContent
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
tools:replace="android:label"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
...>
...
</application>
</manifest>
<data-extraction-rules>
<exclude domain="sharedpref" path="DriveKitPreferences.xml" />
<exclude domain="sharedpref" path="DriveKitEncryptedPreferences.xml" />
<exclude domain="sharedpref" path="DriveKitBackupPrefs.xml" />
<include domain="sharedpref" path="DriveKitBackup.xml" />
</data-extraction-rules>
<data-extraction-rules xmlns:tools="http://schemas.android.com/tools"><!-- Exclude rules of your app
and/or the external libraries -->
<cloud-backup>
<exclude domain="sharedpref" path="DriveKitPreferences.xml" tools:ignore="FullBackupContent" />
<exclude domain="sharedpref" path="DriveKitEncryptedPreferences.xml"
tools:ignore="FullBackupContent" />
<exclude domain="sharedpref" path="DriveKitBackupPrefs.xml" tools:ignore="FullBackupContent" />
<include domain="sharedpref" path="DriveKitBackup.xml" />
</cloud-backup>
<device-transfer>
<exclude domain="sharedpref" path="DriveKitPreferences.xml" tools:ignore="FullBackupContent" />
<exclude domain="sharedpref" path="DriveKitEncryptedPreferences.xml"
tools:ignore="FullBackupContent" />
<exclude domain="sharedpref" path="DriveKitBackupPrefs.xml" tools:ignore="FullBackupContent" />
<include domain="sharedpref" path="DriveKitBackup.xml" />
</device-transfer>
</data-extraction-rules>
With new setup method, you need to provide a valid @DrawableResId in FairmaticTripNotification object. Failing to provide a valid resource id would result in bad notification icon for the Fairmatic SDK notifications. Follow these steps to generate resource id for your assets
fm_car.png) under Platforms/Android/Resources/drawable directory. It could be jpg, png, svg or android vector drawable (xml) file. Note that it needs to be a monochrome image with snake_case filenamedotnet build)Resource.Drawable.fm_car (file name without extension)To put the SDK into a “ready” state, you’ll first need to set up the Fairmatic SDK properly. This allows subsequent Insurance Period APIs to be called and the SDK to start actively capturing information. Replace the "YOUR_SDK_KEY" with the SDK key provided by the Fairmatic team.
FairmaticDriverAttributes fairmaticDriverAttributes = new FairmaticDriverAttributes(
firstName: "John",
lastName: "Doe",
email: "john.doe@example.com",
phoneNumber: "123-456-7890"
);
FairmaticConfiguration fairmaticConfiguration = new FairmaticConfiguration(
driverId: "your_driver_id",
sdkKey: "YOUR_SDK_KEY", // replace with your SDK key
driverAttributes: fairmaticDriverAttributes
);
FairmaticTripNotification fairmaticTripNotification = new FairmaticTripNotification(
"In Drive Notification", "You are now in drive mode.", Resource.Drawable.fm_car // your icon resource name
);
// Setup Fairmatic
Fairmatic.Instance.Setup(Android.App.Application.Context, fairmaticConfiguration, fairmaticTripNotification, fairmaticOperationCallback);
[!IMPORTANT] This code should also be present in the flow when your driver logins successfully into the app, and it should be called at every app launch with proper configuration. Failing to do so will result in errors in the trip APIs.
Start insurance period 1 when the driver starts the day and is waiting for a request. The tracking ID is a key that is used to uniquely identify the insurance trip.
Fairmatic.Instance.StartDriveWithPeriod1(Android.App.Application.Context, "trackingId1-maui", fairmaticOperationCallback);
Start insurance period 2 when the driver accepts the passenger's or the company's request.
Fairmatic.Instance.StartDriveWithPeriod2(Android.App.Application.Context, "trackingId2-maui", fairmaticOperationCallback);
Stop the insurance period when the driver ends the work day. Call stop period when the driver is no longer looking for a request.
Fairmatic.Instance.StartDriveWithPeriod3(Android.App.Application.Context, "trackingId3-maui", fairmaticOperationCallback);
Stop the insurance period when the driver ends the work day. Call stop period when the driver is no longer looking for a request.
Fairmatic.Instance.StopPeriod(Android.App.Application.Context, fairmaticOperationCallback);
Ensure you check for any errors and take appropriate actions in your app to resolve them, ensuring the Fairmatic SDK operates smoothly. Use the following code snippet to perform this check:
Fairmatic.Instance.GetFairmaticSettings(Android.App.Application.Context, new FairmaticSettingsCallbackImpl());
Call teardown API when the driver is no longer working with the application and logs out. This will completely disable the SDK on the application.
Fairmatic.Instance.Teardown(Android.App.Application.Context, fairmaticOperationCallback);