ONEAdMax initialization is required before loading ads.
The ONEAdMaxClient.Initialize() should be performed only once.
...usingONEAdMax;...publicclassONEAdMaxDemo:MonoBehaviour{privatestaticbool _isInitialized =false;voidStart() {if (!_isInitialized) { // Initialize the ONEAdMax SDK.ONEAdMaxClient.Initialize(() => { // This callback is called once the ONEAdMax SDK is initialized. _isInitialized =true }); } }}
User identifier setting
It is used to identify users for reward distribution when they complete watching a reward video.
Each user should have a unique user identifier that is not a variable value.
It should not include personal information (such as email, name, phone number, or identifiable user IDs).
If the identifier contains Korean, special characters, or spaces, it must be URL encoded before use.
The user identifier should be set before the user enters the ad.
Reward Video AD Sample Code
You can create an OAMRewardVideo instance and handle events to extend its functionality.
Create a Reward Video Ad instance
publicclassRewardVideoAdController:MonoBehaviour{OAMRewardVideo _rewardVideoAd /// <summary> /// Creates the ad. /// </summary>publicvoidCreateRewardVideoAd() {Debug.Log("Creating Reward video ad.");if (_rewardVideoAd !=null) {Debug.LogWarning("Already have a Reward video ad.");return; } _rewardVideoAd =newOAMRewardVideo(); }}
Network schedule timeout setting (optional)
Set the network schedule timeout for Reward Video Ads.
When loading the Reward Video Ad, you can set a timeout for each network. If the ad is not received within the specified time, it will move on to the next network.
Setting up event listeners for Reward Video Ads (optional)
/// <summary>/// Register to events the reward video ad may raise./// </summary>privatevoidRegisterEvents(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."); };}
Create a Reward Video Ad
Once all settings are complete, create theOAMInterstitialVideo.
// These ad units are configured to always serve test ads. privatereadonlystring _placementId ="string your placement ID";_rewardVideoAd.Create(_placementId);
Load the Reward Video Ad
Call the Load() API for the Reward Video Ad to request an ad from the server.
/// <summary>/// Loads the ad./// </summary>publicvoidLoad(){if (_rewardVideoAd ==null) {Debug.LogWarning("The reward video ad is null.");return; }_rewardVideoAd.Load();}
Excessive ad requests can result in a block, so please be careful!
Display the Reward Video Ad
Once the ad has finished loading, call the Show() API at the desired point to display the ad on the screen.
/// <summary>/// Shows the ad./// </summary>publicvoidShow(){if (_rewardVideoAd !=null&&_rewardVideoAd.IsLoaded()) {Debug.Log("Showing reward video ad.");_rewardVideoAd.Show(); }else {Debug.LogError("The reward video ad hasn't loaded yet."); }}
Destroys the ad
/// <summary>/// Destroys the ad./// </summary>publicvoidDestroy(){if (_rewardVideoAd !=null) {Debug.Log("Destroying reward video ad.");_rewardVideoAd.Destroy(); _rewardVideoAd =null; }}
Check if the Reward Video Ad has been loaded
Check the load status of the Reward Video Ad. (returns true | false)
_rewardVideoAd.IsLoaded();
Extending the application's lifecycle
You need to implement checking the onPause / onResume status of the application where the ad is being displayed.
publicclassRewardVideoAdController:MonoBehaviour{voidOnApplicationPause(bool pauseStatus) { // You should call events for pause and resume in the application lifecycle._rewardVideoAd?.OnPause(pauseStatus); }}
If not handled, it may result in missing report data when using third-party mediation.