> 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/api-interface/react-native/services.md).

# Services

```javascript
import MoveSdk from 'react-native-move-sdk';
```

## **Detection Services**

### **Start Automatic Detection**

Starts the required detection services stated in the [MoveConfig](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveconfig.md) passed on initialization. Starting the service will set the [MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md) to `.running`.

```javascript
MoveSdk.startAutomaticDetection(): void
```

### **Stop Automatic Detection**

Stops the automatic detection service, including all SDK services like driving detection, points of interest, walking and places. Stopping the service will set the [MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md) back to `.ready`.&#x20;

```javascript
MoveSdk.stopAutomaticDetection(): void
```

### **Force Trip Recognition**

Temporarily calibrates the SDK to the highest detection mode.

In order to optimize battery consumption, the SDK goes through different detection modes with different battery consumption levels, depending on the user's current behavior and activity. In general, the SDK is responsible for alternating between those different detection modes.&#x20;

The SDK also provides hosting apps this API to call if they have their own reasons (like buttons, sensors or beacons) to believe that the user is starting a trip. This will make sure the SDK is on the highest detection state to detect the trip faster.

```javascript
MoveSdk.forceTripRecognition(): void
```

### **Finish Current Trip**

Ends the current ongoing trip.

This API will end the ongoing trip and set [MoveTripState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movetripstate.md) back to `.idle`. The SDK is responsible for detecting the trip start and end points. The SDK also provides hosting apps this API to call if they have their own reasons (like sensors or beacons) to believe that the user's trip has ended.

{% hint style="warning" %}
**Precondition**:[ MoveTripState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movetripstate.md) should be in an active trip.
{% endhint %}

```javascript
MoveSdk.finishCurrentTrip(): void
```

{% hint style="info" %}
If this API is called while the user is active on a driving trip, a new trip will start again right away. If the intention is to un-track the ongoing trip, call `ignoreCurrentTrip`API.

More information about trip states can be found in [MoveTripState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movetripstate.md).
{% endhint %}

### **Ignore Current Trip**

Ignores the current ongoing trip.&#x20;

This API will set the ongoing [MoveTripState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movetripstate.md) to `.ignored`. Data of ignored trips is purged and not sent to the server.

{% hint style="warning" %}
**Precondition**: [MoveTripState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movetripstate.md) should be in an active trip.
{% endhint %}

```javascript
MoveSdk.ignoreCurrentTrip(): void
```

## Processing Services

### **Keep in foreground (Android only)**

When an Android application is in the background it may receive limited data (location, sensors, etc.). To improve this behavior, it is possible to put the application always in the foreground with a visible notification that cannot be discarded. Just because it's visible it doesn't mean that it is performing any data collection at all. So this should not have any significant battery impact at all.

{% hint style="info" %}
Disabled by default. Since it may be annoying to the user, it should only be enabled in case of problems.
{% endhint %}

```javascript
MoveSdk.keepInForeground(enabled: boolean): void
```

### **Keep active (Android only)**

To save battery consumption, the SDK is using several triggers to start its data listeners. In case of trouble, these triggers can be circumvented by allowing the MoveSdk to stay active all the time. In that case the SDK is always monitoring required data and is therefore consuming more battery. Depending on the configuration, it may happen that the notification (see[ notification handling](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/appendix/android/notification-managment.md)) is always visible to the user.

{% hint style="info" %}
Disabled by default. Since this is consuming more battery, it should only be enabled in case of problems.
{% endhint %}

```javascript
MoveSdk.keepActive(enabled: boolean): void
```

### **Get SDK State**

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

```javascript
MoveSdk.getState(): Promise<SdkState>
```

### Get Trip State

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

```javascript
MoveSdk.getTripState(): Promise<TripState>
```

### Get Auth State

Get the current [MoveAuthState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveauthstate.md).

```javascript
MoveSdk.getAuthState(): Promise<AuthState>
```

### **Set SDK State Listener**

Provide a block to be invoked every time [MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md) changes.

{% hint style="info" %}
Set the [MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md) listener before initializing the SDK to anticipate the SDK [State](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md) changes triggered by the initialization API. \
Here the host app can start the SDK services when [MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md) is`.ready`or handle errors if occurred.
{% endhint %}

```javascript
MoveSdk.addSdkStateListener(sdkStateChanged: (state: SdkState) => void): ListenerSubscription;
```

| **Callback**    |                                                                                                                                                                                                                                                      |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| sdkStateChanged | Block that gets invoked every time[ MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md) is changed and provides the updated [ MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md). |

### **Set SDK Auth State Listener**

Provide a block to be invoked every time [MoveAuthState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveauthstate.md) changes.

```javascript
MoveSdk.addAuthStateListener(authStateChanged: (event: AuthStateEvent) => void): ListenerSubscription;
```

| **Callback**     |                                                                                                                                           |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| authStateChanged | Block that gets invoked every time [MoveAuthState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveauthstate.md) is updated. |

{% hint style="warning" %}

### Authentication Expiry

The host app is expected to monitor [MoveAuthState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveauthstate.md) updates via`authStateUpdateListene` 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 %}

### **Set Trip State Listener**

Provide a block to be invoked every time [MoveTripState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movetripstate.md) changes.

```javascript
MoveSdk.addTripStateListener(tripStateChanged: (state: TripState) => void): ListenerSubscription;
```

| Callback         |                                                                                                                                                                                                                                                                 |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tripStateChanged | Block that gets invoked every time  [MoveTripState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movetripstate.md) is changed and provides the updated  [MoveTripState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movetripstate.md). |

## Set Errors Listener

Provide a block to be invoked every time [MoveServiceFailure](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveservicefailure.md) changes.

```javascript
MoveSdk.addErrorsListener(errorsReceived: (errors: ErrorListType) => void): ListenerSubscription;
```

## Set Warnings Listener

Provide a block to be invoked every time [MoveServiceWarning](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveservicewarning.md) changes.

```javascript
MoveSdk.addWarningsListener(warningsReceived: (warnings: ErrorListType) => void): ListenerSubscription;
```

### **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](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md) will transit to `.uninitialized`.

{% hint style="warning" %}
**Precondition:** SDK must be initialized.
{% endhint %}

```javascript
MoveSdk.shutdown(force:boolean = true): Promise<ShutdownReturnType>
```

<table data-header-hidden><thead><tr><th width="196.66666666666669"></th><th width="137"></th><th></th></tr></thead><tbody><tr><td><strong>Parameters</strong></td><td><strong>Default</strong></td><td></td></tr><tr><td>force</td><td>true</td><td>If true, <em>shutdown</em> executes immediately. Pending Data may be lost.</td></tr></tbody></table>

### Resolve Error

```typescript
MoveSdk.resolveError(): void
```

### **Synchronize User Data**

Used to force synchronizing user data with the SDK server. Limited to once per 2 minutes.

```javascript
MoveSdk.synchronizeUserData(): void
```

## Other Services

### Initiate Assistance Call

*New feature in MOVE SDK 2.x; configuration in MOVE dashboard pending - please get in touch.*

Initiate an assistance call to emergency services.

```typescript
MoveSdk.initiateAssistanceCall(): Promise<boolean>
```

Returns a promise with a [MoveAssistanceCallStatus](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveassistancecallstatus.md#android).

{% hint style="warning" %}
**Precondition:** The assistance call service needs to be configured in the MOVE dashboard. The SDK needs to be in *ready* or *running* state.
{% endhint %}

### Set Assistance MetaData

*New feature in MOVE SDK 2.1*

```typescript
MoveSdk.setAssistanceMetaData(data: string): void
```

<table><thead><tr><th width="281.3333333333333"></th><th width="176"></th><th></th></tr></thead><tbody><tr><td><strong>Parameters</strong></td><td></td><td></td></tr><tr><td><pre><code>data
</code></pre></td><td>String</td><td>A string to be sent with each assistance call or impact</td></tr></tbody></table>

The metadata string is set once, and then sent to the server with each and every manual assistance call and with AID report. The contents of the string can be anything, e.g. JSON data. The assistance data is persisted once set.

## Configuration services

### Update authentication

Updates SDK [MoveAuth](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveauth.md). On SDK auth expiry, the authStateListener will trigger expired state. The host app is expected to fetch a new [MoveAuth](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveauth.md) using its project API key and pass it to the MoveSDK using the following API:

```jsx
MoveSdk.updateAuth(auth: MoveSdkAuth): Promise<void>
```

<table><thead><tr><th width="186.4285714285714">Parameters</th><th width="150"> </th></tr></thead><tbody><tr><td>auth</td><td>The user's updated Auth object with the new token.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/~/changes/1lLi1pFRKkteajbXv0hC/sdk/api-interface/react-native/services.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.
