Skip to main content

Overview

Display backfill ads in WebView within your Flutter app by registering the WebView with the Adrop SDK using Adrop.registerWebView.

Prerequisites

Add the following packages to your project:
WebView backfill ads require adrop-ads-backfill to be configured on both Android and iOS. See Getting Started for setup instructions.

Platform Configuration

Configure the native platforms to enable backfill ads in WebView.
Add the following to android/app/src/main/AndroidManifest.xml:
AndroidManifest.xml
This configuration is required for backfill ads to work properly in WebView. Without it, backfill ads may not display.

Register WebView

Create a WebViewController, extract the platform-specific identifier, and register it with Adrop.registerWebView before loading content.

Getting the WebView Identifier

The webViewIdentifier is extracted differently per platform:
Call Adrop.registerWebView() before loading any web content. Load the URL only after registration is complete.

WebView Settings (For Ad Optimization)

Google states that default WebView settings are not optimized for ads. Verify the following per platform.

Android

When you call Adrop.registerWebView(), the Adrop native SDK automatically enables:
  • JavaScript
  • DOM Storage
  • Third-party cookies
  • Media playback without user gesture
Keep setJavaScriptMode(JavaScriptMode.unrestricted) as shown in the registration example above, and do not explicitly disable the settings listed above when customizing WebViewController.

iOS

WKWebView’s iOS defaults are generally suitable, but declare inline media playback via WebKitWebViewControllerCreationParams (already included in the registration example above):
Backfill ads in WebView requires adrop-ads-backfill module. If the module is not installed, registerWebView() is silently ignored.

Handling External URLs

If your app opens non-own-domain URLs in an external browser, you must ensure that ad resource requests (e.g., googleads.g.doubleclick.net) are not blocked. Ad resources such as iframes and scripts are loaded automatically by the ad SDK — they are not user-initiated navigations. Only redirect main frame navigations to an external browser.
Do not block or redirect all non-own-domain requests. Ad resources like googleads.g.doubleclick.net are loaded automatically during the backfill ad process and must be allowed to load within the WebView.

Banner Ads

Learn how to integrate banner ads

Reference

API reference

Examples

Example repository