I have two scripts implemented in my Unity project, the one for my Banner ad:
using GoogleMobileAds.Api;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Banner : MonoBehaviour
{
// Use this for initialization
void Start()
{
showBannerAd();
}
private void showBannerAd()
{
string adID = "ca-app-pub-9257400980294652/4995017052";
//***For Testing in the Device***
AdRequest request = new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator) // Simulator.
.AddTestDevice("3812AE58DCC9AA8") // My test device.
.Build();
//***For Production When Submit App***
//AdRequest request = new AdRequest.Builder().Build();
BannerView bannerAd = new BannerView(adID, AdSize.SmartBanner,
AdPosition.Bottom);
bannerAd.LoadAd(request);
}
}
and the on for my interstitial ads:
using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;
public class Interstitial1 : MonoBehaviour
{
bool hasShownAdOneTime;
// Use this for initialization
void Start()
{
//Request Ad
RequestInterstitialAds();
}
void Update()
{
if (SCORESCRIPT.scoreValue >= 0) //***this is just for the testing purposes ***
{
Invoke("showInterstitialAd", 3.0f);
}
}
public void showInterstitialAd()
{
//Show Ad
if (interstitial.IsLoaded())
{
interstitial.Show();
//Stop Sound
//
Debug.Log("SHOW AD XXX");
}
}
InterstitialAd interstitial;
private void RequestInterstitialAds()
{
string adID = "ca-app-pub-9257400980294652/4995017052";
#if UNITY_ANDROID
string adUnitId = adID;
#elif UNITY_IOS
string adUnitId = adID;
#else
string adUnitId = adID;
#endif
// Initialize an InterstitialAd.
interstitial = new InterstitialAd(adUnitId);
//***Test***
AdRequest request = new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator) // Simulator.
.AddTestDevice("3812AE58DCC9AA8") // My test device.
.Build();
//***Production***
//AdRequest request = new AdRequest.Builder().Build();
//Register Ad Close Event
interstitial.OnAdClosed += Interstitial_OnAdClosed;
// Load the interstitial with the request.
interstitial.LoadAd(request);
Debug.Log("AD LOADED XXX");
}
//Ad Close Event
private void Interstitial_OnAdClosed(object sender, System.EventArgs e)
{
//Resume Play Sound
}
}
I am using my real ad ID-s and my real test device ID. When I run the game in unity I get this as my Debug Log:
Dummy .ctor, Dummy CreateInterstitialAd, Dummy LoadAd, AD LOADED XXX
and for my banner ad:
Dummy .ctor, Dummy CreateBannerView, Dummy LoadAd,
I have no idea why my code doesn’t work on my device when the same code worked for the other people who used it in their games. If you have any other code recommendations feel free to share.
I am familiar with the fact that there are many similar threads all over the internet but none of them solved my problem successfully as I am very new to AdMob and Unity.