Listeners/Callbacks
MOVE Models
SDK State Listener
Triggers whenever the MoveSDKState changes.
For android platform it is necessary to start listen explicitly by calling:
if (Platform.OS === 'android') {
MoveSdk.startNativeSdkStateListener();
}interface StateListener {
fun onStateChanged(sdk: MoveSdk, state: MoveSdkState)
}typealias MoveSDKStateCallback = (_ state: MoveSDKState) -> Voidstatic addSdkStateListener(sdkStateChanged: (state: SdkState) => void): ListenerSubscription;Stream<MoveState>Parameter
Latest MoveSDKState.
Auth State Update Listener
Triggers whenever the MoveAuthState changes.
Authentication Expiry
The host app is expected to monitor MoveAuthState updates via authStateUpdateListener API and handle those changes accordingly.
Check Authentication updates and expiry for more details about authentication expiry and renewal.
interface AuthStateUpdateListener {
fun onAuthStateUpdate(state: MoveAuthState)
}typealias MoveAuthStateCallback = (_ state: MoveAuthState) -> Voidstatic addAuthStateListener(authStateChanged: (event: AuthStateEvent) => void): ListenerSubscription;Stream<MoveAuthState>Parameter
Latest MoveAuthState.
Trip State Listener
Triggers whenever the MoveTripState changes.
interface TripStateListener {
fun onTripStateChanged(sdk: MoveSdk, tripState: MoveTripState)
}typealias MoveTripStateCallback = (_ tripState: MoveTripState) -> Voidstatic addTripStateListener(tripStateChanged: (state: TripState) => void): ListenerSubscription;Stream<MoveTripState>Parameter
Latest MoveTripState.
Trip Start Listener
Triggers whenever a trip actually starts.
interface TripStartListener {
fun onTripStarted(startDate: Date)
}typealias MoveTripStartCallback = (_ startDate: Date) -> VoidMoveSdk.addTripStartListener(tripStartTriggered: (start: Date) => void): ListenerSubscription;Parameter
Date
The actual start time of the trip.
Trip Metadata Provider
This triggers whenever a trip is ending, allowing the host app to append metadata along with that trip if needed.
interface TripMetadataProvider {
fun provideMetadata(start: Long, end: Long): Map<String, String>
}typealias MoveMetaDataCallback = (_ tripStart: Date, _ tripEnd: Date) -> [String: String]Parameter
Type
start / tripStart
Long / Date
Trip start timestamp / date.
end / tripEnd
Long / Date
Trip end timestamp / date.
Return
A String dictionary of the trip's metadata.
Device Status Callback
Triggers whenever MoveDeviceStatus changes. MoveDeviceStatus represents the current device's system permissions (for Android / iOS) and services status.
typealias MoveDeviceStatusCallback = (_ status: MoveDeviceStatus) -> VoidParameter
Latest MoveDeviceStatus.
Service Failure Callback
Triggers whenever MoveServiceFailures change.
interface MoveErrorListener {
fun onMoveError(serviceFailures: List<MoveServiceFailure>)
}public typealias MoveServiceFailureCallback = (_ permissions: [MoveServiceFailure]) -> Voidstatic addErrorsListener(errorsReceived: (errors: ErrorListType) => void): ListenerSubscription;Stream<List<MoveServiceError>>Parameter
Service Warning Callback
Triggers whenever MoveServiceWarnings change.
interface MoveWarningListener {
fun onMoveWarning(serviceWarnings: List<MoveServiceWarning>)
}public typealias MoveServiceWarningCallback = (_ permissions: [MoveServiceWarning]) -> Voidstatic addWarningsListener(warningsReceived: (warnings: ErrorListType) => void): ListenerSubscription;Stream<List<MoveServiceWarning>>Initialization Listener
Represents the potential errors occurring when updating the MoveAuth.
interface InitializeListener {
fun onError(error: MoveConfigurationError)
}public typealias MoveInitializationCallback = (_ error: MoveConfigurationError) -> VoidParameter
Type
error
An error to notify when the configuration could
not be loaded from the server.
Log Callback
Triggers whenever a new log event occurs.
interface MoveLogCallback {
fun onLogReceived(eventName: String, value: String?)
}typealias MoveLogCallback = (_ log: String, _ value: String) -> Voidstatic addLogListener(logReceived: (event: MoveSdkLog) => void): ListenerSubscription;
export type MoveSdkLog = {
message: string;
value?: string;
};Parameter
Type
log
String
New log event.
value
String
Log value. Optional
The SDK will trigger log messages to improve debugging.
Remote Config Change Listener
Will be triggered when the MoveConfig was successfully fetched from the server via updateConfig (Android) / update (iOS).
If the MoveConfig object couldn't be fetched from the server then a MoveConfigurationError ServiceUnreachable will be triggered.
interface RemoteConfigChangeListener {
fun onConfigChanged(config: MoveConfig)
}typealias MoveRemoteConfigChangeCallback = (_ config: MoveConfig) -> Voidstatic addConfigChange(warningsReceived: (warnings: ErrorListType) => void): ListenerSubscriptionstatic addRemoteConfigChangeListener(configChangeReceived: (config: Array<IssueListService>) => void): ListenerSubscriptionStream<MoveConfig>Setup Authorization Callback
Will return the success or failure of the internal MOVE SDK authentication process during setup. (also see MoveAuthResult)
interface MoveAuthCallback {
fun onResult(result: MoveAuthResult)
}typealias MoveAuthCallback = (_ result: MoveAuthResult) -> Voidobject : MoveSdk.MoveAuthCallback {
override fun onResult(authResult: MoveAuthResult) {
uiThreadHandler.post {
...
when (authResult.status) {
AuthSetupStatus.SUCCESS -> result.success("success")
AuthSetupStatus.INVALID_CODE -> // e.g. result.error(...)
AuthSetupStatus.NETWORK_ERROR -> // e.g. result.error(...)
}
}
}
}Device Discovery Listener
Will be triggered during a BDD - Device Discovery scan.
interface DeviceDiscoveryListener {
fun onScanResult(results: List<MoveScanResult)
}typealias MoveDeviceDiscoveryCallback = (_ results: [MoveScanResult]) -> Voidstatic addDeviceDiscoveryListener(onScanResult: (state: Array<MoveScanResult>) => void): ListenerSubscriptionStream<List<MoveScanResult>>Parameter
results
List of MoveScanResult's
MoveDevice State Listener / Callback
Will be triggered when the status of a registered MoveDevice changes. This MoveDevice must be previously registered. See chapters "Register Device" (Android, iOS)
interface MoveDeviceStateListener {
fun onStateChanged(device: MoveDevice)
}public typealias MoveDeviceStateCallback = (_ results: [MoveDevice]) -> Voidstatic addDeviceStateListener(onScanResult: (results: Array<MoveSdkDevice>) => void): ListenerSubscriptionStream<List<MoveDevice>>SDK Health Listener / Callback
Will be triggered when the health score of the MOVE SDK changes. A MoveHealthItem (iOS, React Native) / MoveHealthScore (Android) with the current data is provided.
interface MoveHealthScoreListener {
fun onMoveHealthScoreChanged(score: MoveHealthScore)
}public typealias MoveHealthScoreCallback = (_ result: [MoveHealthItem]) -> Voidstatic addHealthListener(scoreReceived: (health: MoveHealthScore) => void): ListenerSubscriptionStream<List<MoveHealthItem>>Last updated