> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/sdks/sdk-mobile/ios-sdk/modulos/conexion-con-plataforma.md).

# Platform connection

This component requires iOS 13 or later.

Events are sent to the platform using the ***Tracking Component*****.**

It is responsible for tracking and monitoring the information collected while operations are running. You can track this data in real time on the **Platform**, while the process is running on the client’s device.

Unlike the other components, this component does not work independently; it works across the other components installed in the *SDKMobile*.

## Dependencies

### CocoaPods

Facephi libraries are distributed remotely using dependency managers. On iOS, **CocoaPods** is used. The **required** dependencies that must be installed beforehand (by adding them to the project's Podfile) are:

```swift
  pod 'FPHISDKMainComponent', '~> $VERSION'
```

To install the **Tracking**component, add the corresponding dependency to the project's `Podfile` , along with the SDK's required dependencies.

```swift
  pod 'FPHISDKTrackingComponent', '~> $VERSION'
```

### Swift Package Manager (SPM)

If you use **SPM**, make sure the SDK's required dependencies are installed first.

```sh
//HTTPS
https://github.com/facephi-clienters/SDK-SdkPackage-SPM.git
//SSH
git@github.com:facephi-clienters/SDK-SdkPackage-SPM.git
```

To install the **Selphi**component, include it in the project's modules.

```swift
//HTTPS
https://github.com/facephi-clienters/SDK-TrackingPackage-SPM.git
//SSH
git@github.com:facephi-clienters/SDK-TrackingPackage-SPM.git
```

## Permissions

In the client application where the components will be integrated, add the following entry to the **Info.plist** file when tracking is going to send location data:

```
Location access must be allowed (NSLocationUsageDescription - Privacy - Location Usage Description)
```

{% hint style="info" %}
Location permission is only required if you **do not** set **`enableLocation: false`** in the initializer for **`TrackingController`**. By default, **`enableLocation`** is **`true`** and the component can request and send location data in events to the platform.
{% endhint %}

## Integration

To reference the dependency from our Swift code:

```swift
import trackingComponent
```

## Injecting into the SDK <a href="#id-4-lanzamiento-simplificado" id="id-4-lanzamiento-simplificado"></a>

```swift
SDKController.shared.initSdk(licensingUrl: SdkConfigurationManager.LICENSING_URL, apiKey: SdkConfigurationManager.APIKEY_LICENSING, output: { sdkResult in
    if sdkResult.finishStatus == .STATUS_OK {
        self.log("Automatic License set successfully")
    } else {
        self.log("An error occurred while trying to obtain the license: \(sdkResult.errorType)")
    }
}, trackingController: trackingController)
```

## Initializing TrackingController

Create an instance of **`TrackingController`** before calling **`SDKController.shared.initSdk`**, passing it in the `trackingController`.

```swift
let trackingController = TrackingController(
    trackingError: { trackingError in
        print("TRACKING ERROR: \(trackingError)")
    },
    enableLocation: false,
    debug: debugFlag)
```

### **enableLocation**

Controls whether the **Tracking** component requests and sends **location data** in events to the platform. By default, it is `true`.

## Receiving errors

Tracking controller errors are not terminal. Unlike the rest of the SDK, they are reported through the callback injected during its initialization (`trackingError` in the previous initializer).

The parameter *trackingError* is a String that can have the following values:

* **APPLICATION\_CONTEXT\_ERROR:** Error initializing the context
* **ASSET\_LINK**: Error sending the asset link
* **ASSET\_UPLOAD**: Error uploading the asset
* **COMPONENT\_LICENSE\_ERROR**: Component License missing or invalid
* **CUSTOMER\_ID**: Error retrieving or validating the customer ID
* **DEVICE\_EVENT\_ERROR**: Failure during a device-related event
* **EMPTY\_LICENSE**: License data is empty or missing
* **FLOW**: Error during the execution Flow
* **INITIALIZATION\_ERROR**: General initialization failure
* **INIT\_IDS\_ERROR**: Error generating or assigning IDs during initialization
* **INIT\_OPERATION**: Operation failed during the initialization phase
* **LICENSE\_ERROR**: Invalid or corrupted license
* **MANAGER\_NOT\_INITIALIZED**: Attempted to use the manager without initializing it
* **NETWORK\_CONNECTION**: Network connection problem
* **NETWORK\_ERROR**: Generic network failure
* **NO\_OPERATION\_CREATED\_ERROR**: No operation was created when one was expected
* **OCR\_DATA**: Error processing OCR data
* **OPERATION\_NOT\_CREATED**: The expected operation was not generated
* **OPERATION\_ID**: Invalid or missing operation ID
* **SESSION\_ID**: Error with session identification
* **SIGNATURE\_RESULT**: Failure in the signing process or result
* **STEP\_CHANGE**: Unexpected or invalid step transition
* **STEP\_RESULT\_CANCELLED**: The step was unexpectedly canceled
* **STEP\_RESULT\_ERROR**: The step ended with an error
* **STEP\_RESULT\_EXPIRED**: The step result expired before completion
* **STEP\_RESULT\_SUCCEEDED**: The step succeeded but generated an unexpected problem
* **TOKEN\_ERROR**: Missing, expired, or invalid Token
* **ADVANCED\_TRACKING\_UPLOAD**: Failed to upload advanced tracking data
* **TENANT\_ID\_EMPTY\_ERROR**: The tenant ID was empty or missing
* **ADVANCED\_TRACKING\_SERIALIZATION\_ERROR**: Error serializing advanced tracking data
* **ADVANCED\_TRACKING\_VALIDATION\_ERROR**: Tracking data validation failed
* **TOKENIZER\_ERROR**: Error during the tokenization process
