Search Unity

Why does my AdMob banner not appear on my Samsung TabA?

Discussion in 'Scripting' started by Reverend-Speed, Sep 22, 2017.

  1. Reverend-Speed

    Reverend-Speed

    Joined:
    Mar 28, 2011
    Posts:
    284
    Hey folks,

    Doing a very basic test for AdMob banners. The app is some very simple UGUI, along with a tap counter. On top of this, I'm trying to display an AdMob banner - I've downloaded the plugin and I'm using sample code from this page, as follows:


    Code (CSharp):
    1. using System.Collections;
    2.     using System.Collections.Generic;
    3.     using UnityEngine;
    4.     using GoogleMobileAds.Api;
    5.  
    6.     public class AdmobTest : MonoBehaviour {
    7.  
    8.         // Use this for initialization
    9.         void Start () {
    10.             RequestBanner();
    11.         }
    12.    
    13.         // Update is called once per frame
    14.         void Update () {
    15.        
    16.         }
    17.  
    18.         public void RequestBanner()
    19.         {
    20.             Debug.Log("Banner Ad has been requested.");
    21.  
    22.         #if UNITY_EDITOR
    23.             string adUnitId = "unused";
    24.     #elif UNITY_ANDROID
    25.                 string adUnitId = "**ADMOB ID REMOVED FOR POSTING TO UNITY FORUMS**";
    26.     #elif UNITY_IPHONE
    27.                 string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
    28.     #else
    29.                 string adUnitId = "unexpected_platform";
    30.     #endif
    31.  
    32.             // Create a 320x50 banner at the top of the screen.
    33.             BannerView bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
    34.             // Create an empty ad request.
    35.             AdRequest request = new AdRequest.Builder().Build();
    36.             // Load the banner with the request.
    37.             bannerView.LoadAd(request);
    38.        
    39.             // bannerView.Show();
    40.         }
    41.     }
    At the moment, the app builds and loads on my tablet, the debug message (Debug.Log("Banner Ad has been requested.")) can be read in the Unity Console, but no banner is visible.

    Can anybody advise me on my next step? My intention is to ultimately use this code to display a banner ad above the restart / config buttons on the gameover screen of my app.

    Thank you in advance,

    --Rev
     
    Last edited: Sep 22, 2017