Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Admob Ads not Showing if Installed from PlayStore

Discussion in 'Scripting' started by Corpse0327, Oct 4, 2017.

  1. Corpse0327

    Corpse0327

    Joined:
    Oct 4, 2014
    Posts:
    26
    Hello everyone

    I am experiencing a problem which i think is weird. I added admob plugin to the game i am developing and started testing ads.

    When the release time came, i removed all the testing code and tested the results on my phone. The ads were visible at this stage.

    Then i uploaded the game to play store and installed the game from playstore. Things were looking fine, but suddenly i realised, that the ads were not showing up if installed from play store.

    Anyone who might know what could possibly causing such an error? Here is the code

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using GoogleMobileAds;
    4. using GoogleMobileAds.Api;
    5.  
    6. public class BannerAd : MonoBehaviour {
    7.     BannerView bannerView;
    8.  
    9.     private bool isLoaded = false;
    10.    
    11.     // Use this for initialization
    12.     void Start () {
    13.         RequestBanner();
    14.     }
    15.  
    16.     void OnDestroy ()
    17.     {
    18.         if (isLoaded)
    19.             bannerView.Destroy();
    20.     }
    21.  
    22.     private void RequestBanner()
    23.     {
    24. #if UNITY_EDITOR
    25.         string adUnitId = "unused";
    26. #elif UNITY_ANDROID
    27.         string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx";
    28. #elif UNITY_IPHONE
    29.         string adUnitId = "";
    30. #else
    31.         string adUnitId = "unexpected_platform";
    32. #endif
    33.  
    34.         // Create a 320x50 banner at the top of the screen.
    35.         bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
    36.         // Create an empty ad request.
    37.         AdRequest request = new AdRequest.Builder()
    38.             .Build();
    39.  
    40.         bannerView.OnAdLoaded += this.AdLoaded;
    41.  
    42.         // Load the banner with the request.
    43.         bannerView.LoadAd(request);
    44.     }
    45.  
    46.     public void AdLoaded(object sender, System.EventArgs e)
    47.     {
    48.         isLoaded = true;
    49.     }
    50. }
    Thanks in advance
     
  2. Sherian

    Sherian

    Joined:
    Jun 13, 2017
    Posts:
    2
    I have the same issue... finding out the solution but i failed :( if anyone has any idea ...please help
     
  3. truongquotuan

    truongquotuan

    Joined:
    Dec 11, 2017
    Posts:
    1
    I have the same issue. Please help.
     
  4. scorp2007

    scorp2007

    Joined:
    Aug 17, 2014
    Posts:
    54
    I have the same problem, although before that I had done several applications and everything was fine.