> 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/sdk/api-interface/ios/setup.md).

# Setup

Before services can be started a user object must be setup to use the SDK and a services configuration must be provided (see [iOS Quick Start](/move-platform/sdk/getting-started/ios/quick-start.md)).

### Setup Auth/Config

Authenticates a user to be used with the SDK.

{% tabs %}
{% tab title="Swift 5" %}

```swift
func setup(authCode: String, config: MoveConfig, options: MoveOptions, callback: @escaping MoveAuthCallback)
```

{% endtab %}

{% tab title="Swift 6" %}

```swift
func setup(authCode: String, config: MoveConfig, options: MoveOptions) async -> MoveAuthResult
```

{% endtab %}
{% endtabs %}

| **Parameters** |                                                                             |                                 |
| -------------- | --------------------------------------------------------------------------- | ------------------------------- |
| authCode       | String                                                                      | Auth code.                      |
| config         | [MoveConfig](/move-platform/sdk/models/moveconfig.md#ios)                   | Move services configuration.    |
| options        | [MoveOptions](/move-platform/sdk/models/moveoptions.md#ios)                 | Move SDK service options dict.  |
| callback       | [MoveAuthCallback](/move-platform/sdk/models/listeners-callbacks.md#ios-12) | Called after setup with result. |

Setup with auth tokens:

```swift
func setup(auth: MoveAuth, config: MoveConfig, options: MoveOptions)
```

| **Parameters** |                                                             |                                |
| -------------- | ----------------------------------------------------------- | ------------------------------ |
| auth           | [MoveAuth](/move-platform/sdk/models/moveauth.md#ios)       | User account object.           |
| config         | [MoveConfig](/move-platform/sdk/models/moveconfig.md#ios)   | Move services configuration.   |
| options        | [MoveOptions](/move-platform/sdk/models/moveoptions.md#ios) | Move SDK service options dict. |

{% hint style="warning" %}
Deprecated, use [setup(authCode: ...)](#setup-auth-config) instead
{% endhint %}

### Update Config

Change the config originally passed in setup.

```swift
func update(config: MoveConfig, options: MoveOptions? = nil)
```

| Parameters |                                                             |                                |
| ---------- | ----------------------------------------------------------- | ------------------------------ |
| config     | [MoveConfig](/move-platform/sdk/models/moveconfig.md#ios)   | Move services configuration.   |
| options    | [MoveOptions](/move-platform/sdk/models/moveoptions.md#ios) | Move SDK service options dict. |

Occasionally this functionality is needed for deployed apps when a projects configuration is updated on the backend.

{% hint style="warning" %}
**Precondition:** SDK user/config should be setup.
{% endhint %}

### Update authentication

Updates SDK [MoveAuth](/move-platform/sdk/models/moveauth.md). The host app was expected to fetch a new [MoveAuth](/move-platform/sdk/models/moveauth.md) using its project API key and pass it to the MoveSDK using the following API:

```swift
func update(auth: MoveAuth, completion: ((MoveAuthError?) -> Void)? = nil)
```

{% hint style="danger" %}
**Deprecated:** Token expiry is no longer a valid auth state forwarded to the app and does not need to be handled.
{% endhint %}

### **Get SDK Auth State**

Gets the current [MoveAuthState](/move-platform/sdk/models/moveauthstate.md).

```swift
func getAuthState() -> MoveAuthState
```

| **Return**                                                  |                  |
| ----------------------------------------------------------- | ---------------- |
| [MoveAuthState](/move-platform/sdk/models/moveauthstate.md) | Latest SDK State |

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

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

{% tabs %}
{% tab title="Swift 5" %}

```swift
func setAuthStateUpdateListener(_ listener: @@escaping AuthStateCallback)
```

{% endtab %}

{% tab title="Swift 6" %}

```swift
func setAuthStateUpdateListener(_ listener: @escaping AsyncMoveAuthStateCallback)
```

{% endtab %}
{% endtabs %}

| **Callback**                                                                                     |                                                                                                            |
| ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------- |
| [AuthStateCallback](/move-platform/sdk/models/listeners-callbacks.md#auth-state-update-listener) | Block that gets invoked every time [MoveAuthState](/move-platform/sdk/models/moveauthstate.md) is updated. |

{% hint style="warning" %}

### Authentication Expiry

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

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

### **Set SDK Initialization Listener**

Provide a block to be invoked when configuration fetch failed.

```swift
func setInitializationListener(_ listener: @escaping MoveInitializationCallback)
```

| **Callback** |                                                                                    |
| ------------ | ---------------------------------------------------------------------------------- |
|              | Block that gets invoked every time **configuration** fetch from the server failed. |

{% hint style="warning" %}
Deprecated. Not needed when setting up with an auth token.
{% endhint %}

### Shutdown

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/sdk/models/movesdkstate.md) will transit to `.uninitialized`.

{% tabs %}
{% tab title="Swift 5" %}

```swift
func shutDown(force: Bool, _ callback: ((MoveShutdownResult) -> Void)?)
```

{% endtab %}

{% tab title="Swift 6" %}

```swift
func shutDown(force: Bool = true) async -> MoveShutdownResult
```

{% endtab %}
{% endtabs %}

<table data-header-hidden><thead><tr><th width="139">Callback</th><th width="90"></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><tr><td>callback</td><td>nil</td><td>Returns a <a href="/pages/8oQEwj2v8SSKn1ib9gng#ios">MoveShutdownResult</a> upon completion. May fail if not forced.</td></tr></tbody></table>

{% hint style="warning" %}
**Precondition:** SDK user/config should be setup.
{% endhint %}


---

# 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/sdk/api-interface/ios/setup.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.
