React Native 배너 광고
배너 광고는 앱 레이아웃의 일부를 차지하는 직사각형 광고입니다. 사용자가 앱과 상호작용하는 동안 화면에 유지됩니다.
시작하기 전에
1
2
배너 광고 구현하기
import React from 'react';
import { View, Dimensions } from 'react-native';
import { AdropBanner, type AdropBannerMetadata } from 'adrop-ads-react-native';
const BannerExample = () => {
const screenWidth = Dimensions.get('window').width;
return (
<View>
<AdropBanner
unitId="YOUR_UNIT_ID"
style={{ width: screenWidth, height: 80 }}
onAdReceived={(unitId, metadata) => {
console.log('광고 로드 완료:', unitId);
}}
onAdFailedToReceive={(unitId, errorCode) => {
console.log('광고 로드 실패:', errorCode);
}}
onAdImpression={(unitId, metadata) => {
console.log('광고 로드 노출:', unitId)
}}
onAdClicked{(unitId, metadata) => {
console.log('광고 로드 클릭:', unitId)
}}
/>
</View>
);
};Props
Parameter
Type
Required
Default
Description
콜백 이벤트
Event
Parameter
Description
AdropBannerMetadata
type AdropBannerMetadata = {
creativeId: string; // 크리에이티브 ID
txId: string; // 트랜잭션 ID
campaignId: string; // 캠페인 ID
destinationURL: string; // 클릭 시 이동할 URL
};수동 로드
import React, { useRef } from 'react';
import { View, Button, Dimensions } from 'react-native';
import { AdropBanner } from 'adrop-ads-react-native';
interface IBannerRef {
load: () => void;
}
const ManualLoadExample = () => {
const bannerRef = useRef<IBannerRef>(null);
const screenWidth = Dimensions.get('window').width;
const loadBanner = () => {
bannerRef.current?.load();
};
return (
<View>
<Button title="광고 로드" onPress={loadBanner} />
<AdropBanner
ref={bannerRef}
unitId="YOUR_UNIT_ID"
style={{ width: screenWidth, height: 80 }}
autoLoad={false}
onAdReceived={(unitId) => console.log('광고 로드됨:', unitId)}
onAdFailedToReceive={(unitId, error) => console.log('에러:', error)}
/>
</View>
);
};Last updated