I have create a Unity game, 1st I add an AdMob interstitial ads script on game object then try on my main camera when I test in my mobile before publishing. It has worked like real time ads and mistakenly clicked it and earn 0.3 so I create new ad unit placed it on my game then published my game. But the ads are not showing in real time. No error was found in AdMob but 147 ad requests are shown in AdMob and ads are not visible when my game 1st scene opens.

Here is my interstitial ads script code:

using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;

public class AdmobScript : MonoBehaviour
{
   private InterstitialAd interstitial;

   private void RequestInterstitial()
   {
      #if UNITY_ANDROID
         string adUnitId = "ca-app-pub-3129337025883034/9036322***";
      #elif UNITY_IPHONE
         string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
      #else
         string adUnitId = "unexpected_platform";
      #endif

      // Create an interstitial.
      this.interstitial = new InterstitialAd(adUnitId);
      // Load an interstitial ad.
      this.interstitial.LoadAd(this.CreateAdRequest());
   }

   // Returns an ad request
   private AdRequest CreateAdRequest()
   {
      return new AdRequest.Builder().Build();
   }

   private void ShowInterstitial()
   {
      if (interstitial.IsLoaded())
      {
         interstitial.Show();
      }
   }

   public void Start()
   {
      RequestInterstitial();
   }

   void Gameover()
   {
      if(interstitial.isloaded){
        ShowInterstitial();
      }
   }
}
  • I started to edit to fix your code formatting, but it's not clear to me if the bold text entries are intentional or typos. You might want to read this post about basic code markdown or possibly the section of the Help Center that explains formatting. – Pikalek Dec 7 at 3:24
  • @Pikalek Thanks to help me sir if its possible can u send me code on gmail pradeep11dx@gmail.com if possible otherwise i will manage it .thank u again – pradeep kumar Dec 7 at 3:32
  • I wasn't editing it as part of an attempt to answer, I was editing to make it easier for others to read, answer & learn from. – Pikalek Dec 7 at 3:40

The ad need a Build request function. Execute the below code and run on the testing device. if you got test ads then surely it will open in play store version also. Then update the new build in play store.

private void RequestInterstitial()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3129337025883034/9036322***";
#elif UNITY_IPHONE
     string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
#else
     string adUnitId = "unexpected_platform";
#endif

// Create an interstitial.
this.interstitial = new InterstitialAd(adUnitId);
 // Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
this.interstitial.LoadAd(request);    
}

The ad calling method must be like this

private void GameOver()
{
  if (this.interstitial.IsLoaded()) {
    this.interstitial.Show();
  }else{
     RequestInterstial();
  }
}
  • thanks to reply when i put this code in my game. and check in my mobile ads not showing. still prob not solved – pradeep kumar Dec 7 at 15:54

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.