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 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 SDK

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

Future<void> setup(MoveAuth auth, MoveConfig moveConfig)

Parameters

auth

MoveAuth object to authenticate the user with. See Move Backend section for acquiring credentials.

moveConfig

MoveConfig object to setup services.

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

Value

success

Shutdown succeeded.

uninitialized

The SDK is in uninitialized state.

networkError

If force was set to false and pending data could not be sent shutdown fails.

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