Rewarded Video - Atmosplay/AtmosplayAds-Unity Wiki

Create a Rewarded Ad object

using System;
using UnityEngine;
using AtmosplayAds.Api;
using AtmosplayAds.Common;
public class AtmosplayAdsDemoScript : MonoBehaviour
{
#if UNITY_ANDROID
  const string AtmosplayAds_App_ID_Rewarded = "Your_AtmosplayAds_App_ID_Rewarded_Android";
  const string AtmosplayAds_AdUnit_ID_Rewarded = "Your_AtmosplayAds_AdUnit_ID_Rewarded_Android";
#elif UNITY_IOS
  const string AtmosplayAds_App_ID_Rewarded = "Your_AtmosplayAds_App_ID_Rewarded_iOS";
  const string AtmosplayAds_AdUnit_ID_Rewarded = "Your_AtmosplayAds_AdUnit_ID_Rewarded_iOS";
#else
  const string AtmosplayAds_App_ID_Rewarded = "unexpected_platform";
  const string AtmosplayAds_AdUnit_ID_Rewarded = "unexpected_platform";
#endif

  RewardVideoAd rewardVideo;

  void Start() 
  {
    AdOptions adOptions = new AdOptionsBuilder()
      .SetChannelId("")
      .SetAutoLoadNext(true)
      .build();

    rewardVideo = new RewardVideoAd(AtmosplayAds_App_ID_Rewarded, AtmosplayAds_AdUnit_ID_Rewarded, adOptions);
    rewardVideo.OnAdLoaded += HandleRewardVideoLoaded;
    rewardVideo.OnAdFailedToLoad += HandleRewardVideoFailedToLoad;
    rewardVideo.OnAdStarted += HandleRewardVideoStart;
    rewardVideo.OnAdClicked += HandleRewardVideoClicked;
    rewardVideo.OnAdRewarded += HandleRewardVideoRewarded;
    rewardVideo.OnAdClosed += HandleRewardVideoClosed;
  }

  #region RewardVideo callback handlers
  public void HandleRewardVideoLoaded(object sender, EventArgs args)
  {
    print("===> HandleRewardVideoLoaded event received");
  }
  public void HandleRewardVideoFailedToLoad(object sender, AdFailedEventArgs args)
  {
    print("===> HandleRewardVideoFailedToLoad event received with message: " + args.Message);
  }
  public void HandleRewardVideoStart(object sender, EventArgs args)
  {
    print("===> HandleRewardVideoStart event received.");
  }
  public void HandleRewardVideoClicked(object sender, EventArgs args)
  {
    print("===> HandleRewardVideoClicked event received.");
  }
  public void HandleRewardVideoRewarded(object sender, EventArgs args)
  {
    print("===> HandleRewardVideoRewarded event received.");
  }
  public void HandleRewardVideoClosed(object sender, EventArgs args)
  {
    print("===> HandleRewardVideoClosed event received.");
  }
  #endregion
}

Request Rewarded Video

rewardVideo.LoadAd(AtmosplayAds_AdUnit_ID_Rewarded);

Determine If Rewarded Video Has Been Loaded

rewardVideo.IsReady(AtmosplayAds_AdUnit_ID_Rewarded)

Present Rewarded Video

if(rewardVideo.IsReady(AtmosplayAds_AdUnit_ID_Rewarded))
{
  rewardVideo.Show(AtmosplayAds_AdUnit_ID_Rewarded);
} 
⚠️ **GitHub.com Fallback** ⚠️