# Trip Manager

### `enableImsTripManager`

**Description**

Enable the IMS Trip Manager. Trip detection and recording do not happen until you explicitly enable it at least once. Use this method to enable trip detection, recording, and trip file upload.

**Returns**

* `Promise<any>`: A promise that resolves when the operation is complete.

Usage example:

```typescript
import { enableImsTripManager } from "ims-react-native/src";

enableImsTripManager().then((result: string) => {
        console.log(result);
      }).catch((error: Error) => {
        console.log(error.message);
    });
```

### `disableImsTripManager`

**Description**

Disable the IMS Trip Manager. Use this method to stop, such as when the user logs out.

**Returns**

* `Promise<any>`: A promise that resolves when the operation is complete.

Usage example:

```typescript
import { disableImsTripManager } from "ims-react-native/src";

disableImsTripManager().then((result: string) => {
        console.log(result);
      }).catch((error: Error) => {
        console.log(error.message);
    });
```

### `startTrip`

**Description**

Start a trip. The trip detection manager must be enabled before the trip recorder can be started or stopped programmatically. The start command has no effect if the recorder is already started (or if trip detection is disabled).

**Returns**

* `Promise<any>`: A promise that resolves when the trip starts.

Usage example:

```typescript
import { startTrip } from "ims-react-native/src";

startTrip().then((result: string) => {
        console.log(result);
      }).catch((error: Error) => {
        console.log(error.message);
    });
```

### `stopTrip`

**Description**

Stop the current trip. The trip detection manager must be enabled before the trip recorder can be started or stopped programmatically. The stop command has no effect if the recorder is not already running.

If you have specified no validator (AndroidTripValidator.PHONE and/or AndroidTripValidator.DEVICE), then, once started, the trip recorder will continue recording indefinitely until you issue the stop command. If you have specified at least one validator, trip recording will stop automatically using the validator, or when you issue the stop command, whichever comes first.

**Returns**

* `Promise<any>`: A promise that resolves when the trip stops.

Usage example:

```typescript
import { stopTrip } from "ims-react-native/src";

stopTrip().then((result: string) => {
        console.log(result);
      }).catch((error: Error) => {
        console.log(error.message);
    });
```

### `addTripStatusListenerAndroid`

**Description**

Add a listener for trip status updates on Android. The application can register a listener to be informed of important lifecycle events such as trip detection enabled, recording started, and/or failures. This can be done by adding a listener while the app is running.

**Returns**

* `Promise<any>`: A promise that resolves when the listener is added.

Usage example:

```typescript
import { addTripStatusListenerAndroid } from "ims-react-native/src";

addTripStatusListenerAndroid().then((result: string) => {
        console.log(result);
      }).catch((error: Error) => {
        console.log(error.message);
    });
```

### `removeTripStatusListenerAndroid`

**Description**

Remove the trip status listener on Android.

**Returns**

* `Promise<any>`: A promise that resolves when the listener is removed.

Usage example:

```typescript
import { removeTripStatusListenerAndroid } from "ims-react-native/src";

removeTripStatusListenerAndroid().then((result: string) => {
        console.log(result);
      }).catch((error: Error) => {
        console.log(error.message);
    });
```

### `setStatusHandlerIos`

**Description**

Set a status handler on iOS.

**Returns**

* `Promise<any>`: A promise that resolves when the status handler is set.

Usage example:

```typescript
import { setStatusHandlerIos } from "ims-react-native/src";

setStatusHandlerIos().then((result: string) => {
        console.log(result);
      }).catch((error: Error) => {
        console.log(error.message);
    });
```

### `removeStatusHandlerIos`

**Description**

Remove the status handler on iOS.

**Returns**

* `Promise<any>`: A promise that resolves when the status handler is removed.

Usage example:

```typescript
import { removeStatusHandlerIos } from "ims-react-native/src";

removeStatusHandlerIos().then((result: string) => {
        console.log(result);
      }).catch((error: Error) => {
        console.log(error.message);
    });
```

### `uploadAllTripDataIos`

**Description**

Upload all trip data on iOS, including any log files. This might be useful to call to ensure no data files or logs are lingering.

**Returns**

* `Promise<any>`: A promise that resolves when the trip data is uploaded.

Usage example:

```typescript
import { uploadAllTripDataIos } from "ims-react-native/src";

uploadAllTripDataIos().then((result: string) => {
        console.log(result);
      }).catch((error: Error) => {
        console.log(error.message);
    });
```

### `tripsToUploadIos`

**Description**

Get the amount of trips to upload on iOS.

**Returns**

* `Promise<any>`: A promise that resolves with the list of trips.

Usage example:

```typescript
import { tripsToUploadIos } from "ims-react-native/src";

tripsToUploadIos().then((result: string) => {
        console.log(result);
      }).catch((error: Error) => {
        console.log(error.message);
    });
```

### `deleteAllTripDataIos`

**Description**

Delete all persisted trip data and logs on iOS. This might be useful in the event that the user has been logged out.

**Returns**

* `Promise<any>`: A promise that resolves when the trip data is deleted.

Usage example:

```typescript
import { deleteAllTripDataIos } from "ims-react-native/src";

deleteAllTripDataIos().then((result: string) => {
        console.log(result);
      }).catch((error: Error) => {
        console.log(error.message);
    });
```

### `getFileLocationIos`

**Description**

Return file location used by the SDK on iOS.

**Returns**

* `Promise<any>`: A promise that resolves with the file location.

Usage example:

```typescript
import { getFileLocationIos } from "ims-react-native/src";

getFileLocationIos().then((result: string) => {
        console.log(result);
      }).catch((error: Error) => {
        console.log(error.message);
    });
```


---

# 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://sdk.ims.tech/readme/other-platforms/react-native/using-the-sdk/trip-manager.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.
