# iOS

{% hint style="danger" %}
**This generation of SDK is deprecated and is no longer supported.**\
Information about the [current version can be found here](https://docs.devtodev.com/integration/integration-of-sdk-v2/sdk-integration/ios).
{% endhint %}

Please perform the following actions to integrate your application with devtodev system:

* add the application to the Space using the wizard for adding application
* [download the latest version of devtodev SDK](https://github.com/devtodev-analytics/ios-sdk) or install via CocoaPods
* integrate SDK into your application. The integration may be whether partial or including all the possibilities.

## CocoaPods

[CocoaPods](http://cocoapods.org/) is the easiest way to add devtodev into your iOS project.

1. Firstly, install CocoaPods using

   ```ruby
   gem install cocoapods
   ```
2. Create a file in your Xcode project called Podfile and add the following:

   ```ruby
   pod 'devtodev'
   ```
3. Run

   ```ruby
   pod install
   ```

   in your Xcode project directory. CocoaPods should download and install the devtodev library, and create a new Xcode workspace. Open this workspace in Xcode.

## Manual installation

1. Download the latest version of devtodev SDK from the [GitHub](https://github.com/devtodev-analytics/ios-sdk) repository.
2. Include devtodev.framework dependency:

   ![](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LnGcP_ZeRJ1ipj9O8dF%2F-LnlShMa3E6SgK1lXtjO%2F-LnlSi943IDSPRSrYBWB%2F4-analyticsintegration-0.png?generation=1567419212747290\&alt=media)
3. Link against the embedded framework:

   Add devtodev.framework to the Linked Frameworks and Libraries section.

   ![](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LnGcP_ZeRJ1ipj9O8dF%2F-LnlShMa3E6SgK1lXtjO%2F-LnlSi96uHqGJ6LYqibP%2F4-analyticsintegration-1.png?generation=1567419213195480\&alt=media)
4. For the correct SDK functioning add the following frameworks:

   * Security.framework (**Optional**) &#x20;
   * UIKit.framework (**Optional**) &#x20;
   * UserNotifications (**Optional**) &#x20;
   * StoreKit.framework &#x20;
   * AdSupport.framework &#x20;

   ![](https://2105883905-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LnGcP_ZeRJ1ipj9O8dF%2F-LnlShMa3E6SgK1lXtjO%2F-LnlSi98BZCoJeeCnP9L%2F4-analyticsintegration-2.png?generation=1567419212534691\&alt=media)
5. Add init method into didFinishLaunchingWithOptions method of your AppDelegate.m

   ```
   /**
   * devtodev App Id and Secret key can be found in the devtodev application
   * settings page (“My apps” → App Name → “Settings” → “Integration”)
   */
   [DevToDev initWithKey:applicationId andSecretKey:secretKey];
   ```
6. If the application you integrate SDK in is a part of a cross-platform project, then the user data initialization is required.\
   Since the analytics of cross-platform projects is based on an unique user (unlike the usual projects where it is based on device identifiers), you have to:
   * Set the unique cross-platform user identifier (it will be used for cross-platform project data collection).    &#x20;
   * Actualize the user data. Mostly it is about game applications where the player has a game level as a characteristic. For such projects, you need to set the current player level.

We recommend you set the user identifier before SDK initialization, otherwise the user identifier from the previous session will be used since the SDK initialization moment till the setUserID method call.

{% hint style="info" %}
If your cross-platform application is supposed to be used without cross-platform authorization, don't use the setUserID method or use the empty string ("") as the user identifier. SDK will assign the unique identifier to the user. This identifier will be used until the real cross-platform identifier is assigned to the user.
{% endhint %}

```objectivec
/**
* Method allows to initialize the user. It applies when SDK initialization or user relogin.
* @param NSString activeUserId - unique cross-platform user identifier (max. 64 symbols)
*/
[DevToDev setUserId:@"activeUserId"];

/**
* Method sets the current user level. Using this method allows to actualize 
* the SDK user data in game cross-platform applications.
* @param NSUInteger level - number of current game level of the user
*/
[DevToDev setCurrentLevel:level];

/**
* devtodev App Id and Secret key can be found in the devtodev application
* settings page ("Settings" → "SDK" → "Integration")
*/
[DevToDev initWithKey:applicationId andSecretKey:secretKey];
```

{% hint style="warning" %}
If your application allows user to re-login (changing the user during the working session of application), then the *setUserID* and *setCurrentLevel* methods should be called just after the authorization. You don't need to call the SDK initialization one more time.
{% endhint %}

### Debug mode

To enable the debug mode and make SDK notifications displayed in the console use this method:

```objectivec
/**
* @param BOOL isActive
*/
[DevToDev setActiveLog: (BOOL) isActive];
```
