1

When I build my application with Unity everything works fine. I had messages like:

Dummy LoadAd

But when I release my build in my device I do not receive any advertising. I published my application on Play Store and tested on several devices without results.

My unity version is 2018.3.3f1. And the code is blocked in AdMob functions.

This is my code:

//request a banner
public void RequestBanner()
  {
    // These ad units are configured to always serve test ads.
#if UNITY_EDITOR
    string adUnitId = "unused";
#elif UNITY_ANDROID
    string adUnitId = "ca-app-pub-2202385704427937/3307508552";
#elif UNITY_IPHONE
    string adUnitId = "ca-app-pub-3940256099942544/2934735716";
#else
    string adUnitId = "unexpected_platform";
#endif

    // Clean up banner ad before creating a new one.
    if (this.bannerView != null)
    {
        this.bannerView.Destroy();
    }

    // Create a 320x50 banner at the top of the screen.
    this.bannerView = new BannerView(adUnitId, AdSize.SmartBanner, 
 AdPosition.Top);

    // Register for ad events.
    this.bannerView.OnAdLoaded += this.HandleAdLoaded;
    this.bannerView.OnAdFailedToLoad += this.HandleAdFailedToLoad;
    this.bannerView.OnAdOpening += this.HandleAdOpened;
    this.bannerView.OnAdClosed += this.HandleAdClosed;
    this.bannerView.OnAdLeavingApplication += 
    this.HandleAdLeftApplication;

    // Load a banner ad.
    this.bannerView.LoadAd(this.CreateAdRequest());
}


//request a interstitial video
public void RequestInterstitial()
  {
    // These ad units are configured to always serve test ads.
#if UNITY_EDITOR
    string adUnitId = "unused";
#elif UNITY_ANDROID
    string adUnitId = "ca-app-pub-2202385704427937/1308031170";
#elif UNITY_IPHONE
    string adUnitId = "ca-app-pub-3940256099942544/4411468910";
#else
    string adUnitId = "unexpected_platform";
#endif

    // Clean up interstitial ad before creating a new one.
    if (this.interstitial != null)
    {
        this.interstitial.Destroy();
    }

    // Create an interstitial.
    this.interstitial = new InterstitialAd(adUnitId);

    // Register for ad events.
    this.interstitial.OnAdLoaded += this.HandleInterstitialLoaded;
    this.interstitial.OnAdFailedToLoad += 
    this.HandleInterstitialFailedToLoad;
    this.interstitial.OnAdOpening += this.HandleInterstitialOpened;
    this.interstitial.OnAdClosed += this.HandleInterstitialClosed;
    this.interstitial.OnAdLeavingApplication += 
    this.HandleInterstitialLeftApplication;

    // Load an interstitial ad.
    this.interstitial.LoadAd(this.CreateAdRequest());
}


 //to show video
public void ShowInterstitial()
  {
    if (this.interstitial.IsLoaded())
    {
        this.interstitial.Show();
    }
    else
    {
        MonoBehaviour.print("Interstitial is not ready yet");
    }
  }
Derk Jan Speelman
  • 11,291
  • 4
  • 29
  • 45

2 Answers2

0

Unfortunately, i dont have 50 points to post this as a comment on your OP. Possible duplicate, but hey, if everything worked right with your Test Ads, then it is possible that you forgot to add payment details for Live Ads.

Nikola G.
  • 335
  • 1
  • 3
  • 9
0

i resolved my problem. I added these lines to android manifest

        <meta-data
        android:name="com.Company.laytonMiniGames"
        android:value="ca-app-pub- 
        2202385704427937~1064488595"/>