react-native-idfa-idfv-gaid
v1.0.4
Published
React Native module to get IDFA, IDFV (iOS) and Google Advertising ID (Android)
Maintainers
Readme
react-native-idfa-idfv-gaid
Get IDFA, IDFV (iOS) and Google Advertising ID / GAID (Android) in React Native.
Installation
npm install react-native-idfa-idfv-gaidiOS Setup
cd ios && pod installAdd to your Info.plist:
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>Android Setup
Add to your AndroidManifest.xml:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>Register the package in MainApplication.kt:
import com.idfaidfvgaid.IdfaIdfvGaidPackage
override fun getPackages(): List<ReactPackage> = listOf(
...,
IdfaIdfvGaidPackage()
)Usage
import { getIDFA, getIDFV, getGAID, getAllIds } from 'react-native-idfa-idfv-gaid';
// iOS only - requires ATT permission first
const idfa = await getIDFA();
// iOS only - no permission needed
const idfv = await getIDFV();
// Android only
const gaid = await getGAID();
// Get all IDs for current platform
const ids = await getAllIds();
// iOS: { idfa: '...', idfv: '...' }
// Android: { gaid: '...' }Notes
- On iOS 14.5+, you must request ATT permission before calling
getIDFA(), otherwise it returns00000000-0000-0000-0000-000000000000 getIDFV()does not require any permission- On Android, if user has opted out of ad tracking,
getGAID()returns00000000-0000-0000-0000-000000000000
License
MIT
