Best practices
This page gathers the practices that avoid the most common integration mistakes, together with the reason behind each one.
Initialization
Section titled “Initialization”- Initialize the SDK once, when the app starts. Call
RNWortiseSdk.initializefrom an effect of the root component, and never from the body of a component, where it would be executed again on every render. - Load the ads after the initialization. In the first launch of the app, an ad that is requested before calling
initializefails with theSDK_NOT_INITIALIZEDerror. From any other component,RNWortiseSdk.wait()returns aPromisethat is resolved once the SDK is ready. - Initialize from JavaScript even if Android is initialized natively. The native initialization in the
MainApplicationclass does not initialize the SDK on iOS.
useEffect(() => { RNWortiseSdk.wait().then(() => { RNWortiseInterstitial.setAdUnitId('Wortise Ad Unit ID'); RNWortiseInterstitial.loadAd(); });}, []);Consent and privacy
Section titled “Consent and privacy”- Request the consent before loading the first ad. The SDK never shows the consent dialog on its own: call
RNWortiseConsentManager.requestIfRequired()when the app starts, so the ad requests already include the choice of the user. - Request it from a component. The dialog needs a visible screen. If there is none (for example, while the JavaScript code is being loaded), the
Promiseis resolved withfalseand nothing is shown. - Do not read the resolved value as the answer of the user. It only indicates if the dialog has been shown.
- Use
request()only for a settings option. It always shows the dialog, whilerequestIfRequired()only shows it when it is needed. - 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 SDK shows this prompt. See SDK integration.
- Set the child-directed treatment and the content rating before initializing the SDK. See Privacy.
Loading ads
Section titled “Loading ads”- Call
setAdUnitId()once per format, beforeloadAd().loadAd()does nothing until an ad unit has been set, and every call tosetAdUnitId()discards the ad that was already loaded. - Use a single ad unit per fullscreen format.
RNWortiseInterstitial,RNWortiseRewardedandRNWortiseAppOpenhold one ad each, so alternating between two ad units discards the loaded ads. - Set the ad unit from an effect, not at module level. On Android, the ad is released when the activity is destroyed. Code at module level is not executed again when the activity is created again, so
loadAd()would no longer do anything. - Do not call
loadAd()while an ad is already loaded. The loaded ad is discarded and a new one is requested, so calling it on every screen or render wastes the ads that were ready to be shown. - Load the next ad when the previous one is dismissed. A fullscreen ad can only be shown once. For App Open ads,
setAutoReload(true)does this automatically. - Do not call
loadAd()again right after a failure. After a failed load, the SDK ignores the new requests during a cooldown (30 seconds by default) and no event is sent for them. TheisInCooldownandcooldownRemainingMsgetters report this state.
Showing ads
Section titled “Showing ads”- Use
awaitwith the getters.isAvailable,isShowingandisInCooldownreturn aPromise, so a condition withoutawaitis always true. - Check
isAvailablebefore callingshowAd(). If there is no ad available, nothing is shown and no event is sent, so a flow that waits for the dismissed event would never continue. The value thatshowAd()resolves with does not indicate if the ad has been shown. - Grant the reward in
onRewardedCompleted, whensuccessistrue. The dismissed and shown events are also sent when the user has not completed the ad.
if (await RNWortiseRewarded.isAvailable) { RNWortiseRewarded.showAd();} else { // Continue without showing the ad}Banners
Section titled “Banners”- Call
loadAd()through the reference of the component.WortiseBannerdoes not load an ad when it is mounted or when its properties change. - Do not call
loadAd()fromonFailedToLoad. The banner already retries by itself after one minute, and refreshes its ad automatically. - Specify
autoRefreshTimein milliseconds. The SDK keeps the value between 30 and 120 seconds. - Read the data of the listeners from
nativeEvent. For example,event.nativeEvent.nameinonFailedToLoad. - Pass an integer width to the adaptive sizes. On iOS, a width with decimals makes the banner not load. Use
Math.floor(width). - Keep the banner mounted. Every time a
WortiseBanneris mounted (for example, in the rows of a list or in a conditional block), a new banner is created and a new ad is requested.
App Open
Section titled “App Open”- Show the ad when the app returns from the background. The plugin has no component that does it automatically, so use
AppStatetogether withtryToShowAd(), which shows the ad if it is available and requests a new one otherwise. - Do not show it when the app returns from another fullscreen ad. On Android,
AppStatealso changes tobackgroundand back toactivewhile an interstitial or rewarded ad is displayed. Skip that case (for example, with a flag that is set before calling theirshowAd()method), or two ads would be shown in a row.
const appState = useRef(AppState.currentState);
// Set to true before showing an interstitial or rewarded adconst skipNextAppOpen = useRef(false);
useEffect(() => { const subscription = AppState.addEventListener('change', (nextState) => { if (appState.current === 'background' && nextState === 'active') { if (!skipNextAppOpen.current) { RNWortiseAppOpen.tryToShowAd(); }
skipNextAppOpen.current = false; }
appState.current = nextState; });
return () => subscription.remove();}, []);Native ads
Section titled “Native ads”- Register the factory on both platforms with the same identifier. If no factory is registered with the identifier passed to
WortiseNativeAdView, the component is displayed empty and no error is reported. - Destroy the ads that are no longer displayed. Each
WortiseNativeAdkeeps its native resources untildestroy()is called, including when the component is unmounted. - Give the media view at least 120x120. Smaller sizes make the ad ineligible for video demand.
Listeners and cleanup
Section titled “Listeners and cleanup”- Register the listeners in an effect and remove them in its cleanup.
addEventListeneradds a new listener on every call, so registering it in the body of a component multiplies the callbacks (and the rewards) on every render. - Do not use
removeAllListeners()from a component. It also removes the listeners that other components have registered for that event.
useEffect(() => { const subscription = RNWortiseInterstitial.addEventListener('onInterstitialDismissed', () => { RNWortiseInterstitial.loadAd(); });
return () => subscription.remove();}, []);Testing
Section titled “Testing”- Use the test ad units or the test mode during development. This way, the development of the app does not generate impressions and clicks on real ads.
- Enable the test mode with
RNWortiseAdSettings.setTestEnabled(__DEV__). The value is not stored, so it must be set on every launch, and__DEV__keeps it disabled in the release builds. - Test on a real build of both platforms. The SDK contains native code, so it does not work in Expo Go.
Before you publish
Section titled “Before you publish”- The Google App ID of each platform is the one shown in the Wortise dashboard.
- On iOS, the
Info.plistfile contains theSKAdNetworkItemskey and, if the app requests the tracking authorization, theNSUserTrackingUsageDescriptionkey. - The app uses its own ad unit IDs (none of the
test-ones) and the test mode is disabled in the release build. - The consent is requested when the app starts, before loading the first ad.
- The SDK is initialized once from JavaScript, and the ads are loaded after it.
- Every banner calls
loadAd(), and every fullscreen ad checksisAvailablewithawaitbefore being shown. - The reward is only granted in
onRewardedCompletedwhensuccessistrue. - The listeners are removed and the native ads are destroyed when their components are unmounted.
- The release build has been tested on both platforms, and the SDK logs show that the ads are loaded.
© 2026 Wortise. All rights reserved.