Fairmatic.Android 3.0.3

dotnet add package Fairmatic.Android --version 3.0.3
                    
NuGet\Install-Package Fairmatic.Android -Version 3.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Fairmatic.Android" Version="3.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fairmatic.Android" Version="3.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Fairmatic.Android" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Fairmatic.Android --version 3.0.3
                    
#r "nuget: Fairmatic.Android, 3.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Fairmatic.Android@3.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Fairmatic.Android&version=3.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Fairmatic.Android&version=3.0.3
                    
Install as a Cake Tool

Binding library for Fairmatic android SDK

Prerequisites

  • The SDK supports Android API 26 and above
  • dotnet SDK version 8.0.300 or above
  • Sign in to the Fairmatic dashboard to access your Fairmatic SDK Key.

Additional configurations

SupportedOSPlatformVersion

Update your *.csproj file to specify supported minimum sdk version

<PropertyGroup>
    <SupportedOSPlatformVersion>26</SupportedOSPlatformVersion>
</PropertyGroup>

AndroidManifest.xml

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>
Sample backup rules
<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>
Sample dataExtractionRules
<data-extraction-rules xmlns:tools="http://schemas.android.com/tools">
    <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>

Notification Icon Resource Id

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

  • Put the desired icon file (say 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 filename
  • Build your project (dotnet build)
  • Get resource id using Resource.Drawable.fm_car (file name without extension)

Setup the Fairmatic SDK

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);

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.

Call the insurance APIs

Insurance period 1

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);

Insurance period 2

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);

Insurance period 3

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);

Stopping the insurance period

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);

Fairmatic SDK settings

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());	

Disable SDK [Optional step]

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);
Product Compatible and additional computed target framework versions.
.NET net8.0-android34.0 is compatible.  net9.0-android was computed.  net10.0-android was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.3 296 4/22/2025
3.0.2 247 4/15/2025