Admob Reward Video Ads not calling event functions.

Hi.
I’m trying to add an Admob reward video ads to my android game. The ad displays fine but when I close the ad, the reward is never given. I’ve tested the code in the function and the works fine so I think the problem is that is isn’t getting called. Can anyone help me?

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
using GoogleMobileAds;
using GoogleMobileAds.Api;

public class textEdit : MonoBehaviour
{
   public Image lifeAdUI;
   static Image lifeAdUIStat;
   public Text adFailUI;
   static Text adFailUIStat;
   public Button lifeButton;

   private static RewardBasedVideoAd videoAd;
   static bool adTime = false;
   static bool adPlaying = false;
   static int pass = 0;
   bool watched;

  // Use this for initialisation
  void Start()
  {
    Button btn = lifeButton.GetComponent<Button>();
    btn.onClick.AddListener(VideoAd);

    videoAd = RewardBasedVideoAd.Instance;

    videoAd.OnAdFailedToLoad += HandleOnAdFailedToLoad;
    videoAd.OnAdOpening += HandleOnAdOpening;
    videoAd.OnAdClosed += HandleOnAdClosed;
    videoAd.OnAdRewarded += HandleOnAdReward;
    videoAd.OnAdLeavingApplication += HandleOnAdLeavingApplication;
    videoAd.OnAdLoaded += HandleOnAdLoaded;
    videoAd.OnAdStarted += HandleOnAdStarted;

    lifeAdUIStat = lifeAdUI;
    adFailUIStat = adFailUI;

  }

public static void LoadVideoAd()
{
#if UNITY_EDITOR
    string adUnitID = "unused";
#elif UNITY_ANDROID
    string adUnitID = "ca-app-pub-3025391748532285/9122766975";
#elif UNITY_IPHONE
    string adUnitID = "";
#else
    string adUnitID = "unexpected_platform";
#endif

    videoAd.LoadAd(new AdRequest.Builder().Build(), adUnitID);
    pass = pass + 1;

}

void VideoAd()
{
    if (videoAd.IsLoaded())
    {
        videoAd.Show();

    }
    else
    {
        //ad not loaded
    }
}

//Ad Events
public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
    if (pass < 2)
    {
        LoadVideoAd();
    }
    else
    {
        StartCoroutine(adFailCoro());
    }
}

 public void HandleOnAdOpening(object ssender, EventArgs args)
 {
    adPlaying = true;
 }

 public void HandleOnAdClosed(object sender, EventArgs args)
 {
    adPlaying = false;
    watched = true;

    if (watched == true)
    {
        control controlScript = GameObject.FindGameObjectWithTag("Control").GetComponent<control>();

        lifeAdUI.enabled = false;
        StartCoroutine(controlScript.ExtraLife());
    }
 }

 public void HandleOnAdReward(object sender, EventArgs args)
 {
    watched = true;
 }

 public void HandleOnAdLeavingApplication(object sender, EventArgs args)
 {

 }

  public void HandleOnAdLoaded(object sender, EventArgs args)
  {

  }

  public void HandleOnAdStarted(object sender, EventArgs args)
  {

  }
}

I have the same problem and when I add my code to try/catch block I get the message like “StartCoroutine_Auto_Internal can only be called from the main thread”. I think AdMob event listeners do not work on main thread and this gives error if any unity api specific function call happens.

To achieve this I found this really basic solution: GitHub - PimDeWitte/UnityMainThreadDispatcher: A simple, thread-safe way of executing actions (Such as UI manipulations) on the Unity Main Thread

It executes your code in main thread. It sounds may look like complicated but please read the readme file, it is really easy to use and saved my day in a minute :slight_smile:

I have the same problem. you found any solution?

Follow this https://github.com/unity-plugins/Unity-Admob
and have a try.

Try to put the function definition inside a bool.

private void Update()
    {
        if(closed==true)
        {
            SceneManager.LoadScene("GamePlay");
            Time.timeScale = 1;
            RewardBtn.interactable = true;
            RewardBtn.GetComponentInChildren<TextMeshProUGUI>().text = "Save Life";
            closed = false;
        }
    }

public void HandleOnRewardedAdClosed(object sender, EventArgs args)
    {
        closed = true;
        adReward.OnAdLoaded -= this.HandleOnRewardedAdLoaded;
        adReward.OnAdRewarded -= this.HandleOnAdRewarded;
        adReward.OnAdClosed -= this.HandleOnRewardedAdClosed;
    }

Hope this solves ur issue.