> ## Documentation Index
> Fetch the complete documentation index at: https://guide.daro.so/llms.txt
> Use this file to discover all available pages before exploring further.

# App Open Ads

> Implement app open ads in your Unity project.

## App Open Ad Format

* Full-screen ads shown when the app returns from background to foreground.
* Prefer showing them on warm foreground returns, not immediately on first launch.

![App open ad example](https://mintcdn.com/delightroom-5a71a6a8/j3-znW7LKrbpP3mb/sdk-integration/android/ad-formats/img/appopen-ad-example.png?fit=max\&auto=format\&n=j3-znW7LKrbpP3mb\&q=85\&s=1b3c49ed5723727ee8e5311ef9a3fc05)

***

## Integrating Ads

**1. Create Ad Instance**

```csharp theme={null}
private DaroAppOpenAd ad;

ad = new DaroAppOpenAd("your-appopen-ad-unit-key");
```

**2. Register Event Handlers**

```csharp theme={null}
ad.OnAdLoaded += info => Debug.Log("app open loaded");
ad.OnAdFailedToLoad += error => Debug.LogWarning(error.Message);
ad.OnAdFailedToShow += error => Debug.LogWarning(error.Message);
```

**3. Subscribe to App State Changes**

```csharp theme={null}
DaroAppStateNotifier.OnAppStateChanged += OnAppStateChanged;
```

**4. Show on Foreground Return**

```csharp theme={null}
private void OnAppStateChanged(DaroAppStateNotifier.AppState state)
{
    if (state == DaroAppStateNotifier.AppState.Foreground
        && ad != null
        && ad.IsReady())
    {
        ad.Show();
    }
}
```

**5. Unsubscribe and Dispose**

```csharp theme={null}
DaroAppStateNotifier.OnAppStateChanged -= OnAppStateChanged;
ad?.Dispose();
ad = null;
```

***

## Example

```csharp expandable theme={null}
using Daro;
using UnityEngine;

public sealed class AppOpenHost : MonoBehaviour
{
    [SerializeField] private string adUnitKey = "your-appopen-ad-unit-key";
    private DaroAppOpenAd ad;
    private bool hasEnteredBackground;

    private void OnEnable()
    {
        ad = new DaroAppOpenAd(adUnitKey);
        ad.OnAdLoaded += info => Debug.Log("app open loaded");
        ad.OnAdFailedToLoad += error => Debug.LogWarning(error.Message);
        ad.OnAdFailedToShow += error => Debug.LogWarning(error.Message);
        ad.Load();

        DaroAppStateNotifier.OnAppStateChanged += OnAppStateChanged;
    }

    private void OnAppStateChanged(DaroAppStateNotifier.AppState state)
    {
        if (state == DaroAppStateNotifier.AppState.Foreground
            && ad != null
            && hasEnteredBackground
            && ad.IsReady())
        {
            ad.Show();
        }

        if (state == DaroAppStateNotifier.AppState.Background)
        {
            hasEnteredBackground = true;
        }
    }

    private void OnDisable()
    {
        DaroAppStateNotifier.OnAppStateChanged -= OnAppStateChanged;
        ad?.Dispose();
        ad = null;
    }
}
```

> [!WARNING]
>
> Do not show app open ads immediately on first launch. Show them when the app returns from background to foreground.

> [!WARNING]
>
> On Android, `OnAdLoaded` can overlap with native preload flow. Check display readiness with `IsReady()` instead of relying only on an `OnAdLoaded` flag.

> [!WARNING]
>
> App open ads can use automatic preload after dismiss. Do not repeatedly call `Load()` from `OnAdDismissed`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.