react-native-google-mobile-ads
    Preparing search index...

    Interface GAMBannerAdProps

    An interface for a GAM Banner advert component.

    The GAMBannerAd 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 GAMBannerAd within your own View if you wish to apply custom props for use-cases such as positioning.

    import { GAMBannerAd, BannerAdSize, TestIds } from 'react-native-google-mobile-ads';

    function HomeScreen() {
    return (
    <GAMBannerAd
    unitId={TestIds.GAM_BANNER}
    sizes={[BannerAdSize.FULL_BANNER]}
    requestOptions={{
    requestNonPersonalizedAdsOnly: true,
    }}
    onAdLoaded={() => {
    console.log('Advert loaded');
    }}
    onAdFailedToLoad={(error) => {
    console.error('Advert failed to load: ', error);
    }}
    />
    );
    }
    interface GAMBannerAdProps {
        manualImpressionsEnabled?: boolean;
        maxHeight?: number;
        onAdClicked?: () => void;
        onAdClosed?: () => void;
        onAdFailedToLoad?: (error: Error & Partial<AdErrorPayload>) => void;
        onAdImpression?: () => void;
        onAdLoaded?: (
            dimensions: {
                height: number;
                responseInfo?: ResponseInfo;
                width: number;
            },
        ) => void;
        onAdOpened?: () => void;
        onAppEvent?: (appEvent: AppEvent) => void;
        onPaid?: PaidEventListener;
        onSizeChange?: (dimensions: { height: number; width: number }) => void;
        requestOptions?: RequestOptions;
        sizes:
            | (
                | BANNER
                | FULL_BANNER
                | LARGE_BANNER
                | LEADERBOARD
                | MEDIUM_RECTANGLE
                | ANCHORED_ADAPTIVE_BANNER
                | LARGE_ANCHORED_ADAPTIVE_BANNER
                | INLINE_ADAPTIVE_BANNER
                | WIDE_SKYSCRAPER
                | "FLUID"
            )[]
            | string[];
        unitId: string;
        width?: number;
    }

    Hierarchy

    Index
    manualImpressionsEnabled?: boolean

    Whether to enable the manual impression counting.

    After setting this value to true, call recordManualImpression() from the ref object.

    import { GAMBannerAd, BannerAdSize, TestIds } from 'react-native-google-mobile-ads';

    function HomeScreen() {
    const ref = useRef<GAMBannerAd>(null);

    const recordManualImpression = () => {
    ref.current?.recordManualImpression();
    }

    return (
    <GAMBannerAd
    ref={ref}
    unitId={TestIds.GAM_BANNER}
    sizes={[BannerAdSize.FULL_BANNER]}
    manualImpressionsEnabled={true}
    />
    );
    }
    maxHeight?: number

    Limit inline adaptive banner height. By default, inline adaptive banners instantiated without a maxHeight value have a maxHeight equal to the device height.

    onAdClicked?: () => void

    Called when a click is recorded for an ad

    onAdClosed?: () => void

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

    onAdFailedToLoad?: (error: Error & Partial<AdErrorPayload>) => void

    When an ad has failed to load. Additive reason / phase / responseInfo fields ride on the Error instance (Error & Partial<AdErrorPayload>) so existing (error: Error) => void handlers stay assignable under strictFunctionTypes.

    onAdImpression?: () => void

    Called when an impression is recorded for an ad.

    onAdLoaded?: (
        dimensions: {
            height: number;
            responseInfo?: ResponseInfo;
            width: number;
        },
    ) => void

    When an ad has finished loading.

    onAdOpened?: () => void

    The ad is now visible to the user.

    onAppEvent?: (appEvent: AppEvent) => void

    When an ad received Ad Manager specific app events.

    onSizeChange?: (dimensions: { height: number; width: number }) => void

    Called when ad size dimensions changed

    requestOptions?: RequestOptions

    The request options for this banner.

    sizes:
        | (
            | BANNER
            | FULL_BANNER
            | LARGE_BANNER
            | LEADERBOARD
            | MEDIUM_RECTANGLE
            | ANCHORED_ADAPTIVE_BANNER
            | LARGE_ANCHORED_ADAPTIVE_BANNER
            | INLINE_ADAPTIVE_BANNER
            | WIDE_SKYSCRAPER
            | "FLUID"
        )[]
        | string[]

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

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

    unitId: string

    The Google Mobile Ads unit ID for the banner.

    width?: number

    Sets the width for adaptive banners (inline and anchored). If not specified, the width defaults to the full device width.