Quantcast
Channel: Questions in topic: "ads"
Viewing all articles
Browse latest Browse all 1416

Google Admob Ads not showing. Test ADS works well, but not my real AD ID

$
0
0
Everything work well if i use the test reward ad unit, but when i change to my own reward ad unit it is not showing up anymore. Why? Help? App got released already and i linked app in admob account. What else there is? using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; using GoogleMobileAds.Api; using NiobiumStudios; public class AdMobScript : MonoBehaviour { public Text adStatus; TimedRewardsInterface timedRewardsInterface; private int rewardAmount; private GameObject reward250; private GameObject reward750; bool isAdClosed = false; bool isRewarded = false; //string Rewarded_AD_ID = "ca-app-pub-3940256099942544/5224354917"; //TEST REWARDED AD ID string Rewarded_AD_ID = "MY REWARD ID HERE, CUT OUT"; private RewardedAd rewardedAd; void Start() { timedRewardsInterface = GetComponent(); MobileAds.Initialize(initStatus => { }); this.RequestRewardedAd(); } void Update() { if (isAdClosed) { if (isRewarded) { // do all the actions // reward the player switch (rewardAmount) { case 250: reward250 = GameObject.FindGameObjectWithTag("Reward250"); reward250.GetComponent().GiveReward(); //reward250.GetComponent().ClaimReward(0); break; case 750: reward750 = GameObject.FindGameObjectWithTag("Reward750"); reward750.GetComponent().GiveReward(); //reward750.GetComponent().ClaimReward(0); break; } isRewarded = false; } else { // Ad closed but user skipped ads, so no reward // Ad your action here switch (rewardAmount) { case 250: reward250 = GameObject.FindGameObjectWithTag("Reward250"); reward250.GetComponent().Reset(); break; case 750: reward750 = GameObject.FindGameObjectWithTag("Reward750"); reward750.GetComponent().Reset(); break; } } isAdClosed = false; // to make sure this action will happen only once. } } public void RequestRewardedAd() { this.rewardedAd = new RewardedAd(Rewarded_AD_ID); //EVENTS// // Called when an ad request has successfully loaded. this.rewardedAd.OnAdLoaded += HandleRewardedAdLoaded; // Called when an ad request failed to load. this.rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad; // Called when an ad is shown. this.rewardedAd.OnAdOpening += HandleRewardedAdOpening; // Called when an ad request failed to show. this.rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow; // Called when the user should be rewarded for interacting with the ad. this.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward; // Called when the ad is closed. this.rewardedAd.OnAdClosed += HandleRewardedAdClosed; //END OF EVENTS// // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the rewarded ad with the request. this.rewardedAd.LoadAd(request); } public void ShowRewardedAd(int rewardAmount) { this.rewardAmount = rewardAmount; //if (this.rewardedAd.IsLoaded()) //{ // this.rewardedAd.Show(); //} switch (rewardAmount) { case 250: reward250 = GameObject.FindGameObjectWithTag("Reward250"); reward250.GetComponent().GiveReward(); //reward250.GetComponent().ClaimReward(0); break; case 750: if (this.rewardedAd.IsLoaded()) { this.rewardedAd.Show(); } break; } } //EVENTS AND DELEGATES FOR ADS public void HandleRewardedAdLoaded(object sender, EventArgs args) { adStatus.text = "Ad Loaded"; } public void HandleRewardedAdFailedToLoad(object sender, AdErrorEventArgs args) { adStatus.text = "Ad Failed To Load" + args.Message; StartCoroutine(SubAndUnsubEvents()); } public void HandleRewardedAdOpening(object sender, EventArgs args) { adStatus.text = "Ad Opening"; } public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args) { adStatus.text = "Ad Failed To Show" + args.Message; StartCoroutine(SubAndUnsubEvents()); } public void HandleRewardedAdClosed(object sender, EventArgs args) { adStatus.text = "Ad Closed"; StartCoroutine(SubAndUnsubEvents()); isAdClosed = true; } public void HandleUserEarnedReward(object sender, GoogleMobileAds.Api.Reward args) { string type = args.Type; double amount = args.Amount; isRewarded = true; adStatus.text = "Rewarded " + amount.ToString() + " " + type; } private void OnDisable() { //EVENTS// // Called when an ad request has successfully loaded. this.rewardedAd.OnAdLoaded -= HandleRewardedAdLoaded; // Called when an ad request failed to load. this.rewardedAd.OnAdFailedToLoad -= HandleRewardedAdFailedToLoad; // Called when an ad is shown. this.rewardedAd.OnAdOpening -= HandleRewardedAdOpening; // Called when an ad request failed to show. this.rewardedAd.OnAdFailedToShow -= HandleRewardedAdFailedToShow; // Called when the user should be rewarded for interacting with the ad. this.rewardedAd.OnUserEarnedReward -= HandleUserEarnedReward; // Called when the ad is closed. this.rewardedAd.OnAdClosed -= HandleRewardedAdClosed; //END OF EVENTS// } IEnumerator SubAndUnsubEvents() { OnDisable(); yield return new WaitForSeconds(0.1f); RequestRewardedAd(); } }

Viewing all articles
Browse latest Browse all 1416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>