Admob Rewarded Video Help!! Please help me :( Still an issue :(
From my understanding, the coding is correct, the button to start the video works, however the advertisement is not loading in either editor, or the build.
I am receiving these dummy logs:
Dummy .ctor UnityEngine.Debug.Log(Object)
Dummy Initialize UnityEngine.Debug.Log(Object)
-Dummy .ctor UnityEngine.Debug.Log(Object)
-Dummy CreateRewardBasedVideoAd UnityEngine.Debug.Log(Object)
-Dummy LoadAd UnityEngine.Debug.Log(Object)
-Attached is the coding
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds;
using GoogleMobileAds.Api;
using UnityEngine.UI;
public class Admob : MonoBehaviour
{
private RewardedAd rewardedAd;
// Start is called before the first frame update
public void Start()
{
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(initStatus => { });
string adUnitId;
#if UNITY_ANDROID
adUnitId = "ca-app-pub-3940256099942544/5224354917";
#elif UNITY_IPHONE
adUnitId = "ca-app-pub-3940256099942544/1712485313";
#else
adUnitId = "unexpected_platform";
#endif
this.rewardedAd = new RewardedAd(adUnitId);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the rewarded ad with the request.
this.rewardedAd.LoadAd(request);
}
private void UserChoseToWatchAd()
{
if (this.rewardedAd.IsLoaded())
{
this.rewardedAd.Show();
}
}
}
You can try this :
public class Admob : $$anonymous$$onoBehaviour { private RewardedAd rewardedAd;
// Start is called before the first frame update
public void Start()
{
#if UNITY_ANDROID
string appId = "ca-app-pub-3940256099942544~3347511713";
#elif UNITY_IPHONE
string appId = "ca-app-pub-3940256099942544~1458002511";
#else
string appId = "unexpected_platform";
#endif
// Initialize the Google $$anonymous$$obile Ads SDK.
$$anonymous$$obileAds.Initialize(appId);
string adUnitId;
#if UNITY_ANDROID
adUnitId = "ca-app-pub-3940256099942544/5224354917";
#elif UNITY_IPHONE
adUnitId = "ca-app-pub-3940256099942544/1712485313";
#else
adUnitId = "unexpected_platform";
#endif
this.rewardedAd = new RewardedAd(adUnitId);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the rewarded ad with the request.
this.rewardedAd.LoadAd(request);
}
private void UserChoseToWatchAd()
{
if (this.rewardedAd.IsLoaded())
{
this.rewardedAd.Show();
}
}
}
Answer by ptct · Apr 04, 2020 at 03:45 AM
hi, I think you should use new API of abmob for unity here's the tutorial link: https://developers.google.com/admob/unity/rewarded-ads
It is the new API :((
Thank you for the response though :)
no it not, you are using the old API
private RewardBasedVideoAd rewardBasedVideo; >>> old
in the new API:
private RewardedAd rewardedAd; >>> new
Oh god sorry :( You are right... I will give it a shot right now. Thank you for catching that.
I will update if it works!
Your answer
![](https://koobas.hobune.stream/wayback/20220612230449im_/https://answers.unity.com/themes/thub/images/avi.jpg)