> For the complete documentation index, see [llms.txt](https://docs.wortise.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wortise.com/ios-sdk/integracion-del-sdk/rewarded.md).

# Rewarded

## Integración

Los anuncios recompensados (rewarded), al igual que los intersticiales, únicamente se pueden integrar a través de código. A continuación se muestra un sencillo ejemplo para entender su funcionamiento:

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

```swift
import UIKit
import WortiseSDK

class ViewController: UIViewController {

    private var rewardedAd: WARewardedAd!

    override func viewDidLoad() {
        super.viewDidLoad()
        ...
        rewardedAd = WARewardedAd(adUnitId: "test-rewarded")
        rewardedAd.loadAd()
    }

    override func willMove(toParent controller: UIViewController?) {
        super.willMove(toParent: controller)
        ...
        rewardedAd.destroy()
    }

    func showRewarded() {
        if rewardedAd.isAvailable {
            rewardedAd.showAd(from: self)
        }
    }
}
```

{% endtab %}
{% endtabs %}

## **Configuración del delegado**

Como en el resto de formatos, se puede añadir un delegate para recibir los diferentes eventos\
que sucedan durante el ciclo de vida del anuncio recompensado. Para ello, es necesario implementar la interfaz `WARewardedDelegate` como se muestra en el siguiente ejemplo:

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

```swift
extension ViewController : WARewardedDelegate {

    func didClick(rewardedAd: WARewardedAd) {
        // Invocado cuando el anuncio ha sido clickeado
    }

    func didComplete(rewardedAd: WARewardedAd, reward: WAReward) {
        // Invocado cuando el anuncio ha sido completado
    }

    func didDismiss(rewardedAd: WARewardedAd) {
        // Invocado cuando el anuncio ha sido cerrado
    }
    
    func didFailToLoad(rewardedAd: WARewardedAd, error: WAAdError) {
        // Invocado cuando el anuncio no se ha podido cargar
        // (por error o falta de inventario)
    }

    func didFailToShow(rewardedAd: WARewardedAd, error: WAAdError) {
        // Invocado cuando el anuncio no se ha podido mostrar
    }

    func didImpress(rewardedAd: WARewardedAd) {
        // Invocado cuando el anuncio ha generado una impresión
    }

    func didLoad(rewardedAd: WARewardedAd) {
        // Invocado cuando el anuncio ha sido cargado
    }
    
    func didPayRevenue(rewardedAd: WARewardedAd, data: WARevenueData) {
        // Invocado cuando el anuncio ha generado un ingreso
    }
 
    func didShow(rewardedAd: WARewardedAd) {
        // Invocado cuando el anuncio ha sido mostrado
    }
}
```

Una vez implementada la interfaz, se asigna el delegate a la instancia del anuncio:

```swift
rewardedAd.delegate = self
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wortise.com/ios-sdk/integracion-del-sdk/rewarded.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
