1. iOS Checklist

triangle-exclamation

Follow the step below to integrate the iOS SDK.

1. Installation

chevron-right1.1 Dependencyhashtag

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__

2. Configuration

chevron-right2.2 Background Modeshashtag

Ensure you turn on Background Modes and enable Location updates

circle-info

If you are going to use the Step Counter feature, you will need to set the registerBackgroundIdentifiers 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

chevron-right2.3 Permissionshashtag

Ensure you include the following permission in info.plist

NSLocationAlwaysAndWhenInUseUsageDescription
NSMotionUsageDescription (Recommended)

3. Usage

chevron-right3.1 SentianceHelper.swifthashtag

For a quick start we have created helper file a couple of methods to easily get started. Download this filearrow-up-right and place it anywhere accessible in your codebase.

chevron-right3.2 Initialization & Background Collectionhashtag

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.

See referencearrow-up-right

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

chevron-right4.1 createUserhashtag

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"

See reference

chevron-right4.2 linkFunctionhashtag

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 referencearrow-up-right

chevron-right4.3 User linking in your backendhashtag

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 referencearrow-up-right

chevron-right4.4 linkFunction -> linkSuccess()hashtag

Upon your backend successfully performing the user linking execute the

method received as a parameter to you linkFunction

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 herearrow-up-right__

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

Last updated