# MoveSDKState

Represent the different SDK States.

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

```kotlin
sealed class MoveSdkState {
    Uninitialised()
    Ready()
    Running()
    Error(reason: MoveStateError)
}


MoveStateError { 
    LocationPermissionMissing
    PhonePermissionMissing
    OverlayPermissionMissing
    MotionPermissionMissing;
    
    fun resolved()
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
enum MoveSDKState {
    case unintialized
    case ready
    case running
    case error(StateError)
 
    enum StateError {
        case locationPermissionMissing
        case locationPrecisionPermissionMissing
        case motionPermissionMissing
        case sensorsInvalid
    }
}
```

{% endtab %}

{% tab title="React Native" %}

```javascript
export type SdkState = 'error' | 'uninitialized' | 'ready' | 'running';
```

{% endtab %}
{% endtabs %}

| **MoveState**         |                                                                                                                                                                                                                                                                                                        |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| uninitialized         | The SDK is not initialized.                                                                                                                                                                                                                                                                            |
| ready                 | The SDK is initialized and ready to start services. Transited to this state on successful initialization and when services didn't start.                                                                                                                                                               |
| running               | The SDK is running its services. Transited to this state after calling startAutomaticDetection() (in [Android](/move-platform/move-sdk-1.x/sdk/api-interface/android-1/android.md#start-automatic-detection) / [iOS](/move-platform/move-sdk-1.x/sdk/api-interface/ios.md#start-automatic-detection)). |
| error(MoveStateError) | The SDK is in an error state. Transited to this state in cases of error.                                                                                                                                                                                                                               |

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

| **MoveStateError**        |                                                                                                                                                                                                                                                                       |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| LocationPermissionMissing | <p>Required location permission is missing.</p><p>(<a href="https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION"><https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION></a>)</p>             |
| MotionPermissionMissing   | <p>Required activity recognition permission is missing.</p><p>(<a href="https://developer.android.com/reference/android/Manifest.permission#ACTIVITY_RECOGNITION"><https://developer.android.com/reference/android/Manifest.permission#ACTIVITY_RECOGNITION></a>)</p> |
| PhonePermissionMissing    | <p>Required phone permission is missing.</p><p>(<a href="https://developer.android.com/reference/android/Manifest.permission#READ_PHONE_STATE"><https://developer.android.com/reference/android/Manifest.permission#READ_PHONE_STATE></a>)</p>                        |
| OverlayPermissionMissing  | <p>Required system alert window permission is missing</p><p>(<a href="https://developer.android.com/reference/android/Manifest.permission#SYSTEM_ALERT_WINDOW"><https://developer.android.com/reference/android/Manifest.permission#SYSTEM_ALERT_WINDOW></a>)</p>     |

**Note:** In case of resolving an error, the SDK needs to be notified via *`resolved()`* method of the state-error object.
{% endtab %}

{% tab title="iOS" %}

| **StateError**                     |                                                    |
| ---------------------------------- | -------------------------------------------------- |
| locationPermissionMissing          | Required location permission is missing.           |
| locationPrecisionPermissionMissing | Required location precision permission is missing. |
| motionPermissionMissing            | Required motion permission is missing.             |
| sensorsInvalid                     | Required sensors are not available.                |
| {% endtab %}                       |                                                    |
| {% endtabs %}                      |                                                    |

Upon initializing the SDK, it will evaluate the system's services and required permissions (for [Android](/move-platform/move-sdk-1.x/sdk/appendix/android/permission-handling.md) / [iOS](/move-platform/move-sdk-1.x/sdk/appendix/ios/permission-handling.md)) to activate the SDK detection services requested by the host app in the passed [MoveConfig](/move-platform/move-sdk-1.x/sdk/models/moveconfig.md). The SDK is successfully ready to start its services only if all the required services are available and all the required permissions are granted. **The SDK will not transit to `.ready`** [**MoveSDKState**](/move-platform/move-sdk-1.x/sdk/models/movestate.md) **except when all its requirements are fulfilled.**

Required and optional permissions are determined based on the passed [MoveConfig](/move-platform/move-sdk-1.x/sdk/models/moveconfig.md) on initialization. Check [MoveConfig](/move-platform/move-sdk-1.x/sdk/models/moveconfig.md) and permissions handling ([Android](/move-platform/move-sdk-1.x/sdk/appendix/android/permission-handling.md) / [iOS](/move-platform/move-sdk-1.x/sdk/appendix/ios/permission-handling.md)) for more details about configurations and permission requirements.

**The host app is expected to monitor** [**MoveSDKState**](/move-platform/move-sdk-1.x/sdk/models/movestate.md) **changes via `setSDKStateListener` to handle the** [**MoveSDKState**](/move-platform/move-sdk-1.x/sdk/models/movestate.md) **transitions accordingly.**

When the SDK transits to an error state, it either will be a:

* Permission error: In this case, the host app is expected to handle this missing permission (for [Android](/move-platform/move-sdk-1.x/sdk/appendix/android/permission-handling.md) / [iOS](/move-platform/move-sdk-1.x/sdk/appendix/ios/permission-handling.md)) in its app accordingly. When the missing required permission is granted, the SDK will transit back to `.ready` [MoveSDKState](/move-platform/move-sdk-1.x/sdk/models/movestate.md) waiting to start.
* [MoveAuth](/move-platform/move-sdk-1.x/sdk/models/moveauth.md) Expired: In this case, the host app is expected to fetch a new [MoveAuth ](/move-platform/move-sdk-1.x/sdk/models/moveauth.md)from the SDK server to renew the session.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.movesdk.com/move-platform/move-sdk-1.x/sdk/models/movestate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
