message  Send Feedback

BannerAd

An interface for a Banner advert component.

Example

The BannerAd interface is exposed as a React component, allowing you to integrate ads within your existing React Native code base. The component itself is isolated, meaning any standard View props (e.g. style) are not forwarded on. It is recommended you wrap the BannerAd within your own View if you wish to apply custom props for use-cases such as positioning.

import { BannerAd, BannerAdSize, TestIds } from '@react-native-firebase/admob';
function HomeScreen() {
return (
<BannerAd
unitId={TestIds.BANNER}
size={BannerAdSize.FULL_BANNER}
requestOptions={{
requestNonPersonalizedAdsOnly: true,
}}
onAdLoaded={() => {
console.log('Advert loaded');
}}
onAdFailedToLoad((error) => {
console.error('Advert failed to load: ', error);
})
/>
);
}

Properties


Properties

onAdClosed

onAdClosed: Function;

Called when the user is about to return to the app after tapping on an ad.


onAdFailedToLoad

onAdFailedToLoad: Function;

When an ad has failed to load. Callback contains an Error.


onAdLeftApplication

onAdLeftApplication: Function;

Called when the user has left the application (e.g. clicking an advert).


onAdLoaded

onAdLoaded: Function;

When an ad has finished loading.


onAdOpened

onAdOpened: Function;

The ad is now visible to the user.


requestOptions

requestOptions?: RequestOptions;

The request options for this banner.


size

size: BannerAdSize | string;

The size of the banner. Can be a predefined size via BannerAdSize or custom dimensions, e.g. 300x200.

Inventory must be available for the banner size specified, otherwise a no-fill error will be sent to onAdFailedToLoad.


unitId

unitId: string;

The AdMob unit ID for the banner.


React Native Market

Looking for pre-built React Native apps to kick start your next project? Check out the React Native Market by Invertase.

Your purchases help support our open-source projects such as React Native Firebase. All items are currently 50% off to celebrate the release of React Native Firebase version 6.
shopping_cartVisit React Native Market