Adrop
Class for initializing the Adrop SDK and managing global settings.
initialize
static initialize(
production: boolean,
targetCountries?: string[],
useInAppBrowser?: boolean
): void
Initializes the Adrop SDK.
Parameters:
production (boolean): Production mode (true: production, false: development)
targetCountries (string[], optional): Target country code array (default: [])
useInAppBrowser (boolean, optional): Whether to use in-app browser (default: false)
Example:
import { Adrop } from 'adrop-ads-react-native'
Adrop.initialize(true, ['KR', 'US'], false)
setUID
static setUID(uid: string): void
Sets the unique user identifier.
Parameters:
uid (string): Unique user identifier
Example:
setTheme
static setTheme(theme: AdropTheme): void
Sets the app theme.
Parameters:
theme (AdropTheme): Theme value (‘light’, ‘dark’, ‘auto’)
Example:
import { Adrop, AdropTheme } from 'adrop-ads-react-native'
Adrop.setTheme(AdropTheme.dark)
registerWebView
static registerWebView(viewTag: number): Promise<void>
Registers a native WebView for backfill ad support. Call this after the WebView is mounted.
Parameters:
viewTag (number): Native view tag obtained via findNodeHandle() from the View wrapping the WebView
Example:
import { useEffect, useRef } from 'react'
import { findNodeHandle, View } from 'react-native'
import { Adrop } from 'adrop-ads-react-native'
const containerRef = useRef<View>(null)
useEffect(() => {
if (containerRef.current) {
const tag = findNodeHandle(containerRef.current)
if (tag != null) {
Adrop.registerWebView(tag)
}
}
}, [])
Requires adrop-ads-backfill module. If not installed, this call is silently ignored.
AdropTheme
Constant object for specifying app theme.
const AdropTheme = {
light: 'light',
dark: 'dark',
auto: 'auto',
} as const
type AdropTheme = (typeof AdropTheme)[keyof typeof AdropTheme]
Values:
light: Light theme
dark: Dark theme
auto: Follow system setting
BrowserTarget
Enum for specifying how ad destination URLs should be opened.
enum BrowserTarget {
EXTERNAL = 0,
INTERNAL = 1,
}
Values:
EXTERNAL: Open URL in external browser (default)
INTERNAL: Open URL in in-app browser
AdropErrorCode
Error codes that may occur during ad loading and display.
enum AdropErrorCode {
network = 'ERROR_CODE_NETWORK',
internal = 'ERROR_CODE_INTERNAL',
initialize = 'ERROR_CODE_INITIALIZE',
invalidUnit = 'ERROR_CODE_INVALID_UNIT',
notTargetCountry = 'ERROR_CODE_NOT_TARGET_COUNTRY',
inactive = 'ERROR_CODE_AD_INACTIVE',
adNoFill = 'ERROR_CODE_AD_NO_FILL',
adDuplicated = 'ERROR_CODE_AD_LOAD_DUPLICATED',
adLoading = 'ERROR_CODE_AD_LOADING',
adEmpty = 'ERROR_CODE_AD_EMPTY',
adShown = 'ERROR_CODE_AD_SHOWN',
adHideForToday = 'ERROR_CODE_AD_HIDE_FOR_TODAY',
adLandscapeUnsupported = 'ERROR_CODE_LANDSCAPE_UNSUPPORTED',
backfillNoFill = 'ERROR_CODE_AD_BACKFILL_NO_FILL',
undefined = 'UNDEFINED',
}
Error Codes:
network: Network error
internal: Internal error
initialize: SDK initialization error
invalidUnit: Invalid ad unit
notTargetCountry: Not a target country
inactive: Deactivated ad
adNoFill: No ad available
adDuplicated: Duplicate ad load request
adLoading: Ad is loading
adEmpty: Ad is empty
adShown: Ad already shown
adHideForToday: Ad hidden for today
adLandscapeUnsupported: Landscape mode not supported
backfillNoFill: Backfill ad not available
undefined: Undefined error
AdropBanner
React component for displaying banner ads.
Props
type AdropBannerProp = {
style: { height: number; width: number | string }
unitId: string
useCustomClick?: boolean
adSize?: { width: number; height: number } | null
autoLoad?: boolean
onAdReceived?: (unitId: string, metadata?: AdropBannerMetadata) => void
onAdImpression?: (unitId: string, metadata?: AdropBannerMetadata) => void
onAdClicked?: (unitId: string, metadata?: AdropBannerMetadata) => void
onAdFailedToReceive?: (unitId: string, errorCode?: any) => void
}
Props:
style (object, required): Banner style (including height and width)
unitId (string, required): Ad unit ID
useCustomClick (boolean, optional): Custom click handling (default: false)
adSize (object, optional): Ad size setting
autoLoad (boolean, optional): Auto load (default: true)
onAdReceived (function, optional): Called on ad reception
onAdImpression (function, optional): Called on ad impression
onAdClicked (function, optional): Called on ad click
onAdFailedToReceive (function, optional): Called on ad reception failure
Methods
load()
Loads the ad. (Called via ref)
type AdropBannerMetadata = {
creativeId: string
txId: string
campaignId: string
destinationURL: string
browserTarget: BrowserTarget
}
Example:
import { AdropBanner } from 'adrop-ads-react-native'
<AdropBanner
style={{ width: 320, height: 50 }}
unitId="PUBLIC_TEST_UNIT_ID_320_50"
onAdReceived={(unitId, metadata) => console.log('Ad received', metadata)}
onAdFailedToReceive={(unitId, errorCode) => console.log('Ad failed', errorCode)}
/>
AdropNativeAd
Class for managing native ads.
Constructor
constructor(unitId: string, useCustomClick: boolean = false)
Parameters:
unitId (string): Ad unit ID
useCustomClick (boolean, optional): Custom click handling (default: false)
Properties
isLoaded (readonly)
Returns whether the ad is loaded.
unitId (readonly)
Returns the ad unit ID.
requestId (readonly, deprecated)
get requestId(): string // deprecated - always returns ''
Deprecated. This property always returns an empty string and will be removed in future versions.
creativeId (readonly)
Returns the creative ID.
txId (readonly)
Returns the transaction ID.
campaignId (readonly)
Returns the campaign ID.
useCustomClick (readonly)
get useCustomClick(): boolean
Returns whether custom click handling is enabled.
isBackfilled (readonly)
get isBackfilled(): boolean
Returns whether it’s a backfill ad.
isVideoAd (readonly)
Returns whether the ad is a video ad.
browserTarget (readonly)
get browserTarget(): BrowserTarget
Returns the browser target setting.
properties (readonly)
get properties(): AdropNativeProperties
Returns ad properties.
listener
listener?: AdropNativeAdListener
Sets the ad event listener.
Methods
load()
Loads the ad.
destroy()
Releases the ad instance.
AdropNativeProperties
type AdropNativeProperties = {
icon?: string
cover?: string
headline?: string
body?: string
creative?: string
asset?: string
destinationURL?: string
advertiserURL?: string
accountTag?: string
creativeTag?: string
advertiser?: string
callToAction?: string
profile?: AdropNativeProfile
extra?: Record<string, string>
isBackfilled?: boolean
}
AdropNativeProfile
type AdropNativeProfile = {
displayName: string
displayLogo: string
}
AdropNativeAdListener
interface AdropNativeAdListener {
onAdReceived?: (ad: AdropNativeAd) => void
onAdClicked?: (ad: AdropNativeAd) => void
onAdImpression?: (ad: AdropNativeAd) => void
onAdFailedToReceive?: (ad: AdropNativeAd, errorCode?: any) => void
}
AdropNativeAdView
Container component for displaying native ads.
Props
type Props = ViewProps & {
nativeAd?: AdropNativeAd
}
Props:
nativeAd (AdropNativeAd, optional): Native ad instance
- …ViewProps: All React Native View props
Example:
import { AdropNativeAdView } from 'adrop-ads-react-native'
<AdropNativeAdView nativeAd={nativeAd}>
{/* Native ad views */}
</AdropNativeAdView>
Native Ad View Components
Components for displaying each element of a native ad. All components must be used inside AdropNativeAdView.
AdropIconView
Displays the ad icon.
interface IconViewProps extends Omit<ImageProps, 'source'> {
source?: ImageSourcePropType | undefined
}
Example:
import { AdropIconView } from 'adrop-ads-react-native'
<AdropIconView style={{ width: 50, height: 50 }} />
AdropHeadLineView
Displays the ad headline.
const AdropHeadLineView: React.FC<TextProps>
Example:
import { AdropHeadLineView } from 'adrop-ads-react-native'
<AdropHeadLineView style={{ fontSize: 18, fontWeight: 'bold' }} />
AdropBodyView
Displays the ad body text.
const AdropBodyView: React.FC<TextProps>
Example:
import { AdropBodyView } from 'adrop-ads-react-native'
<AdropBodyView style={{ fontSize: 14 }} />
Displays the ad media (image/video).
const AdropMediaView: React.FC<ViewProps>
Example:
import { AdropMediaView } from 'adrop-ads-react-native'
<AdropMediaView style={{ width: '100%', height: 200 }} />
AdropCallToActionView
Displays the ad CTA (Call To Action) button.
const AdropCallToActionView: React.FC<TextProps>
Example:
import { AdropCallToActionView } from 'adrop-ads-react-native'
<AdropCallToActionView
style={{
backgroundColor: '#007AFF',
color: 'white',
padding: 10
}}
/>
AdropAdvertiserView
Displays the advertiser information.
const AdropAdvertiserView: React.FC<TextProps>
Example:
import { AdropAdvertiserView } from 'adrop-ads-react-native'
<AdropAdvertiserView style={{ fontSize: 12, color: 'gray' }} />
AdropProfileLogoView
Displays the profile logo.
interface IconViewProps extends Omit<ImageProps, 'source'> {
source?: ImageSourcePropType | undefined
}
Example:
import { AdropProfileLogoView } from 'adrop-ads-react-native'
<AdropProfileLogoView style={{ width: 30, height: 30, borderRadius: 15 }} />
AdropProfileNameView
Displays the profile name.
const AdropProfileNameView: React.FC<TextProps>
Example:
import { AdropProfileNameView } from 'adrop-ads-react-native'
<AdropProfileNameView style={{ fontSize: 14, fontWeight: '600' }} />
AdropInterstitialAd
Class for managing interstitial ads.
Constructor
constructor(unitId: string)
Parameters:
unitId (string): Ad unit ID
Properties
isLoaded (readonly)
Returns whether the ad is loaded.
unitId (readonly)
Returns the ad unit ID.
creativeId (readonly)
Returns the creative ID.
txId (readonly)
Returns the transaction ID.
campaignId (readonly)
Returns the campaign ID.
destinationURL (readonly)
get destinationURL(): string
Returns the destination URL.
browserTarget (readonly)
get browserTarget(): BrowserTarget
Returns the browser target setting.
listener
Sets the ad event listener.
Methods
load()
Loads the ad.
show()
Shows the ad.
close()
Closes the ad programmatically.
destroy()
Releases the ad instance.
Example:
import { AdropInterstitialAd } from 'adrop-ads-react-native'
const interstitialAd = new AdropInterstitialAd('YOUR_UNIT_ID')
interstitialAd.listener = {
onAdReceived: (ad) => {
console.log('Ad loaded')
ad.show()
},
onAdFailedToReceive: (ad, errorCode) => {
console.log('Ad failed to load', errorCode)
},
}
interstitialAd.load()
AdropRewardedAd
Class for managing rewarded ads.
Constructor
constructor(unitId: string)
Parameters:
unitId (string): Ad unit ID
Properties
Same properties as AdropInterstitialAd.
Methods
load()
Loads the ad.
show()
Shows the ad.
close()
Closes the ad programmatically.
destroy()
Releases the ad instance.
setServerSideVerificationOptions()
setServerSideVerificationOptions(options: ServerSideVerificationOptions): void
Sets options for server-side reward verification. Call before load().
options.userId (string, optional): User identifier sent in the server callback
options.customData (string, optional): Custom data sent in the server callback
Example:
import { AdropRewardedAd } from 'adrop-ads-react-native'
const rewardedAd = new AdropRewardedAd('YOUR_UNIT_ID')
// Set server-side verification options
rewardedAd.setServerSideVerificationOptions({
userId: 'user_12345',
customData: 'extra_info',
})
rewardedAd.listener = {
onAdReceived: (ad) => {
console.log('Ad loaded')
ad.show()
},
onAdEarnRewardHandler: (ad, type, amount) => {
console.log(`Reward earned: type=${type}, amount=${amount}`)
},
onAdFailedToReceive: (ad, errorCode) => {
console.log('Ad failed to load', errorCode)
},
}
rewardedAd.load()
Class for managing popup ads.
Constructor
constructor(
unitId: string,
colors?: AdropPopupAdColors,
useCustomClick?: boolean
)
Parameters:
unitId (string): Ad unit ID
colors (AdropPopupAdColors, optional): Popup color customization
useCustomClick (boolean, optional): Custom click handling (default: false)
Properties
isLoaded (readonly)
Returns whether the ad is loaded.
unitId (readonly)
Returns the ad unit ID.
creativeId (readonly)
Returns the creative ID.
txId (readonly)
Returns the transaction ID.
campaignId (readonly)
Returns the campaign ID.
destinationURL (readonly)
get destinationURL(): string
Returns the destination URL.
browserTarget (readonly)
get browserTarget(): BrowserTarget
Returns the browser target setting.
listener
Sets the ad event listener.
Methods
load()
Loads the ad.
show()
Shows the ad.
close()
Closes the popup ad.
destroy()
Releases the ad instance.
type AdropPopupAdColors = {
closeTextColor?: string
hideForTodayTextColor?: string
backgroundColor?: string
}
Properties:
closeTextColor (string, optional): Close button text color
hideForTodayTextColor (string, optional): ‘Hide for today’ text color
backgroundColor (string, optional): Background color
AdropListener
Listener interface for receiving ad events.
type AdropListener = {
onAdReceived?: (ad: AdropAd) => void
onAdClicked?: (ad: AdropAd) => void
onAdImpression?: (ad: AdropAd) => void
onAdFailedToReceive?: (ad: AdropAd, errorCode?: any) => void
onAdDidPresentFullScreen?: (ad: AdropAd) => void
onAdWillPresentFullScreen?: (ad: AdropAd) => void
onAdDidDismissFullScreen?: (ad: AdropAd) => void
onAdWillDismissFullScreen?: (ad: AdropAd) => void
onAdFailedToShowFullScreen?: (ad: AdropAd, errorCode?: any) => void
onAdEarnRewardHandler?: (ad: AdropAd, type: number, amount: number) => void
onAdBackButtonPressed?: (ad: AdropAd) => void
}
Events:
onAdReceived: Ad reception complete
onAdClicked: Ad clicked
onAdImpression: Ad impression
onAdFailedToReceive: Ad reception failed
onAdDidPresentFullScreen: Full-screen ad presented
onAdWillPresentFullScreen: Full-screen ad about to present
onAdDidDismissFullScreen: Full-screen ad dismissed
onAdWillDismissFullScreen: Full-screen ad about to dismiss
onAdFailedToShowFullScreen: Full-screen ad failed to show
onAdEarnRewardHandler: Reward earned (rewarded ads only)
onAdBackButtonPressed: Back button pressed (Android only)
useAdropInterstitialAd
Manages interstitial ads with a React Hook.
Signature
function useAdropInterstitialAd(unitId: string | null): AdHookReturns & AdStates
Parameters:
unitId (string | null): Ad unit ID
Returns:
load: Ad load function
show: Ad show function
reset: State reset function
isBackPressed: Back button pressed status (Android only)
isClicked: Click status
isClosed: Closed status
isEarnRewarded: Whether the user has earned a reward
isLoaded: Loaded status
isOpened: Opened status
isReady: Ready status
errorCode: Error code
reward: Reward info ({ type: number, amount: number } or undefined)
browserTarget: Browser target setting (BrowserTarget or undefined)
Example:
import { useAdropInterstitialAd } from 'adrop-ads-react-native'
function MyComponent() {
const { load, show, isLoaded, errorCode } = useAdropInterstitialAd('YOUR_UNIT_ID')
useEffect(() => {
load()
}, [])
useEffect(() => {
if (isLoaded) {
show()
}
}, [isLoaded])
return <View />
}
useAdropRewardedAd
Manages rewarded ads with a React Hook.
Signature
function useAdropRewardedAd(unitId: string | null): AdHookReturns & AdStates
Parameters:
unitId (string | null): Ad unit ID
Returns:
load: Ad load function
show: Ad show function
reset: State reset function
isBackPressed: Back button pressed status (Android only)
isClicked: Click status
isClosed: Closed status
isEarnRewarded: Whether the user has earned a reward
isLoaded: Loaded status
isOpened: Opened status
isReady: Ready status
errorCode: Error code
reward: Reward info ({ type: number, amount: number } or undefined)
browserTarget: Browser target setting (BrowserTarget or undefined)
Example:
import { useAdropRewardedAd } from 'adrop-ads-react-native'
function MyComponent() {
const { load, show, isLoaded, isEarnRewarded, reward } = useAdropRewardedAd('YOUR_UNIT_ID')
useEffect(() => {
load()
}, [])
useEffect(() => {
if (isLoaded) {
show()
}
}, [isLoaded])
useEffect(() => {
if (isEarnRewarded && reward) {
console.log(`Reward: type=${reward.type}, amount=${reward.amount}`)
}
}, [isEarnRewarded, reward])
return <View />
}
useAdropWebView
Hook for registering a WebView with the Adrop SDK. Handles view tag resolution and registration automatically.
Signature
function useAdropWebView(): {
containerRef: React.RefObject<View>
isReady: boolean
onLayout: () => void
}
Returns:
containerRef: Ref to attach to the View wrapping the WebView
isReady: Whether the WebView has been successfully registered
onLayout: Callback to trigger registration on layout
Example:
import { View } from 'react-native'
import { WebView } from 'react-native-webview'
import { useAdropWebView } from 'adrop-ads-react-native'
function WebViewScreen() {
const { containerRef, isReady, onLayout } = useAdropWebView()
return (
<View ref={containerRef} style={{ flex: 1 }} onLayout={onLayout}>
<WebView
source={isReady ? { uri: 'https://your-website.com' } : { html: '' }}
javaScriptEnabled={true}
thirdPartyCookiesEnabled={true}
mediaPlaybackRequiresUserAction={false}
allowsInlineMediaPlayback={true}
/>
</View>
)
}
AdropMetrics
Class for managing user attributes and events.
setProperty
static setProperty(key: string, value: any): void
Sets a user property.
Parameters:
key (string): Property key
value (any): Property value
Example:
import { AdropMetrics, AdropProperties, AdropGender } from 'adrop-ads-react-native'
AdropMetrics.setProperty(AdropProperties.AGE, 25)
AdropMetrics.setProperty(AdropProperties.GENDER, AdropGender.MALE)
AdropMetrics.setProperty(AdropProperties.BIRTH, '1998-01-01')
sendEvent
static sendEvent(name: string, params?: Record<string, any>): void
Sends a user behavior event. Supports nested items arrays for multi-item events.
Parameters:
name (string): Event name (1–64 characters)
params (Record<string, any>, optional): Event parameters
Example:
import { AdropMetrics } from 'adrop-ads-react-native'
// Simple event
AdropMetrics.sendEvent('app_open')
// Event with parameters
AdropMetrics.sendEvent('view_item', {
item_id: 'SKU-123',
item_name: 'Widget',
price: 29900,
})
// Multi-item event
AdropMetrics.sendEvent('purchase', {
tx_id: 'TXN-001',
currency: 'KRW',
items: [
{ item_id: 'SKU-001', item_name: 'Product A', price: 29900, quantity: 1 },
{ item_id: 'SKU-002', item_name: 'Product B', price: 15000, quantity: 2 },
],
})
logEvent (deprecated)
/** @deprecated Use sendEvent instead */
static logEvent(name: string, params?: Record<string, any>): void
Logs a custom event. Internally calls sendEvent.
Parameters:
name (string): Event name
params (object, optional): Event parameters
properties
static properties(): Promise<Record<string, any>>
Gets all set properties.
Returns:
- Promise<Record<string, any>>: Property object
AdropProperties
Enum defining user property keys.
enum AdropProperties {
AGE = 'AGE',
BIRTH = 'BIRTH',
GENDER = 'GDR',
}
Values:
AGE: Age
BIRTH: Birth date
GENDER: Gender
AdropGender
Enum defining gender.
enum AdropGender {
MALE = 'M',
FEMALE = 'F',
OTHER = 'O',
UNKNOWN = 'U',
}
Values:
MALE: Male
FEMALE: Female
OTHER: Other
UNKNOWN: Unknown
AdropConsent
Class for managing user consent (GDPR, CCPA, etc.).
requestConsentInfoUpdate
static requestConsentInfoUpdate(): Promise<AdropConsentResult>
Updates consent information and shows the consent popup if needed.
Returns:
Promise<AdropConsentResult>: Consent result
Example:
import { AdropConsent } from 'adrop-ads-react-native'
const result = await AdropConsent.requestConsentInfoUpdate()
console.log('Status:', result.status)
console.log('Can request ads:', result.canRequestAds)
console.log('Can show personalized ads:', result.canShowPersonalizedAds)
getConsentStatus
static getConsentStatus(): Promise<AdropConsentStatus>
Gets the current consent status.
Returns:
Promise<AdropConsentStatus>: Current consent status
Example:
const status = await AdropConsent.getConsentStatus()
canRequestAds
static canRequestAds(): Promise<boolean>
Checks whether ads can be requested based on current consent.
Returns:
Promise<boolean>: Whether ads can be requested
Example:
const canRequest = await AdropConsent.canRequestAds()
if (canRequest) {
// Load ads
}
reset
Resets consent settings. For testing and debugging purposes.
Example:
setDebugSettings
static setDebugSettings(geography: AdropConsentDebugGeography): void
Sets debug geography for testing consent flows. Only works in DEBUG builds.
Parameters:
geography (AdropConsentDebugGeography): Geography to simulate
Example:
import { AdropConsent, AdropConsentDebugGeography } from 'adrop-ads-react-native'
AdropConsent.setDebugSettings(AdropConsentDebugGeography.EEA)
AdropConsentStatus
Enum representing user consent status.
enum AdropConsentStatus {
UNKNOWN = 0,
REQUIRED = 1,
NOT_REQUIRED = 2,
OBTAINED = 3,
}
Values:
UNKNOWN: Not yet determined
REQUIRED: Consent required (popup display needed)
NOT_REQUIRED: Consent not required (not applicable region)
OBTAINED: Consent obtained
AdropConsentResult
Interface representing the result of a consent info update.
interface AdropConsentResult {
status: AdropConsentStatus
canRequestAds: boolean
canShowPersonalizedAds: boolean
error?: string
}
Properties:
status (AdropConsentStatus): Consent status
canRequestAds (boolean): Whether ads can be requested
canShowPersonalizedAds (boolean): Whether personalized ads can be shown
error (string, optional): Error message if any
AdropConsentDebugGeography
Enum for specifying debug geography in consent testing.
enum AdropConsentDebugGeography {
DISABLED = 0,
EEA = 1,
NOT_EEA = 2, // deprecated - use OTHER instead
REGULATED_US_STATE = 3,
OTHER = 4,
}
Values:
DISABLED: No debug setting (use actual location)
EEA: European Economic Area (GDPR applies)
NOT_EEA: (deprecated - use OTHER instead)
REGULATED_US_STATE: Regulated US states (California, etc., CCPA applies)
OTHER: Unregulated region
Deprecated APIs
The following APIs are deprecated and will be removed in future versions. Migrate to the recommended alternatives.
AdropAd.destinationUrl
destinationUrl is deprecated. Use destinationURL instead.
// Before (deprecated)
const url = ad.destinationUrl
// After
const url = ad.destinationURL
createIds() is deprecated. Use creativeId instead.
// Before (deprecated)
const ids = popupAd.createIds()
// After
const id = popupAd.creativeId
AdropNativeAd.requestId
AdropNativeAd.requestId is deprecated and always returns an empty string. This property will be removed in future versions.
// Before (deprecated)
const reqId = nativeAd.requestId // always returns ''
// After - remove usage of requestId
AdropMetrics.logEvent()
logEvent() is deprecated. Use sendEvent() instead.
// Before (deprecated)
AdropMetrics.logEvent('purchase', { item_id: 'SKU-001' })
// After
AdropMetrics.sendEvent('purchase', { item_id: 'SKU-001' })