I am trying to integrate AdMobs into my unity 2D project (game is designed for mobile platforms).
After searching the web and answers here i could not find the solution to my problem.
When i port my game to each platform iOS works and displays the banner view.
Android does not display the banner view.
- I tried deleting and re importing the google package and still Android wont show the banner.
I did exactly what the google tutorial in this link describes. https://developers.google.com/admob/unity/start
But still no go Android won't display the banner view with the ad (tested on 2 seperate devices). Here is my code i added the appId string to both manifest and plist handlers in the project.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
using System;
public class GoogleAdsHandler:MonoBehaviour {
private BannerView bannerView;
// Use this for initialization
void Start () {
#if UNITY_ANDROID
string appId = Consts.ANDROID_AD_APPID;
#elif UNITY_IPHONE
string appId = Consts.IOS_AD_APPID;
#else
string appId = "unexpected_platform";
#endif
InitilizeAdMob ();
}
private void InitilizeAdMob () {
#if UNITY_ANDROID
string appId = Consts.ANDROID_AD_APPID;
#elif UNITY_IPHONE
string appId = Consts.IOS_AD_APPID;
#else
string appId = "unexpected_platform";
#endif
MobileAds.Initialize (appId);
this.RequestBanner ();
}
private void RequestBanner () {
#if UNITY_ANDROID
string adUnitId = Consts.ANDROID_BANNER_ID;
#elif UNITY_IPHONE
string adUnitId = Consts.IOS_BANNER_ID;
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
bannerView = new BannerView (adUnitId, AdSize.Banner, AdPosition.Bottom);
AdRequest request = new AdRequest.Builder ().Build ();
bannerView.LoadAd (request);
bannerView.Show ();
bannerView.OnAdLoaded += HandleOnAdLoaded;
}
public void HandleOnAdLoaded (object sender, EventArgs args) {
MonoBehaviour.print ("HandleAdLoaded event received");
}
}
This script is attached to a game object on my main menu scene.
Would appreciate help with the matter.
Kindest regards.
Rony.