광고를 로드하기 전 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
});
}
}
}
개인정보( 이메일, 이름, 전화번호, 식별 가능한 유저 아이디 등 )가 포함되어서는 안됩니다.
한글, 특수문자, 공백 등이 포함된 경우에는 반드시 URL 인코딩 처리를 하여 사용하여야 합니다.
유저가 광고에 진입하기 전에 설정되어야 합니다.
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();
}
}
네트워크 스케줄 타임아웃 설정 (선택사항)
리워드 비디오 광고에 대한 네트워크 스케줄 타임아웃을 설정합니다.
리워드 비디오 광고 로딩 시 각 네트워크 별로 타임아웃 시간을 설정하여 해당 시간 안에 광고를 받지 못할 경우 , 다음 네트워크로 넘어갑니다.
/// <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을 사용에서 리포트 수치가 누락되는 경우가 발생합니다.