Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by saneesh44 · Jun 13, 2015 at 01:35 PM · androidadmobunity 4.6

Admob Interstitial ads are not showing up?

I want to show interstitial ads after 5 times of gameplay. I have written the below code and added it to a game object. So that when the user clicks the restart button 5 times (ie, after 5 gameplays) an interstitial ad should show up but its not. Banner ads are showing correctly but interstitial ads are not showing?

 using System; 
 using UnityEngine; 
 using GoogleMobileAds; 
 using GoogleMobileAds.Api;
     
     public class GoogleAdmob : MonoBehaviour {
     
     private int count; private BannerView bannerView; private InterstitialAd interstitial;
     
     void Start(){
     
       count = PlayerPrefs.GetInt("Count");
      
       RequestBanner ();
       RequestInterstitial ();
      
       bannerView.Show ();
       if (count > 5) {
           ShowInterstitial();
           count = 0;
           PlayerPrefs.SetInt ("Count", count);
      
       }
       count += 1;
       PlayerPrefs.SetInt ("Count", count);
      
     }
     
     void Update(){
     
       if(Input.GetKeyDown(KeyCode.Escape)){
           bannerView.Destroy();
           interstitial.Destroy();
           Application.LoadLevel("MainMenu");
       }
      
     }
     
     private void RequestBanner() {
     
       #if UNITY_ANDROID
       string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxxx";
       #elif UNITY_IPHONE
           string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
       #else
           string adUnitId = "unexpected_platform";
       #endif
      
       // Create a 320x50 banner at the top of the screen.
       bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);
       AdRequest request = new AdRequest.Builder().Build();
       
       // Register for ad events.
       bannerView.AdLoaded += HandleAdLoaded;
       bannerView.AdFailedToLoad += HandleAdFailedToLoad;
       bannerView.AdOpened += HandleAdOpened;
       bannerView.AdClosing += HandleAdClosing;
       bannerView.AdClosed += HandleAdClosed;
       bannerView.AdLeftApplication += HandleAdLeftApplication;
       // Load a banner ad.
       bannerView.LoadAd(request);
     }
     
     private void RequestInterstitial() {
     
       #if UNITY_ANDROID
       string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxxx";
       #elif UNITY_IPHONE
           string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
       #else
           string adUnitId = "unexpected_platform";
       #endif
      
       // Create an interstitial.
       interstitial = new InterstitialAd(adUnitId);
       AdRequest request = new AdRequest.Builder().Build();
      
       // Register for ad events.
       interstitial.AdLoaded += HandleInterstitialLoaded;
       interstitial.AdFailedToLoad += HandleInterstitialFailedToLoad;
       interstitial.AdOpened += HandleInterstitialOpened;
       interstitial.AdClosing += HandleInterstitialClosing;
       interstitial.AdClosed += HandleInterstitialClosed;
       interstitial.AdLeftApplication += HandleInterstitialLeftApplication;
       // Load an interstitial ad.
       interstitial.LoadAd(request);
     }
     
     // Returns an ad request with custom ad targeting.
     
     private void ShowInterstitial() { 
        if (interstitial.IsLoaded()) { 
               interstitial.Show(); 
            }
     
     }







Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Altered · Jun 13, 2015 at 07:50 PM 0
Share

I have this same problem on Unity 5.1, Banner ads work fine, interstitial ads won't show... Trying various methods but nothing has worked so far.

3 Replies

· Add your reply
  • Sort: 
avatar image
8
Best Answer

Answer by Altered · Jun 14, 2015 at 01:45 PM

For me the problem seems to happen because the interstitial ad takes a while to load (sometimes up to 3 seconds). You're trying to call it too fast, and it's not loaded, so nothing happens. What I did was continually try to show the interstitial ad in void Update until it shows (using a bool called shown):

 void Update () {
             if (shown == false) {
             ShowInterstitial();
             Debug.Log ("Not yet...");
             }      }
 public void ShowInterstitial()
 {
     if (interstitial.IsLoaded())
     {
         interstitial.Show();
         shown = true;
     } else    {
         Debug.Log ("Interstitial is not ready yet.");
     }    }

You could also load the ad at the beginning of the level, and then only call it when the round is over.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image anuraganand.hazaribag · Apr 25, 2016 at 07:11 AM 0
Share

Is it good to show Interstitial ads continusly? Is it falls under Ad$$anonymous$$ob guidelines or not?

avatar image lokvisnu · May 03, 2018 at 06:15 AM 0
Share

I too had the Same Problem with the Admob Interstitial Ads , Now it works prefectly. Thank You So so much. I will never Forget u in my life. Thanku thank u than...................................................................................... Thak u

avatar image aqib_ch_ · Sep 29, 2019 at 12:22 PM 0
Share

This answer is very helpful. and working thanks

avatar image VincenzoBrunale · Oct 26, 2020 at 09:31 PM 0
Share

Thank you Altered, you help for me. I wanna introduce a variant of your script.

When call show you can use StartCoroutine.It is better to wait and try every few milliseconds instead of every frame. This is to save compute, battery and CPU cycles

 //When you want call Interstitial show
 StartCoroutine(showInterstitial());
 
 IEnumerator showInterstitial()
     {
         while(!this.interstitial.IsLoaded())
         {
             Debug.Log("Si sta aspettando che l'interstitial sia caricato");
             yield return new WaitForSeconds(0.2f);
         }
         this.interstitial.Show();
     } 

StartCoroutine(showInterstitial());

 IEnumerator showInterstitial()
 {`
     while(!this.interstitial.IsLoaded())
     {
         Debug.Log("Si sta aspettando che l'interstitial sia caricato");
         yield return new WaitForSeconds(0.2f);
     }
     this.interstitial.Show();
 } 
avatar image
1

Answer by isrmicha · Jun 14, 2015 at 07:22 AM

are you using the right ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxxx for instertitial ? you create a full ad for your app in admob ?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image saneesh44 · Jun 14, 2015 at 08:11 AM 0
Share

I'm using my full ad id

avatar image
1

Answer by bigjobs · Feb 28, 2016 at 02:24 PM

download this last plugin https://github.com/unity-plugins/Unity-Admob and then add code

4.How to integrate Interstitial into Unity 3d app?

Here is the minimal banner code to create an interstitial.

 Admob.Instance().loadInterstitial(); 

Unlike banners, interstitials need to be explicitly shown. At an appropriate stopping point in your app, check that the interstitail is ready before showing it:

 if (Admob.Instance().isInterstitialReady()) {
   Admob.Instance().showInterstitial();
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to debug Android apps that use Admob 1 Answer

quit game if no internet access on android 1 Answer

Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define 0 Answers

My game crahses when I use it on a phone 0 Answers

Update the Android Gallery after take a screenshot from android device using unity3d 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges