Install
Install the package from NuGet:RadarIO.Xamarin supports both Xamarin and MAUI bindings.
Integrate
Initialize
First, initialize the SDK:Identify user
To identify the user when logged in, call:userId
is a stable unique ID for the user.
To set an optional dictionary of custom metadata for the user, call:
metadata
is a JSONObject
with up to 16 keys and values of type string, boolean, or number.
Finally, to set an optional description for the user, displayed in the dashboard, call:
description
is a string.
You only need to call these functions once, as these settings will be persisted across app sessions.
Learn about platform-specific implementations of these functions in the iOS SDK documentation and Android SDK documentation.
Request permissions
Before tracking the user’s location, the user must have granted location permissions for the app. See the MAUI Permissions docs to learn how to check and request permissions.Foreground tracking
Once you have initialized the SDK and the user has granted permissions, you can track the user’s location. To track the user’s location in the foreground, call:Background tracking
On iOS and Android, once you have initialized the SDK and the user has granted permissions, you can start tracking the user’s location in the background. For background tracking, the SDK supports custom tracking options as well as three presets:TrackingOptionsEfficient
: A low frequency of location updates and lowest battery usage. On Android, avoids Android vitals bad behavior thresholds.TrackingOptionsResponsive
: A medium frequency of location updates and low battery usage. Suitable for most consumer use cases.TrackingOptionsContinuous
: A high frequency of location updates and higher battery usage. Suitable for on-demand use cases (e.g., delivery tracking) and some consumer use cases (e.g., order ahead, “mall mode”).
Listeners should be set only once and before tracking begins.
Mock tracking
On iOS and Android, you can simulate a sequence of location updates for testing. For example, to simulate a sequence of 10 location updates every 3 seconds by car from anorigin
to a destination
, we can call: