> 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

Event sending to the platform is done with the ***Tracking Component*****.**

It is responsible for tracking and monitoring the information obtained during the execution of the operations. Real-time tracking of this data will be possible on the **Platform**, while the process is running on the client's device.

Unlike the rest, this component does not work independently; it works transversally to the rest of the components installed in the *SDKMobile*.

## Dependencies

### CocoaPods

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

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

To install the component **Tracking**, add the corresponding dependency in the `Podfile` of the project, together with the mandatory dependencies of the SDK.

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

### Swift Package Manager (SPM)

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

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

To install the component **Selphi**, 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 are to be integrated, it is necessary to include the following item in the file **Info.plist** when tracking is going to send location:

```
It is necessary to allow access to location (NSLocationUsageDescription - Privacy - Location Usage Description)
```

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

## Integration

To reference the dependency from our Swift code:

```swift
import trackingComponent
```

## Injection in 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 correctly")
    } else {
        self.log("An error occurred while trying to obtain the License: \(sdkResult.errorType)")
    }
}, trackingController: trackingController)
```

## Initialization of the TrackingController

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

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

### **enableLocation**

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

## Receiving errors

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

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

* **APPLICATION\_CONTEXT\_ERROR:** Error in context initialization
* **ASSET\_LINK**: Error when sending the resource link
* **ASSET\_UPLOAD**: Error during resource upload
* **COMPONENT\_LICENSE\_ERROR**: Component License missing or invalid
* **CUSTOMER\_ID**: Error when obtaining or validating the customer ID
* **DEVICE\_EVENT\_ERROR**: Failure during a device-related event
* **EMPTY\_LICENSE**: Empty or nonexistent License data
* **FLOW**: Error during the execution Flow
* **INITIALIZATION\_ERROR**: General failure in Initialization
* **INIT\_IDS\_ERROR**: Error when generating or assigning IDs during Initialization
* **INIT\_OPERATION**: Failed operation in the Initialization phase
* **LICENSE\_ERROR**: Invalid or corrupted License
* **MANAGER\_NOT\_INITIALIZED**: The manager was used without initializing it
* **NETWORK\_CONNECTION**: Problem with the network connection
* **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 the session identification
* **SIGNATURE\_RESULT**: Failure in the signature process or result
* **STEP\_CHANGE**: Unexpected or invalid step transition
* **STEP\_RESULT\_CANCELLED**: The step was unexpectedly cancelled
* **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 issue
* **TOKEN\_ERROR**: Token missing, expired or invalid
* **ADVANCED\_TRACKING\_UPLOAD**: Failure when uploading 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**: Failure in Tracking data validation
* **TOKENIZER\_ERROR**: Error during the tokenization process
