# Integración del SDK

## Requisitos

* Xcode: **15.0** o superior
* Target deployment: **iOS 12.0** o superior

## Configurar proyecto

Para comenzar con la integración de nuestro SDK, es necesario añadir la siguiente dependencia en el fichero `Podfile` del proyecto, tal y como se muestra a continuación:

```ruby
source 'https://cdn.cocoapods.org/'
platform :ios, '12.0'

...

target 'MyTarget' do
    use frameworks!
    ...
    pod 'WortiseSDK' '>= 1.7.0'
end
```

{% hint style="info" %}
Actualmente, el SDK de Wortise solo se distribuye a través de Cocoapods. En un futuro, se agregará soporte para su integración con Swift Package Manager (SPM).
{% endhint %}

## Configurar Info.plist

Es necesario agregar el siguiente parámetro en el fichero `Info.plist`, con el ID de aplicación de Google como valor:

```xml
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-xxxxxxxxxxxxxxxxxx</string>
```

{% hint style="info" %}
Este valor puede ser localizado en nuestro dashboard, dentro de los detalles de cada aplicación, bajo el nombre `Google App ID`.
{% endhint %}

A continuación, solo faltaría añadir el siguiente bloque, en el mismo fichero, para finalizar la correcta integración con Google:

<pre class="language-xml"><code class="lang-xml"><strong>&#x3C;key>SKAdNetworkItems&#x3C;/key>
</strong>&#x3C;array>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>cstr6suwn9.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>4fzdc2evr5.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>4pfyvq9l8r.skadnetwork &#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>2fnua5tdw4.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>ydx93a7ass.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>5a6flpkh64.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>p78axxw29g.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>v72qych5uu.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>ludvb6z3bs.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>cp8zw746q7.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>c6k4g5qg8m.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>s39g8k73mm.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>3qy4746246.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>3sh42y64q3.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>f38h382jlk.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>hs6bdukanm.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>prcb7njmu6.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>v4nxqhlyqp.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>wzmmz9fp6w.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>yclnxrl5pm.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>t38b2kh725.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>7ug5zh24hu.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>9rd848q2bz.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>y5ghdn5j9k.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>n6fk4nfna4.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>v9wttpbfk9.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>n38lu8286q.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>47vhws6wlr.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>kbd757ywx3.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>9t245vhmpl.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>a2p9lx4jpn.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>22mmun2rn5.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>4468km3ulz.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>2u9pt9hc89.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>8s468mfl3y.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>av6w8kgt66.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>klf5c3l5u5.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>ppxm28t8ap.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>424m5254lk.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>ecpz2srf59.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>uw77j35x4d.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>mlmmfzh3r3.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>578prtvx9j.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>4dzt52r2t5.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>gta9lk7p23.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>e5fvkxwrpn.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>8c4e2ghe7u.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>zq492l623r.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>3rd42ekr43.skadnetwork&#x3C;/string>
    &#x3C;/dict>
    &#x3C;dict>
    &#x3C;key>SKAdNetworkIdentifier&#x3C;/key>
    &#x3C;string>3qcr597p9d.skadnetwork&#x3C;/string>
    &#x3C;/dict>
&#x3C;/array>
</code></pre>

## Solicitar consentimiento

{% hint style="success" %}
Es **muy recomendable** solicitar consentimiento al usuario para poder mostrar anuncios personalizados. Esto permitirá mostrar contenido que resulte de mayor interés y generar ingresos superiores.
{% endhint %}

Puede consultar el siguiente apartado para implementar esta solicitud y obtener el consentimiento de los usuarios: [Consentimiento del usuario](consentimiento-del-usuario)

## Inicializar SDK

Nuestra recomendación es inicializar el SDK en la clase `AppDelegate` de la app, aunque también se puede realizar en algún `ViewController` principal.

Para ello, es necesario integrar el siguiente código en el método `application(didFinishLaunchingWithOptions:)`:

{% tabs %}
{% tab title="Swift" %}
```swift
func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
    ...
    WortiseAds.shared.initialize(assetKey: "tu app key")
}
```
{% endtab %}
{% endtabs %}

### Delegado de inicialización

Existen dos maneras posibles para conocer cuando el SDK finaliza su inicialización:

#### Pasando un delegate como último parámetro del método `WortiseAds.shared.initialize`

{% tabs %}
{% tab title="Swift" %}
```swift
WortiseAds.shared.initialize(assetKey: "tu app key") {
    // Este delegate será invocado cuando la inicialización finalice
}
```
{% endtab %}
{% endtabs %}

#### Utilizando el método `WortiseAds.shared.wait`

{% tabs %}
{% tab title="Swift" %}
```swift
WortiseAds.shared.wait {
    // Este delegate será invocado cuando la inicialización finalice
}
```
{% endtab %}
{% endtabs %}

## Modo de prueba

Para verificar la integración, el SDK ofrece un modo de prueba (_test mode_) que permite que la app siempre reciba anuncios.

Además de la opción que hay disponible en nuestro dashboard, es posible activar este modo de prueba programáticamente, desde el propio SDK, utilizando el siguiente código:

{% tabs %}
{% tab title="Swift" %}
```swift
WAAdSettings.testEnabled = true
```
{% endtab %}
{% endtabs %}
