Search code examples
androidunity-game-engineadmobads

Unity - Admob shows only real ads, even when trying to test


I'm trying to use my AdManager class that shows banner like so:

public static void ShowBanner()
{
    AdRequest request = new AdRequest.Builder()
            .AddTestDevice(AdRequest.TestDeviceSimulator)
            .AddTestDevice("MY_DEVICE_ID").Build();
    if (bannerAd != null)
    {
        bannerAd.Destroy();
    }

    bannerAd = new BannerView(bannerID, AdSize.SmartBanner, AdPosition.Top);
    bannerAd.LoadAd(request);
}

And I have the Interstitial ads called:

public static void ShowVideo()
{
    AdRequest request = new AdRequest.Builder()
            .AddTestDevice(AdRequest.TestDeviceSimulator)
            .AddTestDevice("MY_DEVICE_ID").Build();
    if (interst != null)
    {
        interst.Destroy();
    }

    interst = new InterstitialAd(videoID);
    interst.LoadAd(request);
    if (interst.IsLoaded())
    {
        interst.Show();
    }
}

Of course I have some viable string instead of "MY_DEVICE_ID" in the appropriate section. I got that by downloading an app named "Device ID" from Google Play and put the ID I got into the string. bannerID and videoID are viable strings as well, I got them by creating my admob account, though I don't have the app uploaded to Play yet.

The issue is that to my best knowledge this should only show me some test ads, but it actually gives me real ads when trying to use it on my tablet.

Note that I deploy by clicking "Build" inside Unity, copy the .apk to my device and install it.

What could cause the issue? In case of a wrong device ID it just gives real ads? How to get around it?


Solution

  • To make sure you are using test ads, it's the safest to actually use this method here.

    It's basically that you use the following IDs for ads:

    • Banner

    ca-app-pub-3940256099942544/6300978111

    • Interstitial

    ca-app-pub-3940256099942544/1033173712

    • Rewarded Video

    ca-app-pub-3940256099942544/5224354917

    • Native Advanced

    ca-app-pub-3940256099942544/2247696110

    • Native Express

    (Small template): ca-app-pub-3940256099942544/2793859312

    (Large template): ca-app-pub-3940256099942544/2177258514

    Instead of your own ad IDs.