The Google Mobile Ads Mediation Test Suite lets you test whether you've correctly configured your app and ad units to be able to display ads from third-party networks through AdMob mediation.
This guide outlines how to use the Mediation Test Suite in your Unity app. The first step is integrating the tool into your app.
Prerequisites
Have the
GoogleMobileAds
Unity package in your Unity project.Target iOS 9.0 or higher.
Target Android SDK 4.1 (API level 16) or higher.
Installation
After downloading the Mediation Test Suite, with your Unity project open, double-click the Unity package and import the files into your project.
Once this is complete, you have integrated the
GoogleMobileAdsMediationTestSuite
into your Unity project.
Launching the Test Suite
To include the Test Suite into a script, you must first add the following imports:
using GoogleMobileAdsMediationTestSuite.Api;
Next, call MediationTestSuite.Show()
to launch the Test Suite.
private void ShowMediationTestSuite()
{
MediationTestSuite.Show();
}
Note that you need to have correctly configured your AdMob App ID for this to correctly show the Test Suite.
The Unity plugin provides a convenient wrapper to enable you to easily integrate and launch the Test Suite from the Unity environment. Once the Test Suite is launched, it looks the same as the iOS and Android Test Suites. Follow these respective guides for help navigating the Test Suite.
Knowing when the Test Suite is dismissed
If you want to be notified when the Test Suite is dismissed, you can register a
delegate to the MediationTestSuite.OnMediationTestSuiteDismissed
event
handler.
public void Start()
{
MediationTestSuite.OnMediationTestSuiteDismissed += this.HandleMediationTestSuiteDismissed;
}
public void HandleMediationTestSuiteDismissed(object sender, EventArgs args)
{
MonoBehaviour.print("HandleMediationTestSuiteDismissed event received");
}
One practical use case for this event is to know when to resume your game.
Enabling testing in production and non-development builds
By default, the Test Suite only launches in development / debug builds. This is meant to prevent end users from inadvertently launching the Test Suite. If you have a need to run the Test Suite on a device once it's in production, you should register your test device using the AdMob test device ID (retrieved from your console logs) prior to distributing the build.
Add your test device ID to your RequestConfiguration.TestDeviceIds
list :
RequestConfiguration requestConfiguration = new RequestConfiguration();
requestConfiguration.TestDeviceIds.Add("2077ef9a63d2b398840261c8221a0c9b");
MobileAds.SetRequestConfiguration(requestConfiguration);
When including the Test Suite in a production app, you need a hidden way to launch the Test Suite (such as a secret gesture or a hidden debug menu). You can then launch the Test Suite on any device that's on the test device list.
Configuring ad requests with network extras (optional)
Certain mediated networks, such as
Liftoff Monetize,
let you send a custom network extras object to their network. If you need to
provide network extras for your mediation requests, you can set an ad request
for the Test Suite to use through the MediationTestSuite.AdRequest
static
property:
AdRequest adRequest = new AdRequest();
...
// Set your network extras for your chosen networks here.
// For each network extras object, call
// adRequest.MediationExtras.Add(<network extras>).
...
MediationTestSuite.AdRequest = adRequest;
Ensure that you do this before calling MediationTestSuite.Show()
. You can then
instantiate and configure an ad request with any required extras, which the Test
Suite can then use in its request to the mediated network.
Frequently Asked Questions
- Does the disclaimer show every time?
- Yes, we do this intentionally as a reminder that pubs should turn on test mode for their mediation ad sources.
- Why do I see AdMob multiple times on the Ad Unit details page?
- If multiple mediation groups target the same ad unit, we combine all of the groups together. For example, you may see multiple AdMob entries and possibly multiple of other ad sources. Even inside the same mediation group, a mediation partner can be defined up to 3 times.
- Which networks / ad sources are supported by the Test Suite?
- The Test Suite works for all open source and versioned adapters as well as custom event adapters. The ad networks in our open source initiative are listed on our mediation page.