Quantcast
Channel: Questions in topic: "admob"
Viewing all articles
Browse latest Browse all 137

admob ads not working in android

$
0
0
There is no problem C# Script. Also, Admob is working well in unity. But is not working in Android. This my C#Script using System.Collections; using System.Collections.Generic; using UnityEngine; using GoogleMobileAds.Api; public class BottomBanner : MonoBehaviour { private BannerView bannerView; public void Start() { // Initialize the Google Mobile Ads SDK. MobileAds.Initialize(initStatus => { }); this.RequestBanner(); } private void RequestBanner() { #if UNITY_ANDROID string adUnitId = "my banner id"; #elif UNITY_IPHONE string adUnitId = "ca-app-pub-3940256099942544/2934735716"; #else string adUnitId = "unexpected_platform"; #endif // Create a 320x50 banner at the top of the screen. this.bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the banner with the request. this.bannerView.LoadAd(request); } // Start is called before the first frame update } _ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using GoogleMobileAds.Api; public class replay : MonoBehaviour { private InterstitialAd interstitial; public Canvas myCanvas; private void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "my ads id"; #elif UNITY_IPHONE string adUnitId = "ca-app-pub-3940256099942544/4411468910"; #else string adUnitId = "unexpected_platform"; #endif // Initialize an InterstitialAd. this.interstitial = new InterstitialAd(adUnitId); // Called when the ad is closed. this.interstitial.OnAdClosed += HandleOnAdClosed; // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. this.interstitial.LoadAd(request); } public void ReplayGame() { RequestInterstitial(); //When you want call Interstitial show StartCoroutine(showInterstitial()); IEnumerator showInterstitial() { while(!this.interstitial.IsLoaded()) { yield return new WaitForSeconds(0.2f); } this.interstitial.Show(); myCanvas.sortingOrder = -1; } // if (this.interstitial.IsLoaded()) { // this.interstitial.Show(); // myCanvas.sortingOrder = -1; // } // SceneManager.LoadScene("Ready"); } public void HandleOnAdClosed(object sender, System.EventArgs args) { SceneManager.LoadScene("Ready"); } } This script converts scene when close ads

Viewing all articles
Browse latest Browse all 137

Trending Articles



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