R
R
Refractor2019-11-01 14:54:14
C++ / C#
Refractor, 2019-11-01 14:54:14

Why aren't test ads showing?

Here is the code:

using UnityEngine;
using GoogleMobileAds.Api;

public class AdWarder : MonoBehaviour
{
   
    private string idAd;
    private string idApp;
    public bool testingMode = true;

    void Start()
    {  

    Invoke("Inin", 3f);

}

void Inin()
{
   #if UNITY_IPHONE
    idAd = "ca-app-pub-5530031616350650/9050313142";
    idApp = "ca-app-pub-5530031616350650~4969814946";
    
  #endif

  #if UNITY_ANDROID
    idAd = "ca-app-pub-5530031616350650/8717488269";
    idApp = "ca-app-pub-5530031616350650~1938109884";
    
  #endif
       
   
     //  MobileAds.Initialize(idApp);
}
     InterstitialAd ad;
    public void CallIAdd()
    {
      Debug.Log("Call");
        ad = new InterstitialAd("ca-app-pub-3940256099942544/1033173712");
        AdRequest request = new AdRequest.Builder()
  .AddTestDevice("8680DB4A01E89E6555855D4C9599A8D0")
  .Build();
        ad.LoadAd(request);
    }

    public void LoadAd()
    {
      Debug.Log("Load");
            ad.Show();
       
    }
}

At the beginning, Call is called, then Load is called. The cat writes to the log: This request is sent from a test device. and Interstitial was not ready to be shown. How is this corrected?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Gaydak, 2019-11-01
@MrMureno

ad - should contain a check - whether everything is ready and loaded.
you can't just immediately call "show ads"
in all the examples there on the update waiting or the like.
(it also requests, loads, caches .. and maybe you don’t have the Internet or block ads, so until the “baner / vidos is ready to show” flag is not there, you can’t call Show)
Update
I suggest looking here.
an example of how to wait for it to load, according to the callback, for google advertising.
https://developers.google.com/admob/unity/banner
you can also find out if there was an error and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question