Services

API Interface / Flutter

import 'package:movesdk/movesdk.dart';

Detection Services

Start Automatic Detection

Starts the required detection services stated in the MoveConfig passed on initialization. Starting the service will set the MoveSDKState to .running.

Returns false if the SDK is not in .ready state.

Future<bool> MoveSdk.startAutomaticDetection()

Stop Automatic Detection

Stops the automatic detection service, including all SDK services like driving detection, points of interest, walking and places. Stopping the service will set the MoveSDKState back to .ready.

Returns false if the SDK is not in .ready state.

Future<bool> MoveSdk.stopAutomaticDetection()

Force Trip Recognition

Temporarily calibrates the SDK to the highest detection mode.

In order to optimize battery consumption, the SDK goes through different detection modes with different battery consumption levels, depending on the user's current behavior and activity. In general, the SDK is responsible for alternating between those different detection modes.

The SDK also provides hosting apps this API to call if they have their own reasons (like buttons, sensors or beacons) to believe that the user is starting a trip. This will make sure the SDK is on the highest detection state to detect the trip faster.

Future<void> MoveSdk.forceTripRecognition()

Manual Start Trip

Manually force the start of a trip, bypassing trip validation checks. This non-standard SDK usage may be feasible only in situations where active user input can be expected. Using the metadata parameter, self-defined information can be added to each trip which can be fetched from the timeline.

Future<bool> startTrip(Map<String, String>? metadata)

Returns false if the SDK is not in .ready state.

Precondition: MOVE SDK must be inREADYMoveSdkState.

Manually starting a trip bypasses additional trip detection checks. Manually started trips must be ended with finishCurrentTrip().

It is recommended not to use MoveOptions motionPermissionMandatory or backgroundLocationPermissionMandatorywith this API, as they will be ignored.

Finish Current Trip

Ends the current ongoing trip.

This API will end the ongoing trip and set MoveTripState back to .idle. The SDK is responsible for detecting the trip start and end points. The SDK also provides hosting apps this API to call if they have their own reasons (like sensors or beacons) to believe that the user's trip has ended.

Precondition: MoveTripState should be in an active trip.

Future<void> MoveSdk.finishCurrentTrip()

If this API is called while the user is active on a driving trip, a new trip will start again right away. If the intention is to un-track the ongoing trip, call ignoreCurrentTripAPI.

More information about trip states can be found in MoveTripState.

Ignore Current Trip

Ignores the current ongoing trip.

This API will set the ongoing MoveTripState to .ignored. Data of ignored trips is purged and not sent to the server.

Precondition: MoveTripState should be in an active trip.

Future<void> MoveSdk.ignoreCurrentTrip()

Processing Services

Keep in foreground (Android only)

When an Android application is in the background it may receive limited data (location, sensors, etc.). To improve this behavior, it is possible to put the application always in the foreground with a visible notification that cannot be discarded. Just because it's visible it doesn't mean that it is performing any data collection at all. So this should not have any significant battery impact at all.

Disabled by default. Since it may be annoying to the user, it should only be enabled in case of problems.

Future<void> MoveSdk.keepInForeground(bool enabled)

Keep active (Android only)

To save battery consumption, the SDK is using several triggers to start its data listeners. In case of trouble, these triggers can be circumvented by allowing the MoveSdk to stay active all the time. In that case the SDK is always monitoring required data and is therefore consuming more battery. Depending on the configuration, it may happen that the notification (see notification handling) is always visible to the user.

Disabled by default. Since this is consuming more battery, it should only be enabled in case of problems.

Future<void> MoveSdk.keepActive(bool enabled)

Get SDK State

Gets the current MoveSDKState;

Future<MoveState> getState() async

Get Trip State

Get the current MoveTripState.

Future<MoveTripState> getAuthState() async

Get Auth State

Get the current MoveAuthState.

Future<MoveAuthState> getAuthState() async

Set SDK State Listener

Provide a block to be invoked every time MoveSDKState changes.

Set the MoveSDKState listener before initializing the SDK to anticipate the SDK State changes triggered by the initialization API. Here the host app can start the SDK services when MoveSDKState is.readyor handle errors if occurred.

Stream<MoveState> setSdkStateListener() async*

Set SDK Auth State Listener

Provide a block to be invoked every time MoveAuthState changes.

Stream<MoveAuthState> setAuthStateListener() async*

Authentication Expiry

The host app is expected to monitor MoveAuthState updates viaauthStateUpdateListener API and handle those changes accordingly.

Check Authentication updates and expiry for more details about authentication expiry and renewal.

Set Trip State Listener

Provide a block to be invoked every time MoveTripState changes.

Stream<MoveTripState> setTripStateListener() async*

Set Errors Listener

Provide a block to be invoked every time MoveServiceFailure changes.

Stream<List<MoveServiceError>> setServiceErrorListener() async*

Set Warnings Listener

Provide a block to be invoked every time MoveServiceWarning changes.

Stream<List<MoveServiceWarning>> setServiceWarningListener() async*

Resolve Error

Forces a permission recheck, useful for example after the motion permission request was given in iOS.

Future<void> resolveError()

Synchronize User Data

Used to force synchronizing user data with the SDK server. Limited to once per 2 minutes.

Future<bool> synchronizeUserData()

Returns wether data upload is still in progress.

Other Services

Live Location TAG

New feature since MOVE SDK 2.8.0

Adds a Tag (=string value) to trip events. This tag information is added to the timeline data.

To clear the Tag pass null as parameter.

After a shutdown(...) the tag is also cleared.

Future<bool> setLiveLocationTag(String? tag)

Initiate Assistance Call

New feature in MOVE SDK 2.x; configuration in MOVE dashboard pending - please get in touch.

Initiate an assistance call to emergency services.

Future<MoveAssistanceCallStatus> initiateAssistanceCall()

Returns a promise with a MoveAssistanceCallStatus.

Precondition: The assistance call service needs to be configured in the MOVE dashboard. The SDK needs to be in ready or running state.

Set Assistance MetaData

Future<void> setAssistanceMetaData(String? assistanceMetadataValue)

The metadata string is set once, and then sent to the server with each and every manual assistance call and with AID report. The contents of the string can be anything, e.g. JSON data. The assistance data is persisted once set.

Geocode

Geo-code address lookup.

Geocode will use the system's native Geocode API or fallback to contacting the MOVE backend to attempt a geo-lookup.

Future<GeocodeResult> geocode(double latitude, double longitude) async

Returns an object of type MoveGeocodeResult with either the Address as a result string, or a MoveGeocodeError.

class MoveGeocodeResult {
  String? result;
  MoveGeocodeError? error;
}

Throttle: Geocode is limited to a maximum of 100 lookups per hour.

The native API may have its own throttling and maybe used up for the app calling this function.

Set Remote Config Change Listener

Since MOVE SDK v2.5

Provide a block to be invoked every time MoveConfig was successfully fetched from the server.

Stream<MoveConfig> setRemoteConfigChangeListener() async*

Device Discovery

Scanning Devices

Start scanning for devices which can be registered on the SDK for trip device discovery. A block will get invoked each time new devices are found.

Stream<List<MoveDevice>> startScanningDevices(
      {List<MoveDeviceFilter> filter = const [MoveDeviceFilter.paired],
      String? uuid,
      int? manufacturerId}) async*

Opens a stream which will receive a list of new unique devices scanned. Device scanning will be stopped when the stream is closed.

A list of filters can be specified to filter which devices to scan for:

Set MoveDevice Connection State Listener

Since MOVE SDK v2.10.0

Set a MoveDevice connection state listener to be fired when the Bluetooth connection state of a previously registered MoveDevice has changed.

Stream<List<MoveDevice>> setDeviceStateListener() async*

Get Registered Devices

Get a list of devices (MoveDevice) registered to be discovered during trips.

Future<List<MoveDevice>> getRegisteredDevices() async

Register Devices

Register devices (MoveDevice) to be discovered during trips.

Future<void> registerDevices(List<MoveDevice> devices) async

Unregister Devices

Unregister devices (MoveDevice) to be discovered during trips.

Future<void> unregisterDevices(List<MoveDevice> devices) async

Discover Devices

Stream<List<MoveScanResult>> setDeviceDiscoveryListener() async*

Opens a stream to receive updates when devices are scanned for during trips. See MoveScanResult.

Last updated