- Home /
 
Google Admob Events not being called
I have a simple script that displays ads. When a rewarded video is watched I want to reward the user obviously, but the code inside "HandleOnAdRewarded" is never called. using UnityEngine; using UnityEngine.UI; using System.Collections.Generic; using GoogleMobileAds.Api; using System;
 public class AdManager : MonoBehaviour
 {
     public string APP_ID = "ca-app-pub-3681777380489381~9433518844";
 
     private BannerView bannerAd;
     private InterstitialAd interstitialAd;
     private RewardBasedVideoAd rewardVideoAd;
 
     public Text debugText;
     private void Start()
     {
         debugText.text = "";
         MobileAds.Initialize(initStatus => { });
         RequestBanner();
         RequestInterstitial();
         RequestVideoAd();
         Events(true);
     }
     private void OnDisable()
     {
         Events(false);
     }
 
     public void Events(bool subscribe)
     {
         if(subscribe)
         {
             rewardVideoAd.OnAdClosed += HandleOnAdClosed;
             rewardVideoAd.OnAdFailedToLoad += HandleOnAdFailedToLoad;
             rewardVideoAd.OnAdLeavingApplication += HandleOnAdLeavingApplication;
             rewardVideoAd.OnAdLoaded += HandleOnAdLoaded;
             rewardVideoAd.OnAdOpening += HandleOnAdOpening;
             rewardVideoAd.OnAdRewarded += HandleOnAdRewarded;
             rewardVideoAd.OnAdStarted += HandleOnAdStarted;
 
         }
         else
         {
             rewardVideoAd.OnAdClosed -= HandleOnAdClosed;
             rewardVideoAd.OnAdFailedToLoad -= HandleOnAdFailedToLoad;
             rewardVideoAd.OnAdLeavingApplication -= HandleOnAdLeavingApplication;
             rewardVideoAd.OnAdLoaded -= HandleOnAdLoaded;
             rewardVideoAd.OnAdOpening -= HandleOnAdOpening;
             rewardVideoAd.OnAdRewarded -= HandleOnAdRewarded;
             rewardVideoAd.OnAdStarted -= HandleOnAdStarted;
         }
     }
     void RequestBanner()
     {
         string banner_ID = "ca-app-pub-3940256099942544/6300978111";
         bannerAd = new BannerView(banner_ID, AdSize.SmartBanner, AdPosition.Bottom);
         AdRequest adRequest = new AdRequest.Builder()
 .AddTestDevice("2077ef9a63d2b398840261c8221a0c9b")
 .Build();
         //AdRequest adRequest = new AdRequest.Builder().Build();
         bannerAd.LoadAd(adRequest);
         debugText.text = "Requested banner ad";
     }
     public void RequestInterstitial()
     {
         string interstitial_ID = "ca-app-pub-3940256099942544/1033173712";
         interstitialAd = new InterstitialAd(interstitial_ID);
         AdRequest adRequest = new AdRequest.Builder()
 .AddTestDevice("2077ef9a63d2b398840261c8221a0c9b")
 .Build();
         //AdRequest adRequest = new AdRequest.Builder().Build();
         interstitialAd.LoadAd(adRequest);
         debugText.text = "Requested interstitial ad";
     }
     public void RequestVideoAd()
     {
         string video_ID = "ca-app-pub-3940256099942544/5224354917";
 
         rewardVideoAd = RewardBasedVideoAd.Instance;
         AdRequest adRequest = new AdRequest.Builder()
     .AddTestDevice("2077ef9a63d2b398840261c8221a0c9b")
     .Build();
         //AdRequest adRequest = new AdRequest.Builder().Build();
         rewardVideoAd.LoadAd(adRequest, video_ID);
         debugText.text = "Requested rewarded vidoe ad";
     }
     public void DisplayBanner()
     {
         bannerAd.Show();
         debugText.text = "Displaying banner ad";
     }
     public void DisplayInterstitial()
     {
         if(interstitialAd.IsLoaded())
         {
             interstitialAd.Show();
             debugText.text = "Displaying interstitial ad";
         }
 
     }
     public void DisplayVideoAd()
     {
         if (rewardVideoAd.IsLoaded())
         {
             rewardVideoAd.Show();
             debugText.text = "Displaying rewarded ad";
         }
 
     }
 
     //Events
     public event EventHandler<EventArgs> OnAdLoaded;
 
     public event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad;
 
     public event EventHandler<EventArgs> OnAdOpening;
 
     public event EventHandler<EventArgs> OnAdStarted;
 
     public event EventHandler<EventArgs> OnAdClosed;
 
     public event EventHandler<Reward> OnAdRewarded;
 
     public event EventHandler<EventArgs> OnAdLeavingApplication;
 
     public void HandleOnAdLoaded(object sender, EventArgs args)
     {
 
     }
     public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
     {
 
     }
     public void HandleOnAdOpening(object sender, EventArgs args)
     {
 
     }
     public void HandleOnAdStarted(object sender, EventArgs args)
     {
         debugText.text = "Started Ad";
     }
     public void HandleOnAdClosed(object sender, EventArgs args)
     {
         debugText.text = "Closed Ad";
         RequestVideoAd();
     }
     public void HandleOnAdRewarded(object sender, Reward args)
     {
  
         RequestVideoAd();
         debugText.text = "Watched rewarde video. Have a treart";
     }
     public void HandleOnAdLeavingApplication(object sender, EventArgs args)
     {
 
     }
 }
 
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by suIly · Aug 16, 2020 at 02:27 PM
It turns out the HandleOnAdClosed event was being called instead of the HandleOnAdRewarded, so I put all of my reward code inside of it.
Your answer