Native Overlay Ads
Native Overlay ads are a specialized ad format that allows you to display a Native Ad on top of your app content. Unlike standard Native Ads that require you to build the UI yourself, Native Overlay ads use Templates to provide a consistent and easy-to-integrate experience, similar to other platforms.
Note
This format is ideal for games and apps that want native look-and-feel without the complexity of manual UI layout.
Prerequisites
Before you continue, do the following:
- Complete the Get started guide.
Always test with test ads
The following table contains ad unit IDs which you can use to request test ads. They have 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.
Implementation
The main steps to integrate native overlay ads are:
- Load the native ad
- Define the template style
- Render the template
- Listen to ad events
- Show/Hide or Destroy the ad
Load the native ad
Loading a native ad is accomplished using the load() method on the NativeOverlayAd class. You need to provide an ad unit ID, an AdRequest, NativeAdOptions, and a completion callback.
Define the template style
You can use NativeTemplateStyle to customize how the ad looks. There are two main templates available: SMALL and MEDIUM.
Ad Positions
You can place the ad in several predefined positions or a custom XY coordinate using the AdPosition class.
AdPosition.TOPAdPosition.BOTTOMAdPosition.CENTERAdPosition.TOP_LEFT/AdPosition.TOP_RIGHTAdPosition.BOTTOM_LEFT/AdPosition.BOTTOM_RIGHTAdPosition.custom(x, y)
Listen to ad events
To handle user interactions, you can use the ad_listener property of the NativeOverlayAd instance.
Show/Hide and Destroy
Once rendered, you can control the visibility of the ad or destroy it completely to free resources.
Best practices
- Destruction: Always call
destroy()when you no longer need the ad to prevent memory leaks on native platforms. - Background Loading: You can load ads in the background and only call
render_template()when you are ready to display them. - Template Choice: Use
SMALLtemplates for lists or tight spaces, andMEDIUMfor more prominent placements like level transition screens.
Additional resources
- Sample Project: See the
Nativetab for a full implementation.