Question by
trindade_99 · Nov 19, 2018 at 10:28 PM ·
androidadsadmobbanner
Banner Admod not always showing!
Hy im kinda wth a strange problem, I have this game for mobile (in testing on android) and it is not always showing my banner, sometimes it does show and sometimes not (on the same biuld that I have on my phone). Here is the code, if somebody could help me!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
public class Ad_Mob_Script2 : MonoBehaviour
{
private BannerView bannerView;
[SerializeField] private string appID = "ca-app-pub-1188220283344166~4305226342";
[SerializeField] private string bannerID = "ca-app-pub-1188220283344166/3159240602";
[SerializeField] private string regularAD = "ca-app-pub-1188220283344166/5726119223";
void Start()
{
this.RequestBanner();
}
private void Awake()
{
MobileAds.Initialize(appID);
}
public void OnClickShowBanner()
{
this.RequestBanner();
}
public void OnClickShowAd()
{
RequestRegularAD();
}
private void RequestRegularAD()
{
InterstitialAd AD = new InterstitialAd(regularAD);
AdRequest request = new AdRequest.Builder().Build();
AD.LoadAd(request);
AD.Show();
}
private void RequestBanner()
{
bannerView = new BannerView(bannerID, AdSize.Banner, AdPosition.Top);
AdRequest request = new AdRequest.Builder().Build();
bannerView.OnAdFailedToLoad += HandleOnAdFailedToLoad;
bannerView.LoadAd(request);
bannerView.Show();
}
public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
this.RequestBanner();
}
}
Comment