# iOS

## CocoaPods

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

1\. Firstly, install CocoaPods using:

```bash
sudo gem install cocoapods
```

2\. In the project directory execute the command:

```bash
pod init
```

3\. In the created Podfile add the dependency:

```bash
platform :ios, '9.0'

target 'TargetName' do
  use_frameworks!
  pod 'DTDAnalytics', '~> 2.0.0'
end
```

4\. Finally, run the command in your Xcode project directory:

```bash
pod install
```

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 repository  ](https://github.com/devtodev-analytics/ios-sdk-2.0)

2\. Add **`DTDAnalytics.xcframework`** to the project

3\. Add frameworks:

* **`AppTrackingTransparency.framework`**
* **`AdSupport.framework`**

4\. Add initialization t&#x6F;**`didFinishLaunchingWithOptions`** method:

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

```swift
let config = DTDAnalyticsConfiguration()
config.logLevel = .error
DTDAnalytics.initialize(applicationKey: "App ID", configuration: config)
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
DTDAnalyticsConfiguration *config = [[DTDAnalyticsConfiguration alloc] init];
config.logLevel = DTDLogLevelError;
[DTDAnalytics applicationKey:@"App ID" configuration:config];
```

{% endtab %}
{% endtabs %}

You can find the `App ID` in the settings of the respective app in devtodev (Settings → SDK → Integration → [Credentials](https://docs.devtodev.com/reports-and-functionality/project-related-reports-and-fuctionality/settings#integration)).&#x20;

For [Cross-platform type projects](https://docs.devtodev.com/getting-started/cross-platform-application) use `App ID + Platform ID` .

* **`config`** - an object instance of **`DTDAnalyticsConfiguration`**, which is used for specifying additional properties during the initialization.

**`DTDAnalyticsConfiguration`**

| **Parameter**              | **Type**                 | **Description**                                                                                                                                                                                                                                                                                                                                  |
| -------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **`currentLevel`**         | int                      | The player level at the moment of devtodev SDK initialization. It is recommended (but optional) to use to improve data precision.                                                                                                                                                                                                                |
| **`userId`**               | string                   | <p>A custom user identifier provided by the developer. If you utilize the default calculation by the device ID, this identifier can be used for finding a user in devtodev.</p><p>In case your project utilizes the calculation by the user identifier, you must set this parameter because it becomes the main user identifier in devtodev.</p> |
| **`trackingAvailability`** | DTDTrackingStatus (enum) | The property allows or disallows devtodev tracking of the user. By default, it is set to ***`DTDTrackingStatus.enable`***. SDK stores the previously assigned value. Pass ***`DTDTrackingStatus.disable`*** if the user opted out of tracking in line with GDPR.                                                                                 |
| **`logLevel`**             | DTDLogLevel (enum)       | The level of logging the SDK activity. The ***`DTDLogLevel.no`*** value is used by default. For troubleshooting during integration it is recommended to set it to ***`DTDLogLevel.debug`***, and either switch it off ***`DTDLogLevel.no`***. Use ***`DTDLogLevel.no`*** in the release version.                                                 |

Example:

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

```swift
let config = DTDAnalyticsConfiguration()
config.currentLevel = 1
config.userId = "CustomUserID"
config.trackingAvailability = .enable
config.logLevel = .no
DTDAnalytics.initialize(applicationKey: "App ID", configuration: config)
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
DTDAnalyticsConfiguration *config;
config.currentLevel = @1;
config.userId = @"CustomUserID";
config.trackingAvailability = DTDTrackingStatusEnable;
config.logLevel = DTDLogLevelNo;
[DTDAnalytics applicationKey:@"App ID" configuration:config];
```

{% endtab %}
{% endtabs %}

### Integration features

#### **For Objective-C**

1. Create Bridging-Header. To do this, you need to add any swift file to the project (don’t delete it later) and choose ‘Create Bridging Header’ in the offered dialog box. &#x20;
2. Make sure that the ‘Build Settings’ for ‘Defines Module’ value evaluates to ‘YES’. &#x20;
3. While importing, use: **`#import <DTDAnalytics/DTDAnalytics-Swift.h>`**

#### **For SwiftUI**&#x20;

For SDK to function properly, it needs to be integrated at the earliest moment of the app launch. It is recommended that you use the following method of main entry point initialization:

```swift
@main
struct TestSwiftUIApp: App {
    init() {
        let config = DTDAnalyticsConfiguration()
        config.logLevel = .debug
        DTDAnalytics.initialize(applicationKey: "App ID", configuration: config)
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
```

## **Apps targeted at children**

When developing and publishing apps targeted at children under 13 years old, you need to ensure special conditions for data processing. Any mobile app aimed at children or intended for users in a region with strict regulations on child online protection, must comply with current laws.

{% hint style="info" %}
Please study the following requirements:

* USA: [Children’s Online Privacy Protection Act (COPPA)](https://www.ftc.gov/tips-advice/business-center/privacy-and-security/children's-privacy)&#x20;
* EU: [General Data Protection Regulation (GDPR) Article 8](https://gdpr-info.eu/art-8-gdpr/)
  {% endhint %}

If your app has to comply with the legal requirements (COPPA), use the following recommendations:

1. Implement the `coppaControlEnable` method. The method disables collection of ad IDs and vendor IDs (IDFA, IDFV).
2. To comply with [Apple’s guidelines](https://developer.apple.com/news/?id=091202019a)
   1. Remove `AppTrackingTransparency.framework` and all the links pointing to it.
   2. Remove `AdSupport.framework` all the links pointing to it.

{% hint style="warning" %}
Call the `coppaControlEnable` method before SDK initialization. If the method was not called, the SDK will work as before.
{% endhint %}

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

```swift
DTDAnalytics.coppaControlEnable()
DTDAnalytics.initialize(applicationKey: "App ID", configuration: config)
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
[DTDAnalytics coppaControlEnable];
[DTDAnalytics applicationKey:@"App ID" configuration:config];
```

{% endtab %}
{% endtabs %}

## Privacy Manifest

The **Privacy Manifest** is a new way introduced at [WWDC23](https://developer.apple.com/videos/play/wwdc2023/10060/) for third-party SDK developers to provide information about their privacy policies.

The Privacy Manifest describes the methods for ensuring code confidentiality in the application in a unified format. When publishing the application, Xcode will combine the privacy manifests of all third-party SDKs used in your application into a single, convenient report. This report makes it easier to create more accurate privacy labels (Nutrition Labels).

**The Privacy Manifest includes the following sections for data entry:**

* Privacy Tracking Enabled
* Privacy Tracking Domains
* Privacy Nutrition Label Types
* Privacy Accessed API Types

**Privacy Tracking Enabled.** A Boolean value indicating whether the application or third-party SDK uses data for tracking, as defined within the *App Tracking Transparency* framework.

**Privacy Tracking Domains.** An array of strings listing the internet domains that the application or third-party SDK connects to and participates in tracking.

**Privacy Nutrition Label Types.** An array of dictionaries describing the types of data collected by the application or third-party SDK. Nutrition Labels are needed to let users know what data the application collects before installing it from the App Store.

**Privacy Accessed API Types.** An array of dictionaries describing the types of APIs accessed by the application or third-party SDK, which are marked as APIs and require verification for access.

### Privacy manifest for Devtodev SDKs: <a href="#privacy-manifest-for-devtodev-sdks" id="privacy-manifest-for-devtodev-sdks"></a>

### **Analytics module**

**Privacy Nutrition Label Types**

<table><thead><tr><th width="217">Collected Data Type</th><th width="146">Linked to User</th><th width="168">Used for Tracking</th><th>Collection Purposes</th></tr></thead><tbody><tr><td>Product Interaction</td><td>No</td><td>No</td><td>Analytics</td></tr><tr><td>Device ID</td><td>No</td><td>No</td><td>Analytics</td></tr><tr><td>User ID</td><td>No</td><td>No</td><td>Analytics</td></tr><tr><td>Purchase History</td><td>No</td><td>No</td><td>Analytics</td></tr><tr><td>Other Data Types</td><td>No</td><td>No</td><td>Analytics</td></tr></tbody></table>

**Privacy Accessed API Types**

<table><thead><tr><th width="260">Privacy Accessed API Type</th><th>Privacy Accessed API Reasons</th></tr></thead><tbody><tr><td>User Defaults</td><td>CA92.1: Access info from same app, per documentation</td></tr></tbody></table>

### **Messaging module**

**Privacy Nutrition Label Types**

<table><thead><tr><th width="217">Collected Data Type</th><th width="146">Linked to User</th><th width="168">Used for Tracking</th><th>Collection Purposes</th></tr></thead><tbody><tr><td>Device ID</td><td>No</td><td>No</td><td>Analytics</td></tr><tr><td>Other Data Types</td><td>No</td><td>No</td><td>Analytics</td></tr></tbody></table>

**Privacy Accessed API Types**

<table><thead><tr><th width="260">Privacy Accessed API Type</th><th>Privacy Accessed API Reasons</th></tr></thead><tbody><tr><td>User Defaults</td><td>CA92.1: Access info from same app, per documentation</td></tr></tbody></table>

## SDK Signature <a href="#sdk-signature" id="sdk-signature"></a>

Since we distribute our SDKs as binary dependencies, we have implemented a signing practice. Now, when you use a new version of the SDK, Xcode will confirm that it has been signed by us, increasing the integrity of the software supply chain.
