---
title: iOS
slug: ios
docTags: 
createdAt: 2022-04-12T07:13:48.000Z
---

To work with Eyrene Deeplink on iOS:

***

:::ExpandableHeading
# 1. Install and configure the SDK

To install the SDK, add the `ICDeepLink.framework` file to the project. To start working with the Eyrene API, configure the `scheme`, `token`, and `agentId` parameters.

## Scheme

A scheme is needed so that you can return to your application. Add a new scheme under URL Types and run:

```objective-c
[ICDeepLink shared].scheme = @"string";
```

## Token

Access token to the Eyrene app. It is needed to start the visit.

```objective-c
[ICDeepLink shared].token = @"string";
```

## AgentID

AgentID - user ID for identification in the system.

```objective-c
[ICDeepLink shared].agentId = @"string";
```
:::

***

::::ExpandableHeading
# 2. Sync Master Data



To work with the app offline, sync master data.

:::hint{type="info"}
**Note**

We recommend syncing data once at the beginning of the day, with stable internet
:::

To synchronize master data, specify a token, a list of stores, and a synchronization command.

## Request example

```objective-c
[[ICDeepLink shared] startSyncListCustomerId:@[ @"id1", @"id2", @"id3" ]];
```

When synchronization is complete, control from the Eyrene app will be back to the calling application. The calling application receives the synchronization status in the delegate method. If synchronization fails, an error code will be returned in the response.

## Response example

```objective-c
- (void)syncStatus:(BOOL)status withErrorCode:(NSNumber* _Nullable)errorCode;
```

## Response parameters

***

`Status` *boolean*
Sync status. If the value is `YES` - synchronization was successful, `NO` - there was a problem with the exchange. In this case, retry synchronization.

***

`ErrorCode`**&#xA0;***integer*

Error code:

- **1201** — no internet connection;
- **1202** — sync canceled by the user;
- **1203** — time limit exceeded;
- **1204** — problems with sync in Eyrene.

***
::::

***

:::ExpandableHeading
# 3. Start a visit

To start or view a visit, call the function:

```objective-c
- (void)openVisitId:(NSString *_Nonnull)visitId
     withCustomerId:(NSString *_Nonnull)customerId
         withFilter:(NSString *_Nullable)filter
       withReadonly:(BOOL)readonly;
```

## Request parameters

***

`visitId` *string*

**<font color="#f40000">Required</font>. Visit ID.

***

`customerId`**&#xA0;***string*

**<font color="#ff0000">Required</font>. Store ID for the visit.

***

`filter`**&#xA0;***string*

Task filter. [A regular expression](https://developer.android.com/reference/java/util/regex/Pattern) for filtering tasks by name. If you have specified a filter, the visit will display tasks that match the specified filter.

***

`readonly`**&#xA0;***boolean*

Opens the visit read-only. Tasks are view-only.

***
:::

***

:::ExpandableHeading
# 4. Return from the Eyrene app

After the user clicks "Return", control from the Eyrene app will be back to the calling application. To handle this event, define a function:

```objective-c
- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:
                (NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
   return [[ICDeepLink shared] proceedDeeplink:url];
}
```

To receive visit information from the Eyrene app, subscribe to the `ICDeepLinkDelegate`.

```objective-c
[ICDeepLink shared].delegate = self;
```

In this case, the method

```objective-c
- (void)reciveVisitId:(NSString *_Nonnull)visitId
           customerId:(NSString *_Nonnull)customerId
             userInfo:(NSDictionary *_Nonnull)userInfo;
```

will be called during control transfer to the calling application.

Additional data arrives in the `userInfo` dictionary. The following keys are available in the current version:

- `total_images` — the total number of photos in the visit.

In future versions of the SDK, the set of keys in userInfo may be expanded.
:::

***

