Search Unity

Reward video doesn't work (Admob)

Discussion in 'Unity Ads & User Acquisition' started by robisoftware, Mar 11, 2020.

  1. robisoftware

    robisoftware

    Joined:
    Jan 22, 2020
    Posts:
    23
    Hello guys , i just trying to make ad showing when i press a button , and receive some coins back(in my case) .
    This is my video reward script button . In Console its seem to be all okay , i will put a picture . I test also on my phone , when i press that button i receive a small message back with (AD IS NOT AVAILABLE AT THE MOMENT) . Thanks a lot for any help ..

    Code (CSharp):
    1. using GoogleMobileAds.Api;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class RewardedVideoButton : MonoBehaviour
    7. {
    8.     private const string ACTION_NAME = "rewarded_video";
    9.  
    10.     private void Start()
    11.     {
    12.         Timer.Schedule(this, 0.1f, AddEvents);
    13.     }
    14.  
    15.     private void AddEvents()
    16.     {
    17. #if UNITY_ANDROID || UNITY_IOS
    18.         if (AdmobController.instance.rewardBasedVideo != null)
    19.         {
    20.             AdmobController.instance.rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;
    21.         }
    22. #endif
    23.     }
    24.  
    25.     public void OnClick()
    26.     {
    27.         if (IsAvailableToShow())
    28.             AdmobController.instance.ShowRewardBasedVideo();
    29.         else if (!IsAdAvailable())
    30.             Toast.instance.ShowMessage("Ad is not available at the moment");
    31.         else
    32.         {
    33.             int remainTime = (int)(GameConfig.instance.rewardedVideoPeriod - CUtils.GetActionDeltaTime(ACTION_NAME));
    34.             Toast.instance.ShowMessage("Please wait " + remainTime + " seconds for the next ad");
    35.         }
    36.     }
    37.  
    38.     public void HandleRewardBasedVideoRewarded(object sender, Reward args)
    39.     {
    40.  
    41.     }
    42.  
    43.     public bool IsAvailableToShow()
    44.     {
    45.         return IsActionAvailable() && IsAdAvailable();
    46.     }
    47.  
    48.     private bool IsActionAvailable()
    49.     {
    50.         return CUtils.IsActionAvailable(ACTION_NAME, GameConfig.instance.rewardedVideoPeriod);
    51.     }
    52.  
    53.     private bool IsAdAvailable()
    54.     {
    55.         if (AdmobController.instance.rewardBasedVideo == null) return false;
    56.         bool isLoaded = AdmobController.instance.rewardBasedVideo.IsLoaded();
    57.         return isLoaded;
    58.     }
    59.  
    60.     private void OnDestroy()
    61.     {
    62. #if UNITY_ANDROID || UNITY_IOS
    63.         if (AdmobController.instance.rewardBasedVideo != null)
    64.         {
    65.             AdmobController.instance.rewardBasedVideo.OnAdRewarded -= HandleRewardBasedVideoRewarded;
    66.         }
    67. #endif
    68.     }
    69. }
    70.  
     
  2. robisoftware

    robisoftware

    Joined:
    Jan 22, 2020
    Posts:
    23
    i'm stuck here .. today i try to import again plugin , but the same result ..
     
  3. robisoftware

    robisoftware

    Joined:
    Jan 22, 2020
    Posts:
    23