Hey guys !
I have been trying to set ads in my game for weeks ! Nothing has been working. I’ve followed multiple tutorials, have tried using different apps. I don’t know what’s wrong. I’m testing the games on my own android device, but nothing pops up, whether its banner or interstitial. In the Unity Editor however, these messages appear :
Dummy .ctor
Dummy Initialize
Dummy .ctor
Dummy CreateBannerView
Dummy LoadAd
Dummy ShowBannerView
Yet nothing is happening. This is the code I’m using. I’ve tried different scripts and I made sure my appID and banner/interstitial Ids match properly.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
public class newBannerScript : MonoBehaviour {
[SerializeField] private string appId = "ca-app-pub-7879575665375462~2132697419";
[SerializeField] private string bannerID = "ca-app-pub-7879575665375462/7854868744";
[SerializeField] private string regularAD = "ca-app-pub-7879575665375462/8314962387";
InterstitialAd theAd;
public bool trying = false;
private BannerView bannerView;
public GameObject wall;
private void Awake()
{
MobileAds.Initialize(appId);
}
public void OnClickShowAd()
{
this.RequestRegularAD();
trying = true;
wall.SetActive(false);
}
public void OnClickShowBanner()
{
RequestBanner();
}
private void RequestBanner()
{
bannerView = new BannerView(bannerID, AdSize.Banner, AdPosition.Bottom);
AdRequest request = new AdRequest.Builder().Build();
bannerView.LoadAd(request);
bannerView.Show();
}
public void Update()
{
if (trying)
{
this.showAd();
}
}
private void RequestRegularAD()
{
InterstitialAd newAD = new InterstitialAd(regularAD);
AdRequest request = new AdRequest.Builder().Build();
Debug.Log(regularAD);
Debug.Log(appId);
newAD.LoadAd(request);
newAD.Show();
theAd = newAD;
}
public void showAd()
{
if (theAd.IsLoaded())
{
Debug.Log("SUCCESS");
trying = false;
theAd.Show();
}
}
}
I know this script is ridiculously messy but I’m desperately trying to show anything on my screen. I don’t even get errors. Another thing that I noticed that was pretty weird is that Google Admob sent me an e-mail telling me I’m showing ads. The requests are registered on my admob. So if it’s registering the requests, it means its properly connected. Why aren’t ads showing ? I’m so confused.