GreedyGameAds.Instance.LoadRewardAd("SDK X Reward adUnit");
// To check if Reward is loaded
GreedyGameAds.Instance.rewardAd.IsLoaded
using UnityEngine;
using GreedyGame;
public class GreedyGameAdsDemoScript : MonoBehaviour
{
private void Start()
{
//after Initialize the GreedygameAds sdk
this.LoadReward();
}
public void LoadReward()
{
GreedyGameAds.Instance.LoadRewardAd("SDK X Reward adUnit");
}
}
GreedyGameAds.Instance.ShowRewardAd(GetReward);
//callback when user close the reward Ad
public void GetReward(bool canReward)
{
//canReward = true if player watched full Ad
//canReward = false if player closed the Ad inbetween
}
public void WatchAdForExtraCoins()
{
. . .
. . .
this.ShowReward();
}
//After RewardAd Method Loaded
public void ShowReward()
{
GreedyGameAds.Instance.ShowRewardAd(GetReward);
}
public void GetReward(bool canReward)
{
if(canReward)
{
// Give Reward
}
else
{
// No Reward
}
}
GreedyGameAds.Instance.ShowRewardAd((bool canReward) =>
{
if(canReward)
{
// Give Reward
}
else
{
// No Reward
}
}
To further customize the behavior of your ad, you can hook into a number of events in the ad's lifecycle: loading, opening, closing, and so on. Listen for these events by registering a delegate for the appropriate EventHandler, as shown below
GreedyGameAds.Instance.rewardAd.OnAdloaded
GreedyGameAds.Instance.rewardAd.OnAdFailedToLoad
GreedyGameAds.Instance.rewardAd.OnAdOpened
GreedyGameAds.Instance.rewardAd.OnAdShowFailed
public void LoadRewardAd()
{
GreedyGameAds.Instance.LoadRewardAd("SDK X Reward adUnit");
// Called when an ad request has successfully loaded.
GreedyGame Ads.Instance.rewardAd.OnAdloaded += this.HandleOnAdLoaded;
// Called when an ad request failed to load.
GreedyGameAds.Instance.rewardAd.OnAdFailedToLoad= this.HandleOnAdFailedToLoad;
// Called when an ad is clicked.
GreedyGameAds.Instance.rewardAd.OnAdOpened+= this.HandleOnAdOpened;
// Called when the ad Failed to show
GreedyGameAds.Instance.rewardAd.OnAdShowFailed += this.HandleOnAdShowFailed;
}
public void HandleOnAdLoaded()
{
MonoBehaviour.print("HandleAdLoaded event received");
}
public void HandleOnAdFailedToLoad(string error)
{
MonoBehaviour.print("HandleFailedToLoadAd event received with message: " +error);
}
public void HandleOnAdOpened()
{
MonoBehaviour.print("HandleAdOpened event received");
}
public void HandleOnAdClosed()
{
MonoBehaviour.print("HandleAdClosed event received");
}
public void HandleOnAdShowFailed()
{
MonoBehaviour.print("HandleAdShowFailed event received");
}