Best practices
These recommendations help you get the most out of the SDK and avoid the integration mistakes that cause lost revenue, wasted requests or policy problems.
Initialization
Section titled “Initialization”-
Call
WortiseSdk.initializeonce, when the app starts, and wait for it to complete before using any ad. An ad requested before the SDK has been initialized fails withSDK_NOT_INITIALIZED. This also applies to theBannerAdwidget, which requests its ad as soon as it is added to the layout:bool _sdkReady = false;Future<void> _initializeSdk() async {await WortiseSdk.initialize('your app key');await ConsentManager.requestIfRequired();setState(() => _sdkReady = true);_interstitialAd.loadAd();}/* ... */// In the children of your layout: the banner is added only when the SDK is readyif (_sdkReady)SizedBox(height: 50,child: BannerAd(adUnitId: 'Wortise Ad Unit ID'),), -
Do not wait for the initialization before calling
runApp.WortiseSdk.initializecompletes after the SDK has downloaded its configuration, so awaiting it inmain()delays the first frame of the app for as long as the network takes. -
Apply the privacy settings before initializing the SDK.
AdSettings.setChildDirectedandAdSettings.setMaxAdContentRatingmust be called beforeWortiseSdk.initialize.
Consent and privacy
Section titled “Consent and privacy”- Request the user consent on every app launch, before loading the first ad. The SDK never shows the consent dialog on its own, and
ConsentManager.requestIfRequiredonly shows it when it is needed. See User consent. - Do not read the result of
requestIfRequiredas the user’s answer. The returned value only tells whether the dialog has been shown. UseConsentManager.canRequestPersonalizedAdsorConsentManager.canCollectDatato know what the user has granted. - On iOS, if your app requests the App Tracking Transparency authorization, do it before the first ad is requested. Requesting it is optional, and neither the plugin nor the iOS SDK shows this prompt. See App Tracking Transparency.
Loading ads
Section titled “Loading ads”-
Create each
InterstitialAd,RewardedAd,AppOpenAdandNativeAdLoaderonce, outside ofbuild(), and keep it in a field. Loading takes time, so an ad created at the moment it has to be shown will not be ready, and an object created inbuild()is created again on every rebuild. -
Use a single object for each ad unit ID. The events are delivered through a channel that is identified by the ad unit ID, and both objects share the same underlying ad: a second object with the same ID takes the events from the first one, and destroying either of them destroys the ad of both.
-
Do not call
loadAd()on an ad that is already loaded. A new load discards the ad that was ready to be shown, which wastes a filled request. CheckisAvailablefirst. -
Let the SDK load the next ad. A fullscreen ad can be shown only once. Set
reloadOnDismissed: trueinInterstitialAdandRewardedAd, orautoReload: trueinAppOpenAd, to load a new ad when the current one is dismissed. -
Do not retry immediately after a failed load. After a failed load of a fullscreen or native ad, the SDK applies a short cooldown during which
loadAd()is ignored and no event is sent. Wait before retrying, usingcooldownRemainingMsas the minimum delay:import 'dart:math';/* ... */_interstitialAd = InterstitialAd('Wortise Ad Unit ID', listener: (event, args) async {if (event == InterstitialAdEvent.FAILED_TO_LOAD) {final cooldown = await _interstitialAd.cooldownRemainingMs;Future.delayed(Duration(milliseconds: max(cooldown, 30000)),_interstitialAd.loadAd,);}});
Showing ads
Section titled “Showing ads”-
Check the value returned by
showAd(). It completes withfalsewhen there is no ad available, and in that case noFAILED_TO_SHOWorDISMISSEDevent is sent. If the app waits forDISMISSEDto continue (for example, to move to the next screen), it must continue by itself when the result isfalse:if (!await _interstitialAd.showAd()) {_continue();} -
Grant the reward of a rewarded ad only in the
COMPLETEDevent, and only when itssuccessargument istrue.SHOWNandDISMISSEDare also sent when the user closes the ad without completing it.
Banners
Section titled “Banners”- Give the
BannerAdwidget a parent with a bounded height. WithAdSize.MATCH_VIEWand the anchored adaptive size, the widget takes all the height of its parent until the ad has been loaded, which causes a layout error when the parent does not limit it, such as aColumnor aListView. - Do not recreate the widget to refresh or retry the ad. The banner refreshes automatically, and it also retries by itself after a failed load. Every new
BannerAdstate (for example, when itskeychanges or when it is rebuilt inside a different parent) creates a new banner and makes a new ad request. - Decide the parameters of the banner before adding it.
adUnitId,adSize,autoRefreshTimeandrequestParametersare read when the banner is created; changing them in a later rebuild has no effect. - Set
keepAlive: truefor banners inside scrollable lists. Otherwise the state of the widget is discarded when it scrolls out of the screen, and a new banner is created, with a new ad request, every time it comes back. - Express
autoRefreshTimein milliseconds. The valid range goes from30000to120000.
App open
Section titled “App open”-
Register the ad with
AppOpenManager.register. The defaultAppOpenManagerconstructor does not listen to the app lifecycle, so it never shows the ad. Only one manager can be registered at a time: a new registration replaces the previous one. -
Load the ad and enable
autoReloadwhen using the manager. The manager shows the ad only if it is already available when the app comes to the foreground; it does not load it:final appOpenAd = AppOpenAd('Wortise Ad Unit ID', autoReload: true)..loadAd();AppOpenManager.register(appOpenAd); -
Use the manual integration when the ad must not be shown on every return to the app. The manager shows the ad every time the app comes to the foreground while there is one available. With
tryToShowAd()the app decides when it is shown.
Native ads
Section titled “Native ads”- Register the native ad factory on Android and on iOS, with the same identifier that is passed to
NativeAdLoader.loadAd()throws an exception when the factory is not found. See Native. - Destroy every
NativeAdthat is no longer displayed. EachLOADEDevent delivers a newNativeAd. Calldestroy()on the previous one when it is replaced, and remove itsAdWidgetfrom the layout: anAdWidgetcannot display an ad that has been destroyed.
Releasing resources
Section titled “Releasing resources”- Call
destroy()on fullscreen ads, native ads and native ad loaders when they are no longer needed, typically in thedispose()method of theStatethat owns them. The plugin keeps each ad in memory until it is destroyed. Destroying aNativeAdLoaderdoes not destroy the ads it has delivered.
Testing
Section titled “Testing”-
Use test mode or the test ad units during development, and never click on real ads. Impressions and clicks made by the developers on real ads are invalid traffic and can get the account penalized.
-
Enable test mode only in debug builds. Test mode is not persisted, so it must be set on every launch before loading ads, and an app published with it enabled does not generate revenue:
await AdSettings.setTestEnabled(kDebugMode); -
Test the first launch after a fresh install, on both platforms. The SDK stores the app key after the first initialization, so an ad that is requested too early only fails the first time the app is opened.
Before you publish
Section titled “Before you publish”WortiseSdk.initializeis called with the app key of the app, and no ad is requested before it completes.AndroidManifest.xmlandInfo.plistcontain the Google App ID shown in the Wortise dashboard for the app.Info.plistcontains theSKAdNetworkItemslist and, if the app requests the tracking authorization, theNSUserTrackingUsageDescriptionkey.- Every ad uses its production ad unit ID: no
test-…ad unit is left in the code. - Test mode is disabled in release builds.
- The user consent is requested before the first ad is loaded.
- The result of
showAd()is checked, and the app continues when an ad is not available. - The reward of rewarded ads is granted only in
COMPLETEDwithsuccessset totrue. - Fullscreen ads, native ads and native ad loaders are destroyed when their screen is disposed.
- A release build has been tested on a real Android device and on a real iOS device, starting from a fresh install.
© 2026 Wortise. All rights reserved.