Native overlay ads

  • Native overlay ads in Unity are presented as customizable UI components that overlay the application, similar to banner ads but with more customization options.

  • Native overlay ads support mediation and video ads, offering an advantage over standard native ads.

  • To implement native overlay ads, you need to load the ad using the NativeOverlayAd.Load() method and then render and style it using a NativeTemplateStyle.

  • You can show, hide, and destroy the native overlay ad using dedicated methods on the loaded NativeOverlayAd object.

  • Always test with test ads using the provided ad unit IDs and configure your device as a test device during development.

Get started

Native overlay ads are presented to users through UI components that are native to the platform. These ads are presented as an overlay on top of the application. This is similar to how banner ads function, but with the ability to customize the appearance of the ads.

Native overlay ads support mediation and video ads. This is a key advantage native overlay ads have over native ads.

This guide shows you how to implement native overlay ads in a Unity app, as well as some important things to consider along the way.

Prerequisites

Before you continue, do the following:

Always test with test ads

The following sample code contains an ad unit ID which you can use to request test ads. It's been specially configured to return test ads rather than production ads for every request, making it safe to use.

However, after you've registered an app in the AdMob web interface and created your own ad unit IDs for use in your app, explicitly configure your device as a test device during development.

Android

ca-app-pub-3940256099942544/1033173712

iOS

ca-app-pub-3940256099942544/4411468910

Load the native overlay ad

Loading a native overlay ad is accomplished using the static Load() method on the NativeOverlayAd class. The loaded NativeOverlayAd object is provided as a parameter in the completion handler.

The following code uses NativeOverlayAd to load an ad:



  // These ad units are configured to always serve test ads.
#if UNITY_ANDROID
  private string _adUnitId = "ca-app-pub-3940256099942544/2247696110";
#elif UNITY_IPHONE
  private string _adUnitId = "ca-app-pub-3940256099942544/3986624511"