Overview
Display backfill ads in WebView within your Flutter app by registering the WebView with the Adrop SDK usingAdrop.registerWebView.
Prerequisites
Add the following packages to your project:Platform Configuration
Configure the native platforms to enable backfill ads in WebView.- Android
- iOS
Add the following to
android/app/src/main/AndroidManifest.xml:AndroidManifest.xml
Register WebView
Create aWebViewController, extract the platform-specific identifier, and register it with Adrop.registerWebView before loading content.
Getting the WebView Identifier
ThewebViewIdentifier 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 callAdrop.registerWebView(), the Adrop native SDK automatically enables:
- JavaScript
- DOM Storage
- Third-party cookies
- Media playback without user gesture
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 viaWebKitWebViewControllerCreationParams (already included in the registration example above):
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.
Related Documentation
Banner Ads
Learn how to integrate banner ads
Reference
API reference
Examples
Example repository