> 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/ios/services.md).

# Services

**Shared Instance**

Use the shared instance as your interface to the MOVE SDK.

```swift
static let shared: MoveSDK
```

## **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`.

{% hint style="warning" %}
**Precondition**: SDK must be in`.ready`[MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md)
{% endhint %}

```swift
func startAutomaticDetection()
```

### **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;

{% hint style="warning" %}
**Precondition**: SDK must be in`.running`[MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md).
{% endhint %}

```swift
func stopAutomaticDetection()
```

### **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.

{% hint style="warning" %}
&#x20;**Precondition**: SDK must be in`.running` [MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md).
{% endhint %}

```swift
func forceTripRecognition()
```

### **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 %}

```swift
func finishCurrentTrip()
```

{% 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 %}

```swift
func ignoreCurrentTrip()
```

## Processing Services

### **Get SDK State**

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

```swift
func getSDKState() -> MoveSDKState
```

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

### **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.`
{% endhint %}

```swift
func setSDKStateListener(_ listener: SDKStateCallback)
```

| **Callback**                                                                                                           |                                                                                                                                                                                                                                                      |
| ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [SDKStateCallback](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/listeners-callbacks.md#sdk-state-listener) | 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). |

### **Get Trip State**

&#x20;Gets the current [MoveTripState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movetripstate.md).

```swift
func getTripState() -> MoveTripState
```

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

### **Set Trip State Listener**

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

```swift
func setTripStateListener(_ listener: TripStateCallback)
```

| Callback                                                                                                                 |                                                                                                                                                                                                                                                                 |
| ------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [TripStateCallback](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/listeners-callbacks.md#trip-state-listener) | 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). |

### Get Device Status

Gets the current [MoveDeviceStatus](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movedevicestatus.md)*.*

```swift
func getDeviceStatus() -> MoveDeviceStatus
```

| Return                                                                                           |                                                                                                          |
| ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- |
| [MoveDeviceStatus](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movedevicestatus.md) | Current [MoveDeviceStatus](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movedevicestatus.md) |

### Get Service Failures

Gets the current [MoveServiceFailures](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveservicefailure.md#ios).

```swift
func getServiceFailures() -> [MoveServiceFailure]
```

| Return                                                                                                           |                            |
| ---------------------------------------------------------------------------------------------------------------- | -------------------------- |
| List of [MoveServiceFailure](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveservicefailure.md#ios) | A list of failed services. |

### Set Service Failure Listener

```swift
func setServiceFailureListener(_ listener: @escaping MoveServiceFailureCallback)
```

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

| Callback                                                                                                            |                                                             |
| ------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| [MoveServiceFailureCallback](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/listeners-callbacks.md#ios-6) | Block that gets invoked when service failure state changes. |

### Get Service Warnings

Gets the current [MoveServiceWarnings](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveservicewarning.md#ios).

```swift
func getServiceWarnings() -> [MoveServiceWarning]
```

| Return                                                                                                             |                                       |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------- |
| List of [MoveServiceWarnings](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveservicewarning.md#ios). | A list of partially working services. |

### Set Service Warning Listener

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

```swift
func setServiceWarningListener(_ listener: @escaping MoveServiceWarningCallback)
```

| Callback                                                                                                            |                                                       |
| ------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| [MoveServiceWarningCallback](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/listeners-callbacks.md#ios-7) | Block that gets invoked when service warnings change. |

### **Set Metadata Listener**

Provide a block returning bundle of key-value pairs to be appended to the trip metadata before the trip finishes.

Host apps can use this API to add any app-level information (for ex. Bluetooth beacon detected, foreground/background time, etc) to append to a trip as metadata. This metadata will be forwarded back along with the trip when fetched by the client-server, so the host app can utilize it in its app. Note: The SDK will not use this metadata element in any way, it is just passed through to the project environment.

The block provides the trip's start and stop times. Make sure to only include metadata events that are relevant for the given start and end periods.

```swift
func setTripMetaDataListener(_ listener: MetaDataCallback)
```

| **Callback**                                                                                                               |                                                                                                   |
| -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [MetaDataCallback](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/listeners-callbacks.md#trip-metadata-provider) | Block that gets invoked on every trip finish. The block provides the trip's start and stop times. |

**Usage Example**

```swift
MoveSDK.shared.setMetadataListener{ (tripStartTime, tripEndTime) in
    getCollectedMetadataForPeriod(start: tripStartTime, end: tripEndTime)
}
```

### **Set Log Listener**

Provide a block to be invoked every time a new SDK log event occurs.

```swift
func setLogListener(_ listener: LogCallback)
```

### **Set Console Logging State** <a href="#set-log-listener" id="set-log-listener"></a>

Toggles console logging enabled state.

This doesn't affect recieving the logs via  `setLogListener(_ listener: MoveLogCallback)` API.

Enabled by default.

```swift
func setConsoleLogging(enabled: Bool) 
```

| **Parameter** |                                                          |
| ------------- | -------------------------------------------------------- |
| enabled       | Boolean that sets SDK console logging to enabled or not. |

### Geocoding

Geo-coordinate address lookup.

```swift
func geocode(latitude: Double, longitude: Double, completion: @escaping (Result<String, MoveGeocodeError>) -> Void)
```

<table data-header-hidden><thead><tr><th width="177"></th><th></th></tr></thead><tbody><tr><td><strong>Parameter</strong></td><td></td></tr><tr><td>latitude</td><td>Geo-coordinate latitude</td></tr><tr><td>longitude</td><td>Geo-coordinate longitude</td></tr><tr><td>completion</td><td>Callback that returns a <em>Result</em> with an address S<em>tring</em> or a <a href="/pages/Wj4MyiWNuZprGeMEmXPA#ios">MoveGeocodeError</a></td></tr></tbody></table>

Geocode will use Apple's builtin *CLGeocoder.reverseGeocodeLocation* or fallback to contacting the MOVE backend to attempt a geo-lookup.

{% hint style="warning" %}
**Throttle:** *Geocode* is limited to a maximum of 100 lookups per hour.

*CLGeocoder.reverseGeocodeLocation* has its own throttling and maybe used up for the app calling this function.
{% endhint %}

### **Delete Local Data**

Deletes all the collected user SDK data stored on the device. This doesn't affect the [MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md).

{% hint style="warning" %}
**Precondition:** [MoveSDKState](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/movestate.md) should be initialized.
{% endhint %}

```swift
func deleteLocalData()
```

### **Synchronize User Data**

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

```swift
func synchronizeUserData()
```

Returns FALSE in case there are Timeline-relevant packages in the queue that remain to be sent to the SDK Backend; and it returns TRUE in case the queue is empty.

## 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.

```swift
func initiateAssistanceCall(_ completionHandler: @escaping (MoveAssistanceCallStatus) -> Void)
```

| **Parameters**    |                                                                                                                                              |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| completionHandler | A callback returning a [MoveAssistanceCallStatus](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/models/moveassistancecallstatus.md#ios). |

The application should process the callback status and inform the user in case of failure.

{% 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*

```swift
func setAssistanceMetaData(_ metadata: String)
```

| **Parameters** |                                                         |
| -------------- | ------------------------------------------------------- |
| metadata       | A string to be sent with each assistance call or impact |

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

### Get Device Qualifier

*New feature in MOVE SDK 2.2*

Get a unique qualifier to identify the individual device.

```swift
func getDeviceQualifier() -> String
```

The device qualifier should be passed to the backend during user registration and user token update. See [Move backend](/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/backend/move-swagger.md).


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.movesdk.com/move-platform/~/changes/1lLi1pFRKkteajbXv0hC/sdk/api-interface/ios/services.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
