setup

suspend fun setup(config: BannerConfig, path: String, location: String?, onClick: (String, EntityType) -> Unit)(source)

Setup the banner in the view by running an auction in the background.

Receiver

Parameters

config

a BannerConfig object that specifies the parameters for the auction

path

identifier for the activity where the banner is displayed. It's recommended to be the deeplink for the view.

location

optional name for the location within the view where the banner is displayed.

onClick

callback for when the banner is clicked. Usually this should navigate to an activity related to the banner (e.g. the product page for the product shown in the banner).


fun setup(winner: BannerResponse, path: String, location: String?, onClick: (String, EntityType) -> Unit)(source)

Display a banner you have already won, and report its impression and clicks.

Use this when the auction is yours to run - your own HTTP stack, your own auth, retries or telemetry, or a winner you resolved earlier and cached. Map whatever your auction returned onto BannerResponse and this view does the rest: loads the creative, reports the impression once the banner is on screen - not on layout, which happens below the fold too - and reports a click when it is tapped. Call from the main thread.

The point of this overload is that reporting stays here. The impression must fire once per resolved bid, when the ad is really on screen - not on every redraw, recomposition or view rebind - and getting that wrong is billable on a CPM campaign. Owning your auction should not mean owning that too.

No AuctionError is thrown or reported here, because no auction is run: you handled that before calling. onNoWinners is likewise never invoked - an absent winner means there is nothing to show, so do not call this at all.

Parameters

winner

the winning bid to display, from runBannerAuction or from your own auction.

path

identifier for the screen where the banner is displayed. Prefer the real route or deeplink - a constant here makes every per-page report collapse into one bucket.

location

optional name for the location within the screen where the banner is shown.

onClick

callback for when the banner is clicked, receiving the winner's entity id and type. Usually this navigates to whatever the banner advertises.