> For the complete documentation index, see [llms.txt](https://docs.movesdk.com/move-platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.movesdk.com/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/listeners-callbacks.md).

# Listeners/Callbacks

## SDK State Listener

Triggers whenever the [MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md) changes.

{% hint style="info" %}
Set an MOVE SDK State listener using`sdkStateListener`([Android](https://docs.movesdk.com/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/pages/-MZIfp4AHvpUSOaycA60#DolphinSdk.Builderv1.1-sdkstatelistenerSdkstatelistener)/[iOS](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/api-interface/ios/services.md#set-sdk-state-listener)) API to anticipate handling the MOVE SDK State changes, start detection services when [MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md) is `.ready` or handle`.error` if occurred.
{% endhint %}

{% tabs %}
{% tab title="Android" %}

```kotlin
interface StateListener {
    fun onStateChanged(sdk: MoveSdk, state: MoveSdkState)
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
typealias MoveSDKStateCallback = (_ state: MoveSDKState) -> Void
```

{% endtab %}

{% tab title="React Native" %}

```typescript
static addTripStateListener(tripStateChanged: (state: TripState) => void): ListenerSubscription;
```

{% endtab %}
{% endtabs %}

| **Parameter**                                                                         |                                                                                               |
| ------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| [MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md) | Latest [MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md). |

## Auth State Update Listener

Triggers whenever the [MoveAuthState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveauth.md) changes.

{% hint style="warning" %}

### Authentication Expiry

The host app is expected to monitor [MoveAuthState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveauthstate.md) updates via `authStateUpdateListener` API and handle those changes accordingly.

Check [Authentication updates and expiry](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveauthstate.md#authentication-updates-and-expiry) for more details about authentication expiry and renewal.
{% endhint %}

{% tabs %}
{% tab title="Android" %}

```kotlin
interface AuthStateUpdateListener {
    fun onAuthStateUpdate(state: MoveAuthState)
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
typealias MoveAuthStateCallback = (_ state: MoveAuthState) -> Void
```

{% endtab %}

{% tab title="React Native" %}

```typescript
static addAuthStateListener(authStateChanged: (event: AuthStateEvent) => void): ListenerSubscription;
```

{% endtab %}
{% endtabs %}

| **Parameter**                                                                              |                                                                                                    |
| ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
| [MoveAuthState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveauthstate.md) | Latest [MoveAuthState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveauthstate.md). |

## Trip State Listener

Triggers whenever the [MoveTripState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movetripstate.md) changes.

{% tabs %}
{% tab title="Android" %}

```kotlin
interface TripStateListener {
    fun onTripStateChanged(sdk: MoveSdk, tripState: MoveTripState)
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
typealias MoveTripStateCallback = (_ tripState: MoveTripState) -> Void
```

{% endtab %}

{% tab title="React Native" %}

```typescript
static addTripStateListener(tripStateChanged: (state: TripState) => void): ListenerSubscription;
```

{% endtab %}
{% endtabs %}

| **Parameter**                                                                              |                                                                                                    |
| ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
| [MoveTripState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movetripstate.md) | Latest [MoveTripState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movetripstate.md). |

## Trip Metadata Provider

Triggers whenever a trip is ending, for the host app to append metadata along with that trip if needed.

{% tabs %}
{% tab title="Android" %}

```kotlin
interface TripMetadataProvider {
    fun provideMetadata(start: Long, end: Long): Map<String, String>
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
typealias MoveMetaDataCallback = (_ tripStart: Date, _ tripEnd: Date) -> [String: String]
```

{% endtab %}
{% endtabs %}

| **Parameter**   |           |                            |
| --------------- | --------- | -------------------------- |
| 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](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movedevicestatus.md) changes.

{% tabs %}
{% tab title="iOS" %}

```swift
typealias MoveDeviceStatusCallback = (_ status: MoveDeviceStatus) -> Void
```

{% endtab %}
{% endtabs %}

| **Parameter**                                                                                    |                                                                                                          |
| ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- |
| [MoveDeviceStatus](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movedevicestatus.md) | Latest [MoveDeviceStatus](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movedevicestatus.md). |

## Service Failure Callback

Triggers whenever [MoveServiceFailures](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveservicefailure.md) change.

{% tabs %}
{% tab title="Android" %}

<pre class="language-kotlin"><code class="lang-kotlin">interface MoveErrorListener {
<strong>    fun onMoveError(serviceFailures: List&#x3C;MoveServiceFailure>)
</strong>}
</code></pre>

{% endtab %}

{% tab title="iOS" %}

```swift
public typealias MoveServiceFailureCallback = (_ permissions: [MoveServiceFailure]) -> Void
```

{% endtab %}

{% tab title="React Native" %}

```typescript
static addErrorsListener(errorsReceived: (errors: ErrorListType) => void): ListenerSubscription;
```

{% endtab %}
{% endtabs %}

| **Parameter**                                                                                        |                                                                                                                |
| ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| [MoveServiceFailure](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveservicefailure.md) | List of [MoveServiceFailures](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveservicefailure.md). |

## Service Warning Callback

Triggers whenever [MoveServiceWarnings](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveservicefailure.md) change.

{% tabs %}
{% tab title="Android" %}

```kotlin
interface MoveWarningListener {
    fun onMoveWarning(serviceWarnings: List<MoveServiceWarning>)
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
public typealias MoveServiceWarningCallback = (_ permissions: [MoveServiceWarning]) -> Void
```

{% endtab %}

{% tab title="React Native" %}

```typescript
static addWarningsListener(warningsReceived: (warnings: ErrorListType) => void): ListenerSubscription;
```

{% endtab %}
{% endtabs %}

| **Parameter**                                                                                        |                                                                                                                |
| ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| [MoveServiceWarning](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveservicewarning.md) | List of [MoveServiceWarnings](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveservicewarning.md). |
|                                                                                                      |                                                                                                                |

## Initialization Listener

Represents the potential errors occurring when updating the [MoveAuth](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveauth.md).

{% tabs %}
{% tab title="Android" %}

```kotlin
interface InitializeListener {
    fun onError(error: MoveConfigurationError)
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
public typealias MoveInitializationCallback = (_ error: MoveConfigurationError) -> Void
```

{% endtab %}
{% endtabs %}

<table data-header-hidden><thead><tr><th width="130">Parameter</th><th width="216"></th><th></th></tr></thead><tbody><tr><td><strong>Parameter</strong></td><td></td><td></td></tr><tr><td>error</td><td><a href="/pages/-MaaWYf8OHiAF4kfCW1V">MoveConfigurationError</a></td><td><p>An error to notify when the configuration could </p><p>not be loaded from the server.</p></td></tr></tbody></table>

## Log Callback

Triggers whenever a new log event occurs.

{% tabs %}
{% tab title="Android" %}

```kotlin
interface MoveLogCallback {
    fun onLogReceived(eventName: String, value: String?)
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
typealias MoveLogCallback = (_ log: String, _ value: String) -> Void
```

{% endtab %}
{% endtabs %}

| **Parameter** |        |                |
| ------------- | ------ | -------------- |
| log           | String | New log event. |
| value         | String | Log value.     |
