0
\$\begingroup\$

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();
      }
   }
}
\$\endgroup\$
0
\$\begingroup\$

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();
  }
}
\$\endgroup\$
  • \$\begingroup\$ thanks to reply when i put this code in my game. and check in my mobile ads not showing. still prob not solved \$\endgroup\$ – pradeep kumar Dec 7 '18 at 15:54
  • \$\begingroup\$ i too face this problem. in my caseafter placing this code AdRequest request = new AdRequest.Builder().Build(); the problem has been solved \$\endgroup\$ – Manoj Balaji M Dec 14 '18 at 5:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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