# 1. iOS Checklist

{% hint style="danger" %}
This document refers to deprecated parts of the platform and has been left intact to help customers with legacy integrations. In order to access the latest platform features and documentation, please go to <https://docs.sentiance.com>.
{% endhint %}

Follow the step below to integrate the iOS SDK.

### 1. Installation

<details>

<summary>1.1 Dependency</summary>

Include the following lines in your *Podfile*

```
platform :ios, '9.0'
pod 'SENTSDK'
```

And run the command

```
pod install --repo-update
```

*If you are using Carthage instead,* [*click here*](https://legacy-docs.sentiance.com/sdk/getting-started/ios-sdk/1.-installation/installation-with-carthage)\_\_

</details>

### 2. Configuration

<details>

<summary>2.2 Background Modes</summary>

Ensure you turn on **Background Modes** and enable **Location updates**

</details>

{% hint style="info" %}
If you are going to use the Step Counter feature, you will need to set the [registerBackgroundIdentifiers](https://legacy-docs.sentiance.com/api-reference/ios/sentconfig-1#registerbackgroundtaskidentifiers) property to YES, and enable **Background Fetch** in the capabilities \*\*\*\* and add a key to the app's plist\*\*:\*\* `BGTaskSchedulerPermittedIdentifiers` with an array item `com.sentiance.backgroundtask.step_counter`
{% endhint %}

<details>

<summary>2.3 Permissions</summary>

Ensure you include the following permission in *info.plist*

```
NSLocationAlwaysAndWhenInUseUsageDescription
NSMotionUsageDescription (Recommended)
```

</details>

### 3. Usage

<details>

<summary>3.1 SentianceHelper.swift</summary>

For a quick start we have created helper file a couple of methods to easily get started. [Download this file](https://github.com/sentiance/sample-apps-ios/blob/master/sample_app_ios/Helpers/SentianceHelper.swift) and place it anywhere accessible in your codebase.

</details>

<details>

<summary>3.2 Initialization &#x26; Background Collection</summary>

Insert the following line in your AppDelegate.swift file and in the *didFinishLaunchingWithOptions* method\_.\_ This line ensures that the SDK is initialized and can collect data while the application is in the background.

```
# AppDelegate.swift

SentianceHelper.initSdk()
```

[See reference](https://github.com/sentiance/sample-apps-ios/blob/master/sample_app_ios/AppDelegate.swift#L13)

</details>

### 4. Data Collection & SDK User Creation

In order for the SDK to collect data the application would need to first "create a user" on the SDK. The "createUser" should ideally be called when the user registers, logs in.

#### 4.2 Standard

<details>

<summary>4.1 createUser</summary>

Invoke the *SentianceHelper.createUser* method at the moment you are ready to start the data collection. (e.g on user login, on user registration, at a feature, etc)

note: Do not forget to Include your "linkFunction"

```swift
SentianceHelper.createUser(SentianceHelper.SDKParams(
   appId: <APP ID>,
   appSecret: <APP SECRET>,
   baseUrl: "https://api.sentiance.com",
   link: linkFunction,
   initCb: { }
))
```

[See reference](#3.-usage)

</details>

<details>

<summary>4.2 linkFunction</summary>

This function is expected to communicate/pass the **installId** (fetched from the SDK) to your backend

Note: This method will receive the parameters: `installId, linkSuccess, linkFailure`

[See reference](https://github.com/sentiance/sample-apps-ios/blob/master/sample_app_ios/Controllers/HomeViewController.swift#L21)

</details>

<details>

<summary>4.3 User linking in your backend</summary>

Create an endpoint on your backend which will communicate with the Sentiance backend and request an installId to be linked to a particular user (in your database)

[See reference](https://github.com/sentiance/sample-apps-api/blob/master/src/routes.js#L61)

</details>

<details>

<summary>4.4 linkFunction -> linkSuccess()</summary>

Upon your backend successfully performing the user linking execute the

```
linkSucess()
```

method received as a parameter to you `linkFunction`

</details>

### Verifying the Integration

You can verify the SDK integration by reading the following statuses from the SDK

| SENTSDK.sharedInstance().getInitState()             | **INITIALIZED** |
| --------------------------------------------------- | --------------- |
| SENTSDK.sharedInstance().getSdkStatus().startStatus | **STARTED**     |

*Note: If you find the **startStatus** to be **PENDING** it usually implies that the user has not granted **location:always** permission. To know more,* [*click here*](https://docs.sentiance.com/sdk/api-reference/android/sdkstatus/startstatus)\_\_

You can continue reading through the next sections to get a deeper understanding of the integration and the SDK capabilities.
