<AdropBanner/>

Banner view component responsible for requesting banner ads and displaying them to the user.


Constructors

AdropBanner

AdropBanner({
    super.key,
    required this.unitId
})

Requires Ad unit ID


Props

Required Props

  • unitId: string

Ad unit ID

  • style: { height: number; width: number | string }

Ad unit size

Optional Props

  • autoLoad: boolean

AdropBanner component automatically requests ads. The default value is true.

  • onAdReceived: (unitId: string) -> void

Adrop will call onAdReceived callback with the ad unit ID when AdropBanner receives an ad.

  • onAdClicked: (unitId: string) -> void

Adrop will call onAdClicked callback with the ad unit ID when AdropBanner clicked.

  • onAdFailedToReceive: (unitId: string, errorCode?: any) -> void

Adrop will call onAdFailedToReceive callback with the ad unit ID and AdropErrorCode when AdropBanner fails to receive an ad.


Usage

Display AdropBanner

<AdropBanner
    unitId={unitId}
    style={{
        width: Dimensions.get('window').width,
        height: 80,
    }}
    onAdClicked={(unitId) => console.log("ad clicked", unitId)}
    onAdReceived={(unitId) => console.log("ad received", unitId)}
    onAdFailedToReceive={(unitId, error) => console.log("ad failed to receive, ", unitId, error)}
/>

Reload Ads using Ref

const ref = useRef(null)

const reload = () => {
    ref.current?.load()
}

// ..
<AdropBanner
    ref={ref}
    unitId={unitId}
    style={{ width: Dimensions.get('window').width, height: 80, }}
/>

Last updated