앱 오프닝 광고

앱 오프닝 광고는 수익을 창출하려는 게시자를 위한 특수한 광고 형식입니다. 확인할 수 있습니다. 앱 오프닝 광고는 언제든지 닫을 수 있으며 사용자가 앱을 포그라운드로 가져올 때 표시됩니다.

앱 오프닝 광고에는 작은 브랜딩 영역이 자동으로 표시되므로 사용자가 어디에 있는지 알 수 있습니다. 있습니다. 다음은 앱 오프닝 광고의 예입니다.

기본 요건

항상 테스트 광고로 테스트

다음 샘플 코드에는 요청에 사용할 수 있는 광고 단위 ID가 포함되어 있습니다. 테스트 광고 테스트 광고를 반환하도록 특별히 구성된 경우 만들기 때문에 안전하게 사용할 수 있습니다.

하지만 광고 단위를 직접 만들었으며 Ad Manager 웹 인터페이스를 앱에서 사용할 ID를 확인하고 기기를 테스트로 명시적으로 구성하세요. 기기에서 있습니다.

/21775744923/example/app-open

구현

앱 오프닝 광고를 통합하는 주요 단계는 다음과 같습니다.

  1. 유틸리티 클래스 만들기
  2. 앱 오프닝 광고 로드
  3. 앱 오프닝 광고 이벤트 수신
  4. 광고 만료 고려
  5. 앱 상태 이벤트 수신 대기
  6. 앱 오프닝 광고 게재
  7. 앱 오프닝 광고 정리
  8. 다음 앱 오프닝 광고 미리 로드

유틸리티 클래스 만들기

광고를 로드할 새 클래스 AppOpenAdController를 만듭니다. 이 수업 로드된 광고 및 광고 단위 ID를 추적하기 위한 인스턴스 변수를 제어합니다. 확인할 수 있습니다

using System;
using UnityEngine;
using GoogleMobileAds.Api;
using GoogleMobileAds.Common;

/// <summary>
/// Demonstrates how to use the Google Mobile Ads app open ad format.
/// </summary>
[AddComponentMenu("GoogleMobileAds/Samples/AppOpenAdController")]
public class AppOpenAdController : MonoBehaviour
{

    // This ad unit is configured to always serve test ads.
    private string _adUnitId = "/21775744923/example/app-open";

    public bool IsAdAvailable
    {
        get
        {
            return _appOpenAd != null;
        }
    }

    public void Start()
    {
        // Initialize the Google Mobile Ads SDK.
        MobileAds.Initialize((InitializationStatus initStatus) =>
        {
            // This callback is called once the MobileAds SDK is initialized.
        });
    }

    /// <summary>
    /// Loads the app open ad.
    /// </summary>
    public void LoadAppOpenAd()
    {
    }

    /// <summary>
    /// Shows the app open ad.
    /// </summary>
    public void ShowAppOpenAd()
    {
    }
}

앱 오프닝 광고 로드

앱 오프닝 광고는 다음과 같이 정적 Load() 메서드를 사용하여 로드됩니다. AppOpenAd 클래스. 로드 메서드에는 광고 단위 ID, AdManagerAdRequest 객체, 그리고 완료 핸들러 는 광고 로드에 성공하거나 실패할 때 호출됩니다. 로드된 AppOpenAd 객체는 완료 핸들러의 매개변수로 제공됩니다. 아래 예는 AppOpenAd를 로드합니다.


  // This ad unit is configured to always serve test ads.
  private string _adUnitId = "/21775744923/example/app-open";

  private AppOpenAd appOpenAd;

  /// <summary>
  /// Loads the app open ad.
  /// </summary>
  public void LoadAppOpenAd()
  {
      // Clean up the old ad before loading a new one.
      if (appOpenAd != null)
      {
            appOpenAd.Destroy();
            appOpenAd = null;
      }

      Debug.Log("Loading the app open ad.");

      // Create our request used to load the ad.
      var adRequest = new AdManagerAdRequest();

      // send the request to load the ad.
      AppOpenAd.Load(_adUnitId, adRequest,
          (AppOpenAd ad, LoadAdError error) =>
          {
              // if error is not null, the load request failed.
              if (error != null || ad == null)
              {
                  Debug.LogError("app open ad failed to load an ad " +
                                 "with error : " + error);
                  return;
              }

              Debug.Log("App open ad loaded with response : "
                        + ad.GetResponseInfo());

              appOpenAd = ad;
              RegisterEventHandlers(ad);
          });
  }

앱 오프닝 광고 이벤트 수신

광고의 작동 방식을 추가로 맞춤설정하려는 경우 열기, 닫기 등)에 대해 정의될 수 있습니다. 듣기 이러한 이벤트를 처리할 수 있습니다.

private void RegisterEventHandlers(AppOpenAd ad)
{
    // Raised when the ad is estimated to have earned money.
    ad.OnAdPaid += (AdValue adValue) =>
    {
        Debug.Log(String.Format("App open ad paid {0} {1}.",
            adValue.Value,
            adValue.CurrencyCode));
    };
    // Raised when an impression is recorded for an ad.
    ad.OnAdImpressionRecorded += () =>
    {
        Debug.Log("App open ad recorded an impression.");
    };
    // Raised when a click is recorded for an ad.
    ad.OnAdClicked += () =>
    {
        Debug.Log("App open ad was clicked.");
    };
    // Raised when an ad opened full screen content.
    ad.OnAdFullScreenContentOpened += () =>
    {
        Debug.Log("App open ad full screen content opened.");
    };
    // Raised when the ad closed full screen content.
    ad.OnAdFullScreenContentClosed += () =>
    {
        Debug.Log("App open ad full screen content closed.");
    };
    // Raised when the ad failed to open full screen content.
    ad.OnAdFullScreenContentFailed += (AdError error) =>
    {
        Debug.LogError("App open ad failed to open full screen content " +
                       "with error : " + error);
    };
}

광고 만료 고려

만료된 광고가 게재되지 않도록 하려면 AppOpenAdController: 광고가 로드된 후 경과한 시간을 확인합니다. 그런 다음 이 메서드를 이용해 광고가 여전히 유효한지 확인합니다.

앱 오프닝 광고의 제한 시간은 4시간입니다. _expireTime에서 로드 시간을 캐시합니다. 변수의 값을 반환합니다.

// send the request to load the ad.
AppOpenAd.Load(_adUnitId, adRequest,
    (AppOpenAd ad, LoadAdError error) =>
    {
        // If the operation failed, an error is returned.
        if (error != null || ad == null)
        {
            Debug.LogError("App open ad failed to load an ad with error : " +
                            error);
            return;
        }

        // If the operation completed successfully, no error is returned.
        Debug.Log("App open ad loaded with response : " + ad.GetResponseInfo());

        // App open ads can be preloaded for up to 4 hours.
        _expireTime = DateTime.Now + TimeSpan.FromHours(4);

        _appOpenAd = ad;
    });

IsAdAvailable 속성을 업데이트하여 로드가 완료되었는지 _expireTime를 확인합니다. 여전히 유효합니다.

public bool IsAdAvailable
{
    get
    {
        return _appOpenAd != null
               && _appOpenAd.IsLoaded()
               && DateTime.Now < _expireTime;
    }
}

앱 상태 이벤트 수신 대기

AppStateEventNotifier를 사용하여 애플리케이션의 포그라운드와 상태를 수신 대기 사용할 수 있습니다. 이 클래스는 매번 AppStateChanged 이벤트를 발생시킵니다. 애플리케이션의 포그라운드 또는 백그라운드에 있을 수 있습니다

private void Awake()
{
    // Use the AppStateEventNotifier to listen to application open/close events.
    // This is used to launch the loaded ad when we open the app.
    AppStateEventNotifier.AppStateChanged += OnAppStateChanged;
}

private void OnDestroy()
{
    // Always unlisten to events when complete.
    AppStateEventNotifier.AppStateChanged -= OnAppStateChanged;
}

AppState.Foreground 상태와 IsAdAvailable를 처리할 때 이(가) true이면 광고를 게재하기 위해 ShowAppOpenAd()를 호출합니다.

private void OnAppStateChanged(AppState state)
{
    Debug.Log("App State changed to : "+ state);

    // if the app is Foregrounded and the ad is available, show it.
    if (state == AppState.Foreground)
    {
        if (IsAdAvailable)
        {
            ShowAppOpenAd();
        }
    }
}

앱 오프닝 광고 게재

로드된 앱 오프닝 광고를 표시하려면 Show() 메서드를 호출합니다. AppOpenAd 인스턴스. 광고는 로드당 한 번만 게재될 수 있습니다. CanShowAd() 사용 메서드를 사용하여 광고를 게재할 준비가 되었는지 확인합니다.

/// <summary>
/// Shows the app open ad.
/// </summary>
public void ShowAppOpenAd()
{
    if (appOpenAd != null && appOpenAd.CanShowAd())
    {
        Debug.Log("Showing app open ad.");
        appOpenAd.Show();
    }
    else
    {
        Debug.LogError("App open ad is not ready yet.");
    }
}

앱 오프닝 광고 정리

AppOpenAd 사용을 마쳤으면 Destroy()를 호출해야 합니다. 메서드를 호출합니다.

appOpenAd.Destroy();

이렇게 하면 플러그인이 더 이상 사용되지 않는다고 플러그인에 알리고 다시 확보할 수 있습니다. 이 메서드를 호출하지 못하면 메모리 누수가 발생합니다.

다음 앱 오프닝 광고 미리 로드

AppOpenAd는 일회용 객체입니다. 즉, 앱 오프닝 광고가 표시되면 객체는 다시 사용할 수 없습니다 앱 오프닝 광고를 다시 요청하려면 새로운 AppOpenAd 객체를 만들어야 합니다.

다음 노출 기회에 앱 오프닝 광고가 게재되도록 준비하려면 앱 오프닝 광고를 OnAdFullScreenContentClosed 또는 OnAdFullScreenContentFailed 광고 이벤트가 발생합니다.

private void RegisterReloadHandler(AppOpenAd ad)
{
    ...
    // Raised when the ad closed full screen content.
    ad.OnAdFullScreenContentClosed += ()
    {
        Debug.Log("App open ad full screen content closed.");

        // Reload the ad so that we can show another as soon as possible.
        LoadAppOpenAd();
    };
    // Raised when the ad failed to open full screen content.
    ad.OnAdFullScreenContentFailed += (AdError error) =>
    {
        Debug.LogError("App open ad failed to open full screen content " +
                       "with error : " + error);

        // Reload the ad so that we can show another as soon as possible.
        LoadAppOpenAd();
    };
}

콜드 스타트 및 로드 화면

지금까지 문서에서는 사용자가 앱 오프닝 광고를 메모리에서 정지된 경우 앱을 포그라운드로 설정하세요. '콜드 스타트' 은(는) 다음과 같은 경우에 발생합니다. 앱이 실행되었지만 이전에 메모리에서 정지되지 않았어야 합니다.

콜드 스타트의 예로는 사용자가 앱을 처음 여는 경우를 들 수 있습니다. 콜드 스타트를 사용하면 이전에 로드한 앱 오프닝 광고가 없지만 바로 표시되도록 할 수 있습니다. 광고를 요청한 후 광고를 받기까지 걸리는 시간 사용자가 내 앱을 다시 사용하기 전에 잠시 앱을 엉뚱한 광고를 보고 깜짝 놀란 경우 이것은 피해야 하는 부정적인 사용자 경험을 제공할 수 있습니다

콜드 스타트 시 앱 오프닝 광고를 사용하는 좋은 방법은 로드 화면을 사용하는 것입니다. 를 설정하여 게임 또는 앱 애셋을 로드하고 화면 앱 로드가 완료되고 사용자를 기본 광고를 게재하지 않습니다.

권장사항

앱 오프닝 광고를 사용하면 앱을 처음 열 때 앱 로드 화면을 통해 수익을 창출할 수 있습니다 앱 전환 중에도 실행되지만 다음 사항을 최대한으로 유지하는 것이 사용자가 앱을 즐겁게 사용할 수 있도록 하는 것이 중요합니다.

  • 사용자가 앱을 몇 번 사용한 후에 첫 앱 오프닝 광고를 게재하세요.
  • 사용자가 기다리지 않을 시간에 앱 오프닝 광고 게재 있습니다.
  • 앱 오프닝 광고 및 로드 화면 아래에 로드 화면이 있는 경우 광고가 취소되기 전에 로드가 완료된 경우 OnAdDidDismissFullScreenContent 이벤트 핸들러
  • iOS 플랫폼에서 AppStateEventNotifierAppStateEventClient GameObject입니다. 이벤트에 이 GameObject이(가) 필요합니다. 파괴하지 마세요. GameObject가 다음과 같은 경우 이벤트 실행이 중지됩니다. 있습니다.

추가 리소스