Wiki
Clone wikiREACT native plugin / fullscreenAds
Fullscreen Ads
All functions to create, reload and show fullscreen ads are included to RNAatkit module. So first you should import RNAatkit:
#!javascript import { RNAatkit, } from '@addapptr/react-native-aatkit'
When AATKit is already initialized, you can create fullscreen placement. Just call createPlacement function passing placement name and the size as RNAatkit.PlacementSize_Fullscreen. Please note that the placement name has to be constant after once defined and cannot change with every app restart.
#!javascript RNAatkit.createPlacement("Fullscreen", RNAatkit.PlacementSize_Fullscreen);
Then you can reload placement using reloadPlacement function:
#!javascript RNAatkit.reloadPlacement( "Fullscreen", (placementReloaded) => { console.log("placementReloaded " + placementReloaded); });
Also it's possible to let fullscreen ad be auto-reloaded by calling startPlacementAutoReload.
When fullscreen ad is loaded, you can show it calling showPlacement function.
#!javascript RNAatkit.showPlacement("Fullscreen", (interstitialShown) => { console.log("interstitialShown " + interstitialShown); });
RNAatkit callbacks
RNAatkit provides callbacks which might be useful, for example to get notified when fullscreen ad is loaded. To receive them, use NativeEventEmitter.
#!javascript import { RNAatkit, } from '@addapptr/react-native-aatkit' import { NativeEventEmitter } from 'react-native'; const aatkitEmitter = new NativeEventEmitter(RNAatkit); const subscriptionHaveAd = aatkitEmitter.addListener( 'AATKitHaveAd', (data) => console.log("AATKitHaveAd placementName " + data.placementName) ); const subscriptionNoAds = aatkitEmitter.addListener( 'AATKitNoAds', (data) => console.log("AATKitNoAds placementName: " + data.placementName) ); const subscriptionPauseForAd = aatkitEmitter.addListener( 'AATKitPauseForAd', (data) => console.log("AATKitPauseForAd placementName: " + data.placementName) ); const subscriptionResumeAfterAd = aatkitEmitter.addListener( 'AATKitResumeAfterAd', (data) => console.log("AATKitResumeAfterAd placementName: " + data.placementName) ); const subscriptionObtainedAdRules = aatkitEmitter.addListener( 'AATKitObtainedAdRules', (data) => console.log("AATKitObtainedAdRules fromTheServer: " + data.fromTheServer) ); const managedConsentNeedsUserInterface = aatkitEmitter.addListener( 'managedConsentNeedsUserInterface', () => { console.log("managedConsentNeedsUserInterface"); } ); const onManagedConsentCompletion = aatkitEmitter.addListener( 'onManagedConsentCompletion', () => { console.log("onManagedConsentCompletion"); } );
API
For more details about functions and callbacks of RNAatkit component, please see the API section on the home page.
Updated