🗂️
ONE AdMax Developer Guides
KR
KR
  • 00. about ONE AdMax
  • 01. 매체 키 발급 방법
  • 02. 플레이스먼트 키 발급 방법
  • 03. SDK for Java
    • 3-1. 보상형 비디오 광고
    • 3-2. 전면 광고
    • 3-3. 배너 광고
    • 3-4. 전면 비디오 광고 (비보상형)
  • 04. Unity-Plugin Guide
    • 4-1. 보상형 비디오 광고 for Unity
    • 4-2. 전면 광고 for Unity
    • 4-3. 배너 광고 for Unity
    • 4-4. 전면 비디오 광고 for Unity (비보상형)
  • 05. Flutter-Plugin Guide
    • 5-1. 보상형 비디오 광고 for Flutter
    • 5-2. 전면 광고 for Flutter
    • 5-3. 배너 광고 구현하기
    • 5-4. 전면 비디오 광고 for Flutter (비보상형)
  • 📌미디에이션 시작하기
  • ONE AdMax SDK Error Codes
  • SDK Version 안내 사항
    • SDK 1.2.0
    • SDK 1.0.2
Powered by GitBook
On this page
  • 사전 작업
  • ONEAdMax SDK 초기화
  • 유저 식별값 설정
  • Reward Video AD Sample Code
  • Reward Video AD 인스턴스 생성하기
  • 네트워크 스케줄 타임아웃 설정 (선택사항)
  • Reward Video AD 이벤트 리스너 설정 (선택사항)
  • 리워드 비디오 광고 생성하기
  • 리워드 비디오 광고 로드 하기
  • 리워드 비디오 광고 노출하기
  • 리워드 비디오 광고 메모리 해지하기
  • 보상형 비디오 광고 로드 여부 체크하기
  • 어플리케이션의 라이프사이클 확장하기
  • CS 페이지 호출
  • 미디에이션 설정
  1. 04. Unity-Plugin Guide

4-1. 보상형 비디오 광고 for Unity

비디오 광고 시청 완료 시, 유저에게 리워드가 지급되는 광고 타입 입니다.

Previous04. Unity-Plugin GuideNext4-2. 전면 광고 for Unity

Last updated 5 months ago

사전 작업


ONEAdMax SDK 초기화

광고를 로드하기 전 ONEAdMax 초기화가 필요하며, ONEAdMaxClient.Initialize() 는 최초 한 번만 수행해야 합니다.

...
using ONEAdMax;
...
public class ONEAdMaxDemo : MonoBehaviour
{
    private static bool _isInitialized = false;
    
    void Start()
    {
        if (!_isInitialized)
        {
            // Initialize the ONEAdMax SDK.
            ONEAdMaxClient.Initialize(() =>
            {
                // This callback is called once the ONEAdMax SDK is initialized.
                _isInitialized = true
            });
        }
    }
}

유저 식별값 설정

보상형 비디오 시청 완료 시 리워드 지급 유저를 식별하기 위해 사용됩니다.

string userId = "bXlBY2NvdW50X25hbWU";
ONEAdMaxClient.SetUserId(userId);

꼭! 확인해주세요!

  1. 1명의 유저는 가변적인 값이 아닌 1개의 고유한 유저식별값을 가져야 합니다.

  2. 개인정보( 이메일, 이름, 전화번호, 식별 가능한 유저 아이디 등 )가 포함되어서는 안됩니다.

  3. 한글, 특수문자, 공백 등이 포함된 경우에는 반드시 URL 인코딩 처리를 하여 사용하여야 합니다.

  4. 유저가 광고에 진입하기 전에 설정되어야 합니다.


Reward Video AD Sample Code

OAMRewardVideo 인스턴스를 생성하고, 이벤트를 처리하여 기능을 확장할 수 있습니다.

Reward Video AD 인스턴스 생성하기

public class RewardVideoAdController : MonoBehaviour
{
    OAMRewardVideo _rewardVideoAd
    
    /// <summary>
    /// Creates the ad.
    /// </summary>
    public void CreateRewardVideoAd()
    {
        Debug.Log("Creating Reward video ad.");
        
        if (_rewardVideoAd != null)
        {
            Debug.LogWarning("Already have a Reward video ad.");
            return;
        }
    
        _rewardVideoAd = new OAMRewardVideo();
    }
}

네트워크 스케줄 타임아웃 설정 (선택사항)

리워드 비디오 광고에 대한 네트워크 스케줄 타임아웃을 설정합니다.

리워드 비디오 광고 로딩 시 각 네트워크 별로 타임아웃 시간을 설정하여 해당 시간 안에 광고를 받지 못할 경우 , 다음 네트워크로 넘어갑니다.

_rewardVideoAd.SetNetworkScheduleTimeout(5); // Default 5 seconds

Reward Video AD 이벤트 리스너 설정 (선택사항)

/// <summary>
/// Register to events the reward video ad may raise.
/// </summary>
private void RegisterEvents(OAMRewardVideo ad)
{
    // Raised when an ad is loaded into the reward video ad.
    ad.OnLoaded += () =>
    {
        Debug.Log("Reward video ad loaded.");
    };

    // Raised when an ad fails to load into the reward video ad.
    ad.OnLoadFailed += (OAMError error) =>
    {
        Debug.LogError("Reward video ad failed to load an ad with error : " + error);
    };

    // Raised when an ad opened full screen content.
    ad.OnOpened += () =>
    {
        Debug.Log("Reward video ad has been opened.");
    };

    // Raised when the ad failed to open full screen content.
    ad.OnOpenFailed += (OAMError error) =>
    {
        Debug.LogError("Reward video ad failed to open an ad with error : " + error);
    };

    // Raised when the ad closed full screen content.
    ad.OnClosed += () =>
    {
        Debug.LogError("Reward video ad is closed.");
    };

    // Raised when the ad completed full screen content.
    ad.OnCompleted += (int adNetworkNo, bool compledted) =>
    {
        Debug.Log("Reward video ad completed : " + "adNetworkNo=" + adNetworkNo + ", compledted=" + compledted);
    };

    // Raised when a click is recorded for an ad. on completed 에서 completed 가 true 일 때만 리워드 지급
    ad.OnClicked += () =>
    {
        Debug.Log("Reward video ad was clicked.");
    };
}

리워드 비디오 광고 생성하기

모든 설정을 완료하고 OAMInterstitialVideo를 만듭니다.

// These ad units are configured to always serve test ads.   
private readonly string _placementId = "string your placement ID";

_rewardVideoAd.Create(_placementId);

리워드 비디오 광고 로드 하기

리워드비디오 광고 Load() API를 호출하여 서버에 광고를 요청합니다.

/// <summary>
/// Loads the ad.
/// </summary>
public void Load()
{
    if (_rewardVideoAd == null)
    {
        Debug.LogWarning("The reward video ad is null.");
        return;
    }

    _rewardVideoAd.Load();
}

과도한 광고 요청은 차단 사유가 되니 주의해주세요!

리워드 비디오 광고 노출하기

광고 로드가 완료되면 광고를 노출을 원하는 시점에 Show() API를 호출하여 화면에 노출 시킵니다.

/// <summary>
/// Shows the ad.
/// </summary>
public void Show()
{
    if (_rewardVideoAd != null && _rewardVideoAd.IsLoaded())
    {
        Debug.Log("Showing reward video ad.");
        _rewardVideoAd.Show();
    }
    else
    {
        Debug.LogError("The reward video ad hasn't loaded yet.");
    }
}

리워드 비디오 광고 메모리 해지하기

광고의 인스턴스 내의 메모리를 해지 합니다.

/// <summary>
/// Destroys the ad.
/// </summary>
public void Destroy()
{
    if (_rewardVideoAd != null)
    {
        Debug.Log("Destroying reward video ad.");
        _rewardVideoAd.Destroy();
        _rewardVideoAd = null;
    }
}

보상형 비디오 광고 로드 여부 체크하기

보상형 비디오 광고의 로드 여부를 체크합니다. (return ture | false)

_rewardVideoAd.IsLoaded();

어플리케이션의 라이프사이클 확장하기

광고가 노출되고 있는 어플리케이션의 onPause / onResume여부를 체크하기 위해 구현해야 합니다.

public class RewardVideoAdController : MonoBehaviour
{
    void OnApplicationPause(bool pauseStatus)
    {
        // You should call events for pause and resume in the application lifecycle.
        _rewardVideoAd?.OnPause(pauseStatus);
    }
}

주의사항

미 처리시, third-party mediation을 사용에서 리포트 수치가 누락되는 경우가 발생합니다.

CS 페이지 호출

광고 CS 페이지를 노출 시키는 API 입니다.

string userId = "bXlBY2NvdW50X25hbWU";
ONEAdMaxClient.OpenRewardVideoCSPage(userId);

미디에이션 설정

안정적인 Fill-rate 및 eCPM을 위해 AppLovin, Unityads, Vungle의 미디에이션 작업을 추천합니다.

04. Unity-Plugin Guide
ONE AdMax SDK Error Codes
📌미디에이션 시작하기