메인 콘텐츠로 건너뛰기

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.

앱 오픈 광고 형태 소개

  • 앱이 백그라운드에서 포그라운드로 돌아올 때 노출하는 전면 광고입니다.
  • 첫 실행 직후가 아니라, 앱 복귀 시점에 노출하는 것을 권장합니다.

광고 연동하기

1

광고 인스턴스 생성

private DaroAppOpenAd ad;

ad = new DaroAppOpenAd("your-appopen-ad-unit-id");
2

이벤트 핸들러 등록

ad.OnAdLoaded += info => Debug.Log("app open loaded");
ad.OnAdFailedToLoad += error => Debug.LogWarning(error.Message);
ad.OnAdFailedToShow += error => Debug.LogWarning(error.Message);
3

앱 상태 변경 구독

DaroAppStateNotifier.OnAppStateChanged += OnAppStateChanged;
4

포그라운드 복귀 시 광고 표시

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

구독 해제 및 광고 해제

DaroAppStateNotifier.OnAppStateChanged -= OnAppStateChanged;
ad?.Dispose();
ad = null;

Example

using Daro;
using UnityEngine;

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

    private void OnEnable()
    {
        ad = new DaroAppOpenAd(adUnitId);
        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;
    }
}
앱 오픈 광고는 첫 실행 직후에 표시하지 말고, 백그라운드에서 포그라운드로 돌아오는 시점에 표시하세요.
Android에서는 OnAdLoaded 콜백이 네이티브 preload 흐름과 겹칠 수 있습니다. 표시 가능 여부는 OnAdLoaded 플래그만 믿지 말고 IsReady()로 확인하세요.
앱 오픈 광고는 dismiss 후 자동 preload 정책을 사용할 수 있습니다. OnAdDismissed에서 반복적으로 Load()를 호출하지 마세요.