- Home /
Admob rewarded video working in Unity but not on android device.
Twenty() ia a button ,in my game when i press it ,on the consoole it desplays :Dummy ShowRewardBasedVideoAd, but when i build the game and I press the button ,nothing happens (on the android device)
using System.Collections; using System.Collections.Generic; using UnityEngine; using GoogleMobileAds; using GoogleMobileAds.Api; using UnityEngine.SceneManagement;
public class videoAd : MonoBehaviour {
public static int Twen;
private RewardBasedVideoAd rewardBasedVideo;
// Use this for initialization
void Start () {
RequestInterstitial();
Twen = 15;
rewardBasedVideo = RewardBasedVideoAd.Instance;
rewardBasedVideo.OnAdRewarded += HandleOnReward;
}
// Update is called once per frame
void Update () {
}
public void Twenty()
{
ShowInterstitial();
}
private void ShowInterstitial()
{
if (rewardBasedVideo.IsLoaded())
{
rewardBasedVideo.Show();
}
}
private void RequestInterstitial()
{
if UNITY_EDITOR
string adUnitId = "unused";
elif UNITY_ANDROID
string adUnitId = " ca-app-pub-1324966xxxxxxxxxxxxxxxxxxxxx";
elif UNITY_IPHONE
string adUnitId = "ca-app-pub-39402560xxxxxxxxxxxxxxxxxxxx";
else
string adUnitId = "unexpected_platform";
endif
RewardBasedVideoAd rewardBasedVideo = RewardBasedVideoAd.Instance;
AdRequest request = new AdRequest.Builder().Build();
rewardBasedVideo.LoadAd(request, adUnitId);
}
public void HandleOnReward(object sender, Reward args)
{
PlayerPrefs.SetInt("Points", Gamecontroller.PointsNow + Twen);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}
Your code is hard to read without setting it as code properly. Also, is there supposed to be that extra space in the beginning of this string?
string adUnitId = " ca-app-pub-1324966749181630/6201228304";
I removed the space but it still doesn't work when i build it.
Your answer
Follow this Question
Related Questions
AdMob Rewarded Video Ad 0 Answers
how to remove vungle sdk properly from my unity project ? 0 Answers
Displaying Admob's banner ad in game scene 0 Answers
Can we show 3d ads in the game like on billboards? 0 Answers
Admob script help 0 Answers