Protected_The Ad Unit ID for this Gogole Mobile Ads ad.
Whether the advert is loaded and can be shown.
Snapshot of the loaded ad's response info, or null before load / after destroy.
ProtectedconstructorProtected_Protected_Protected_Protected_Listen to ad events. See AdEventTypes for more information.
Returns an unsubscriber function to stop listening to further events.
// Create InterstitialAd/RewardedAd
const advert = InterstitialAd.createForAdRequest('...');
const unsubscribe = advert.addAdEventListener(AdEventType.LOADED, () => {
});
// Sometime later...
unsubscribe();
The event type, e.g. AdEventType.LOADED.
A listener callback containing a event type, error and data.
Listen to ad events. See AdEventTypes for more information.
Returns an unsubscriber function to stop listening to further events.
// Create InterstitialAd/RewardedAd
const advert = InterstitialAd.createForAdRequest('...');
const unsubscribe = advert.addAdEventsListener(({ type, payload }) => {
});
// Sometime later...
unsubscribe();
A listener callback containing a event type, error and data.
Release native resources for this ad instance. Idempotent; safe to call from React effect cleanup.
Start loading the advert with the provided RequestOptions.
It is recommended you setup ad event handlers before calling this method.
Remove all registered event listeners.
Show the loaded advert to the user.
Uses two error channels:
.catch() (or try { await } catch).showOptions are structurally invalid (checked only on a
loaded ad with no show in flight, so otherwise the rejection comes
first). Fix the call site.The fullscreen hooks' show absorbs both channels.
// Create InterstitialAd/RewardedAd
const advert = InterstitialAd.createForAdRequest('...');
advert.addAdEventListener(AdEventType.LOADED, () => {
advert
.show({
immersiveModeEnabled: true,
})
.catch(console.warn);
});
OptionalshowOptions: AdShowOptions
An optional AdShowOptions interface.
StaticcreateCreates a new RewardedAd instance.
import { RewardedAd, RewardedAdEventType, TestIds } from 'react-native-google-mobile-ads';
const rewardedAd = RewardedAd.createForAdRequest(TestIds.REWARDED, {
requestAgent: 'CoolAds',
});
rewardedAd.addAdEventListener(RewardedAdEventType.LOADED, () => {
rewardedAd.show().catch(console.warn);
});
rewardedAd.addAdEventListener(RewardedAdEventType.EARNED_REWARD, (reward) => {
console.log('User earned reward of ', reward);
});
rewardedAd.load();
The Ad Unit ID for the Rewarded Ad. You can find this on your Google Mobile Ads dashboard.
OptionalrequestOptions: RequestOptions
Optional RequestOptions used to load the ad.
Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_Protected_
A class for interacting and showing Rewarded Ads.
An Rewarded advert can be pre-loaded and shown at a suitable point in your apps flow, such as at the end of a level in a game. The content of a rewarded advert can be controlled via your Google Mobile Ads dashboard. Typically users are rewarded after completing a specific advert action (e.g. watching a video or submitting an option via an interactive form). Events (such as the user earning a reward or closing a rewarded advert early) are sent back for you to handle accordingly within your application.
Example
First create a new Rewarded instance, passing in your Ad Unit ID from the Google Mobile Ads configuration console, and any additional request options. The example below will present a test advert, and only request a non-personalized ad.
Each advert needs to be loaded from Google Mobile Ads before being shown. It is recommended this is performed before the user reaches the checkpoint to show the advert, so it's ready to go. Before loading the advert, we need to setup event listeners to listen for updates from Google Mobile Ads, such as advert loaded or failed to load.
Event types match the
AdEventTypeorRewardedAdEventTypeinterface. The potential user reward for rewarded adverts are passed back to the event handler on advert load and when the user earns the reward.The rewarded advert will be presented to the user, and several more events can be triggered such as the user clicking the advert, closing it or completing the action.