メインコンテンツへスキップ

Adrop

Adrop SDKを初期化し、グローバル設定を管理するクラス。

initialize

static initialize(
  production: boolean,
  targetCountries?: string[],
  useInAppBrowser?: boolean
): void
Adrop SDKを初期化します。 パラメータ:
  • production (boolean):本番モード(true:本番、false:開発)
  • targetCountries (string[], optional):ターゲット国コード配列(デフォルト:[])
  • useInAppBrowser (boolean, optional):アプリ内ブラウザを使用するかどうか(デフォルト:false)
例:
import Adrop from 'adrop-ads-react-native'

Adrop.initialize(true, ['KR', 'US'], false)

setUID

static setUID(uid: string): void
一意のユーザー識別子を設定します。 パラメータ:
  • uid (string):一意のユーザー識別子
例:
Adrop.setUID('user123')

setTheme

static setTheme(theme: AdropTheme): void
アプリのテーマを設定します。 パラメータ:
  • theme (AdropTheme):テーマ値(‘light’, ‘dark’, ‘auto’)
例:
import Adrop, { AdropTheme } from 'adrop-ads-react-native'

Adrop.setTheme(AdropTheme.dark)

AdropTheme

アプリのテーマを指定するための定数オブジェクト。
const AdropTheme = {
  light: 'light',
  dark: 'dark',
  auto: 'auto',
} as const

type AdropTheme = typeof AdropTheme[keyof typeof AdropTheme]
値:
  • light:ライトテーマ
  • dark:ダークテーマ
  • auto:システム設定に従う

AdropErrorCode

広告のロードおよび表示中に発生する可能性のあるエラーコード。
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',
  undefined = 'UNDEFINED',
}
エラーコード:
  • network:ネットワークエラー
  • internal:内部エラー
  • initialize:SDK初期化エラー
  • invalidUnit:無効な広告ユニット
  • notTargetCountry:ターゲット国ではない
  • inactive:非アクティブな広告
  • adNoFill:利用可能な広告がない
  • adDuplicated:重複した広告ロードリクエスト
  • adLoading:広告がロード中
  • adEmpty:広告が空
  • adShown:広告は既に表示済み
  • adHideForToday:今日は広告を非表示
  • adLandscapeUnsupported:横向きモードはサポートされていない
  • undefined:未定義のエラー

AdropBanner

バナー広告を表示するReactコンポーネント。

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):バナースタイル(高さと幅を含む)
  • unitId (string, required):広告ユニットID
  • useCustomClick (boolean, optional):カスタムクリック処理(デフォルト:false)
  • adSize (object, optional):広告サイズ設定
  • autoLoad (boolean, optional):自動ロード(デフォルト:true)
  • onAdReceived (function, optional):広告受信時に呼び出し
  • onAdImpression (function, optional):広告インプレッション時に呼び出し
  • onAdClicked (function, optional):広告クリック時に呼び出し
  • onAdFailedToReceive (function, optional):広告受信失敗時に呼び出し

メソッド

load()
load(): void
広告をロードします。(refを介して呼び出し)

AdropBannerMetadata

type AdropBannerMetadata = {
  creativeId: string
  txId: string
  campaignId: string
  destinationURL: string
}
例:
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('広告を受信', metadata)}
  onAdFailedToReceive={(unitId, errorCode) => console.log('広告失敗', errorCode)}
/>

AdropNativeAd

ネイティブ広告を管理するクラス。

コンストラクタ

constructor(unitId: string, useCustomClick: boolean = false)
パラメータ:
  • unitId (string):広告ユニットID
  • useCustomClick (boolean, optional):カスタムクリック処理(デフォルト:false)

プロパティ

isLoaded (readonly)
get isLoaded(): boolean
広告がロードされているかどうかを返します。 unitId (readonly)
get unitId(): string
広告ユニットIDを返します。 creativeId (readonly)
get creativeId(): string
クリエイティブIDを返します。 isBackfilled (readonly)
get isBackfilled(): boolean
バックフィル広告かどうかを返します。 properties (readonly)
get properties(): AdropNativeProperties
広告プロパティを返します。 listener
listener?: AdropNativeAdListener
広告イベントリスナーを設定します。

メソッド

load()
load(): void
広告をロードします。 destroy()
destroy(): void
広告インスタンスを解放します。

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
}

AdropNativeAdListener

interface AdropNativeAdListener {
  onAdReceived?: (ad: AdropNativeAd) => void
  onAdClicked?: (ad: AdropNativeAd) => void
  onAdImpression?: (ad: AdropNativeAd) => void
  onAdFailedToReceive?: (ad: AdropNativeAd, errorCode?: any) => void
}

AdropInterstitialAd

インタースティシャル広告を管理するクラス。

コンストラクタ

constructor(unitId: string)
パラメータ:
  • unitId (string):広告ユニットID

プロパティ

isLoaded (readonly)
get isLoaded(): boolean
広告がロードされているかどうかを返します。 unitId (readonly)
get unitId(): string
広告ユニットIDを返します。 creativeId (readonly)
get creativeId(): string
クリエイティブIDを返します。 listener
listener?: AdropListener
広告イベントリスナーを設定します。

メソッド

load()
load(): void
広告をロードします。 show()
show(): void
広告を表示します。 destroy()
destroy(): void
広告インスタンスを解放します。 例:
import { AdropInterstitialAd } from 'adrop-ads-react-native'

const interstitialAd = new AdropInterstitialAd('YOUR_UNIT_ID')

interstitialAd.listener = {
  onAdReceived: (ad) => {
    console.log('広告がロードされました')
    ad.show()
  },
  onAdFailedToReceive: (ad, errorCode) => {
    console.log('広告のロードに失敗しました', errorCode)
  },
}

interstitialAd.load()

AdropRewardedAd

リワード広告を管理するクラス。

コンストラクタ

constructor(unitId: string)
パラメータ:
  • unitId (string):広告ユニットID

プロパティ

AdropInterstitialAdと同じプロパティ。

メソッド

AdropInterstitialAdと同じメソッド。 例:
import { AdropRewardedAd } from 'adrop-ads-react-native'

const rewardedAd = new AdropRewardedAd('YOUR_UNIT_ID')

rewardedAd.listener = {
  onAdReceived: (ad) => {
    console.log('広告がロードされました')
    ad.show()
  },
  onAdEarnRewardHandler: (ad, type, amount) => {
    console.log(`リワード獲得: type=${type}, amount=${amount}`)
  },
  onAdFailedToReceive: (ad, errorCode) => {
    console.log('広告のロードに失敗しました', errorCode)
  },
}

rewardedAd.load()

AdropPopupAd

ポップアップ広告を管理するクラス。

コンストラクタ

constructor(
  unitId: string,
  colors?: AdropPopupAdColors,
  useCustomClick?: boolean
)
パラメータ:
  • unitId (string):広告ユニットID
  • colors (AdropPopupAdColors, optional):ポップアップ色カスタマイズ
  • useCustomClick (boolean, optional):カスタムクリック処理(デフォルト:false)

メソッド

load()
load(): void
広告をロードします。 show()
show(): void
広告を表示します。 close()
close(): void
ポップアップ広告を閉じます。 destroy()
destroy(): void
広告インスタンスを解放します。

AdropPopupAdColors

type AdropPopupAdColors = {
  closeTextColor?: string
  hideForTodayTextColor?: string
  backgroundColor?: string
}
プロパティ:
  • closeTextColor (string, optional):閉じるボタンのテキスト色
  • hideForTodayTextColor (string, optional):「今日は表示しない」のテキスト色
  • backgroundColor (string, optional):背景色

AdropListener

広告イベントを受け取るリスナーインターフェース。
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
}
イベント:
  • onAdReceived:広告受信完了
  • onAdClicked:広告クリック
  • onAdImpression:広告インプレッション
  • onAdFailedToReceive:広告受信失敗
  • onAdDidPresentFullScreen:フルスクリーン広告が表示された
  • onAdWillPresentFullScreen:フルスクリーン広告が表示される
  • onAdDidDismissFullScreen:フルスクリーン広告が閉じられた
  • onAdWillDismissFullScreen:フルスクリーン広告が閉じられる
  • onAdFailedToShowFullScreen:フルスクリーン広告の表示に失敗
  • onAdEarnRewardHandler:リワード獲得(リワード広告のみ)

useAdropInterstitialAd

React Hookでインタースティシャル広告を管理します。

シグネチャ

function useAdropInterstitialAd(unitId: string | null): AdHookReturns & AdStates
パラメータ:
  • unitId (string | null):広告ユニットID
戻り値:
  • load:広告ロード関数
  • show:広告表示関数
  • reset:状態リセット関数
  • isClicked:クリック状態
  • isClosed:閉じた状態
  • isEarnRewarded:リワード獲得状態
  • isLoaded:ロード状態
  • isOpened:表示状態
  • isReady:準備完了状態
  • errorCode:エラーコード
  • reward:リワード情報
例:
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

React Hookでリワード広告を管理します。

シグネチャ

function useAdropRewardedAd(unitId: string | null): AdHookReturns & AdStates
パラメータ:
  • unitId (string | null):広告ユニットID
戻り値: useAdropInterstitialAdと同じ戻り値。 例:
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(`リワード: type=${reward.type}, amount=${reward.amount}`)
    }
  }, [isEarnRewarded, reward])

  return <View />
}

AdropMetrics

ユーザー属性とイベントを管理するクラス。

setProperty

static setProperty(key: string, value: any): void
ユーザープロパティを設定します。 パラメータ:
  • key (string):プロパティキー
  • value (any):プロパティ値
例:
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')

logEvent

static logEvent(name: string, params?: Record<string, any>): void
カスタムイベントを記録します。 パラメータ:
  • name (string):イベント名
  • params (object, optional):イベントパラメータ
例:
import { AdropMetrics } from 'adrop-ads-react-native'

AdropMetrics.logEvent('purchase', {
  item_id: 'ITEM_123',
  price: 9.99,
  currency: 'USD',
})

properties

static properties(): Promise<Record<string, any>>
設定されたすべてのプロパティを取得します。 戻り値:
  • Promise<Record<string, any>>:プロパティオブジェクト

AdropProperties

ユーザープロパティキーを定義する列挙型。
enum AdropProperties {
  AGE = 'AGE',
  BIRTH = 'BIRTH',
  GENDER = 'GDR',
}
値:
  • AGE:年齢
  • BIRTH:生年月日
  • GENDER:性別

AdropGender

性別を定義する列挙型。
enum AdropGender {
  MALE = 'M',
  FEMALE = 'F',
  OTHER = 'O',
  UNKNOWN = 'U',
}
値:
  • MALE:男性
  • FEMALE:女性
  • OTHER:その他
  • UNKNOWN:不明