UMP(User Messaging Platform) SDK는 GDPR(일반 데이터 보호 규정) 및 CCPA(캘리포니아 소비자 개인정보 보호법) 준수를 위해 맞춤형 광고에 대한 사용자 동의를 관리합니다.
UMP 연동에는 adrop-ads-backfill 네이티브 모듈이 필요합니다. 시작하기 의 설치 가이드를 먼저 완료해주세요.
기본 사용법
Adrop 초기화 후 AdropConsent 모듈을 사용하여 사용자 동의를 요청합니다.
import { AdropConsent } from 'adrop-ads-react-native'
// Adrop.initialize() 호출 후 사용
const requestConsent = async () => {
const result = await AdropConsent . requestConsentInfoUpdate ()
if ( result . error ) {
console . error ( 'Consent error:' , result . error )
}
}
AdropConsentResult
requestConsentInfoUpdate()는 다음 결과 타입을 반환합니다:
interface AdropConsentResult {
status : AdropConsentStatus
canRequestAds : boolean
canShowPersonalizedAds : boolean
error ?: string
}
필드 타입 설명 statusAdropConsentStatus현재 동의 상태 canRequestAdsboolean광고 요청 가능 여부 canShowPersonalizedAdsboolean맞춤형 광고 표시 가능 여부 errorstring에러 메시지 (있는 경우)
AdropConsentStatus
enum AdropConsentStatus {
UNKNOWN = 0 ,
REQUIRED = 1 ,
NOT_REQUIRED = 2 ,
OBTAINED = 3 ,
}
상태 값 설명 UNKNOWN0동의 상태가 아직 결정되지 않음 REQUIRED1동의 필요 (팝업이 표시됨) NOT_REQUIRED2동의 불필요 (비GDPR 지역) OBTAINED3이미 동의 완료됨
디버그 설정 (테스트 모드)
개발 중에 GDPR/CCPA 동의 흐름을 테스트하세요:
import {
AdropConsent ,
AdropConsentDebugGeography ,
} from 'adrop-ads-react-native'
// 동의 요청 전에 디버그 지역 설정
// 기기 ID는 자동으로 감지됨
AdropConsent . setDebugSettings ( AdropConsentDebugGeography . EEA ) // GDPR 테스트
// 테스트를 위한 동의 초기화
AdropConsent . reset ()
디버그 지역
지역 설명 DISABLED실제 기기 위치 사용 EEAGDPR 테스트 (유럽 경제 지역) REGULATED_US_STATECCPA 테스트 (캘리포니아 등) OTHER규제가 없는 지역 테스트
디버그 설정은 개발 중에만 사용해야 합니다. 프로덕션 배포 전에 제거하거나 비활성화하세요.
추가 메서드
getConsentStatus
static getConsentStatus (): Promise < AdropConsentStatus >
현재 동의 상태를 반환합니다.
canRequestAds
static canRequestAds (): Promise < boolean >
현재 광고 요청이 가능한지 여부를 반환합니다.
전체 예제
import React , { useEffect , useState } from 'react'
import { View , Text , Button } from 'react-native'
import {
Adrop ,
AdropConsent ,
AdropConsentStatus ,
AdropConsentDebugGeography ,
} from 'adrop-ads-react-native'
const App = () => {
const [ consentStatus , setConsentStatus ] = useState < AdropConsentStatus >(
AdropConsentStatus . UNKNOWN
)
useEffect (() => {
initializeConsent ()
}, [])
const initializeConsent = async () => {
// 먼저 Adrop 초기화
Adrop . initialize ( false )
// 개발 환경에서 디버그 설정
if ( __DEV__ ) {
AdropConsent . setDebugSettings ( AdropConsentDebugGeography . EEA )
}
// 동의 정보 업데이트 요청
const result = await AdropConsent . requestConsentInfoUpdate ()
if ( result . error ) {
console . error ( '동의 오류:' , result . error )
} else {
setConsentStatus ( result . status )
}
}
const resetConsent = async () => {
AdropConsent . reset ()
await initializeConsent ()
}
return (
< View style = {{ flex : 1 , justifyContent : 'center' , alignItems : 'center' }} >
< Text > 동의 상태 : { AdropConsentStatus [ consentStatus ]}</ Text >
{ __DEV__ && (
< Button title = "동의 초기화" onPress = { resetConsent } />
)}
</ View >
)
}
export default App
모범 사례
조기 요청 SDK 초기화 직후, 앱 라이프사이클 초기에 동의를 요청하세요.
오류 처리 동의 오류를 적절히 처리하고 대체 동작을 제공하세요.
모든 시나리오 테스트 배포 전에 디버그 설정을 사용하여 모든 동의 시나리오를 테스트하세요.
사용자 선택 존중 동의를 얻거나 거부된 후에는 사용자의 선택을 존중하고 반복적으로 요청하지 마세요.
관련 문서