Initialization

API Interface / Flutter

The MOVE SDK must be initialized natively. For the first init, the SDK expects to be setup after user onboarding using Flutter. In this case, Flutter passes the required auth code or MoveAuth, and MoveConfig objects.

In all future inits, the SDK expects to be initialized natively at app start points (MainApplication for Android). This is to guarantee that the MOVE SDK is set up and active before the limited time provided by the OS in background wakeups is consumed.

The native init will re-use the last authentication and configs objects passed to the SDK from the Flutter initialization.

import 'package:movesdk/movesdk.dart';

Setup MOVE SDK

With MoveAuth

To setup the MOVE SDK with a registered user you have to provide MoveAuth, MoveConfig:

Future<void> setup(
        MoveAuth auth,
        MoveConfig moveConfig,
        {MoveOptions? options}
)

Parameters

auth

moveConfig

options

Will be remove in future versions, use setupWithCode(...) instead.

With authCode

Alternative to the approach with the MoveAuth you can setup the MOVE SDK with an authentication string. This authCode must be fetched from the backend using the userId (see MOVE Backend - Example request).

Future<MoveAuthResult> setupWithCode(
        String authCode,
        MoveConfig moveConfig,
        {MoveOptions? options}
)

Parameters

authCode

moveConfig

options

Returns

Android

To initialize the SDK natively, in your MainApplication:

import io.dolphin.move.MoveSdk
...
class MainApplication : Application() {

    override fun onCreate() {
        super.onCreate()
        val sdk = MoveSdk.init(this)
        ...
        // you can use the native class furhter on
        // eg. sdk.allowMockLocations(true)
    }
}

For iOS the SDK is automatically initialized in the FlutterPlugin lifecycle during didFinishLaunchingWithOptions.

Notification

To use the MoveSdk in the background, it is required to configure the trip or als recognition notification, like shown in the following:

sdk.recognitionNotification(
    NotificationCompat.Builder(this, recognitionChannel)
        .setContentTitle("MOVE SDK")
        .setContentText("Trip detection")
        .setChannelId(recognitionChannel)
)

Make sure that you are also creating a notification channel. More information about notifications can be found at Notification Management.

Shutdown SDK

Shutdown SDK shared instance.

Stops SDK services, send the queued user data and de-initializes the SDK. After that is executed, the MoveSDKState will transit to .uninitialized.

Precondition: SDK must be initialized.

Future<MoveShutdownResult> shutdown({bool force = true})

Parameters

Default

force

true

If true, shutdown executes immediately. Pending Data may be lost.

Returns

Configuration services

Update authentication

Updates SDK MoveAuth. The host app was expected to fetch a new MoveAuth using its project API key and pass it to the MoveSDK using the following API:

@Deprecated('obsolete')
Future<MoveAuthError?> updateAuth(MoveAuth auth)

Deprecated: Token expiry is no longer a valid auth state forwarded to the app and does not need to be handled.

Update configuration

Updates SDK MoveConfig.

Future<void> updateConfig(MoveConfig auth)
Parameters

config

The new MoveConfig to use.

Throws

uninitialized

The SDK is in uninitialized state.

Last updated