Skip to main content

Overview

Banner ads are rectangular ads displayed in a portion of the screen. They can be easily implemented using the AdropBanner component.

Key Features

  • Can be fixed at the top, bottom, or middle of the screen
  • Support for image and video ads
  • Support for automatic or manual ad loading
  • Ad event handling through callbacks
  • Provides ad metadata (creative ID, campaign ID, etc.)
Use test unit IDs in development: PUBLIC_TEST_UNIT_ID_320_100 or PUBLIC_TEST_UNIT_ID_320_50

AdropBanner Component

Props

string
required
Unit ID created in the Ad Control Console
ViewStyle
required
Banner style (width and height required)
boolean
default:"true"
Whether to automatically load ads when the component is mounted
boolean
default:"false"
Whether to use custom click handling. If set to true, the browser won’t automatically open on ad click.
{ width: number; height: number } | null
Explicit ad size to request from the server. When style.width is a number, adSize is automatically derived from the style dimensions ({ width: style.width, height: style.height }). When style.width is a string (e.g., '100%'), adSize defaults to null and the SDK uses responsive sizing. You generally do not need to set this prop manually.
(unitId: string, metadata?: AdropBannerMetadata) => void
Callback invoked when ad is successfully received
(unitId: string, metadata?: AdropBannerMetadata) => void
Callback invoked when user clicks the ad
(unitId: string, metadata?: AdropBannerMetadata) => void
Callback invoked when ad is displayed on screen
(unitId: string, errorCode?: string) => void
Callback invoked when ad reception fails
(unitId: string) => void
Callback invoked when a video ad starts playing
(unitId: string) => void
Callback invoked when a video ad finishes playing

Basic Usage

Automatically load the ad when the component is mounted.

Manual Load Using Ref

You can load ads at the desired time using ref.

Callback Functions

onAdReceived

Called when ad reception is successful.

onAdClicked

Called when user clicks the ad.

onAdImpression

Called when ad is displayed on screen.

onAdFailedToReceive

Called when ad reception fails.

onAdVideoStart

Called when a video ad starts playing.

onAdVideoEnd

Called when a video ad finishes playing.

AdropBannerMetadata

Type for ad metadata.
This information can be useful for ad analytics, tracking, and reporting.

Ad Sizes

Banner ads should have style dimensions that match the size set in the unit.

Common Banner Sizes

Using Fixed Size

Fitting to Screen Width

Using Responsive Size

If width is set as a string (e.g., '100%'), it works responsively, but if set as a number, that value is passed to the ad server to request ads of appropriate size.

Test Unit IDs

Use the following test unit IDs during development and testing.

Usage Example


Error Handling

Implement appropriate error handling when ad loading fails.

Managing Error State


Best Practices

1. Screen Visibility

Load ads when the banner is visible on screen.

2. Loading Indicator

Improve user experience during ad loading.

3. Managing Multiple Banners

Manage the state of each banner when using multiple banners.

4. Custom Click Handling

Use useCustomClick to handle ad clicks directly.

Complete Example

TypeScript Example

JavaScript Example


Backfill Ads

To use backfill ads, you must have the backfill dependency added to your native platforms (Android/iOS).
When backfill ads are enabled, the SDK automatically falls back to backfill ads when no direct ad is available. You can handle backfill-specific error codes in the onAdFailedToReceive callback.

Next Steps

Native Ads

Implement customizable native ads for your UI

Interstitial Ads

Implement full-screen interstitial ads

Popup Ads

Implement ads displayed in popup format

Reference

Reference types, methods, and error codes