React Native 전면 광고
전면 광고 노출하기
Ad type
Ad unit ID
Interstitial
PUBLIC_TEST_UNIT_ID_INTERSTITIAL
// (선택사항) 이벤트 리스너 선언하기
const listener = {
onAdReceived: (ad: AdropInterstitialAd) =>
console.log(`Adrop interstitial Ad load with unitId ${ad.unitId}!`),
onAdFailedToReceive: (ad: AdropInterstitialAd, errorCode: string) =>
console.log(`error in ${ad.unitId} while load: ${errorCode}`),
onAdFailedToShowFullScreen: (ad: AdropInterstitialAd, errorCode: string) =>
console.log(`error in ${ad.unitId} while showing: ${errorCode}`),
...
}
const YourComponent: React.FC = () => {
const [interstitialAd, setInterstitialAd] = useState<AdropInterstitialAd>(null)
useEffect(() => {
let adropInterstitialAd = new AdropInterstitialAd('YOUR_UNIT_ID')
adropInterstitialAd.listener = listener
adropInterstitialAd.load()
setInterstitialAd(adropInterstitialAd)
}, []);
const show = () => {
if (interstitialAd?.isLoaded) {
interstitialAd?.show()
} else {
console.log('interstitial ad is loading...')
}
}
return (
<View>
<Button title="display ad" onPress={show}/>
</View>
)
}const YourComponent: React.FC = () => {
const { load, show, isLoaded, reset } =
useAdropInterstitialAd('YOUR_UNIT_ID')
const handleShow = () => {
if (isLoaded) show()
}
return (
<View>
<Button title="load ad" onPress={load}/>
<Button title="display ad" onPress={handleShow}/>
</View>
)
}전면 광고 Destroy
useEffect(() => {
return () => {
interstitialAd.destroy()
}
}, [])useEffect(() => {
return () => {
reset()
}
}, [])적용 확인하기
console에서 발급받은 unitId가 한 번이라도 광고요청을 할 경우 성공적으로 연결됩니다.

Last updated