react-native-nitro-advertising-id
v0.1.1
Published
React Native nitro module for getting advertising ID
Maintainers
Readme
📱 React Native Nitro Advertising ID 
🔹 React Native Nitro Advertising ID provides seamless access to the device's advertising identifier (IDFA on iOS, GAID on Android) in your React Native applications. Built with the power of Nitro Modules for high performance.
🚀 Features
- 📲 Cross-Platform Support: Works on both iOS (IDFA) and Android (GAID).
- ⚡ Optimized Performance: Built with Nitro for low-latency native calls.
- 🔒 Privacy Compliant: Handles permission requests via App Tracking Transparency (iOS) and Google Play Services (Android).
- 🔄 Simple API: Just two methods — request permission and get the advertising ID.
🛠️ Prerequisites
Before getting started, ensure you have:
- React Native version
0.75+ react-native-nitro-modules- iOS 14+ (App Tracking Transparency support)
- New architecture support
📦 Installation
Run the following command to install the package:
npm install react-native-nitro-advertising-id react-native-nitro-modules
# or
yarn add react-native-nitro-advertising-id react-native-nitro-modulesiOS Setup
cd ios && pod installEdit Info.plist. Add the following item (Set Value as desired):
| Key | Type | Value |
| --- | ---- | ----- |
| Privacy - NSUserTrackingUsageDescription | String | CHANGEME: This app needs access to your advertising identifier to provide personalized ads. |
Android Setup
No additional setup required. The library uses Google Play Services Ads Identifier which is automatically linked.
Expo Setup
Install the required packages:
npx expo install react-native-nitro-advertising-id react-native-nitro-modules expo-build-propertiesAdd the following to your app.json (or app.config.js):
{
"expo": {
"newArchEnabled": true,
"ios": {
"infoPlist": {
"NSUserTrackingUsageDescription": "CHANGEME: This app needs access to your advertising identifier to provide personalized ads."
}
},
}
}Then create a development build:
npx expo prebuild
npx expo run:ios
# or
npx expo run:android🎯 API Reference
📜 Permission Statuses
Permission checks and requests resolve into one of the following statuses:
| Return Value | Description |
| --- | --- |
| "authorized" | The user has granted tracking permission. |
| "denied" | The user has denied tracking permission. |
| "restricted" | Tracking is restricted (e.g., parental controls). |
| "notDetermined" | The user has not been asked for permission yet (iOS). |
| "granted" | Permission has been granted (Android). |
| "undetermined" | Permission status has not been determined yet (Android). |
| "unknown" | The permission status could not be determined. |
📌 Example Usage
🔄 Requesting Permission
Request tracking permission from the user before accessing the advertising ID:
import { NitroAdvertisingIdHybridObject } from 'react-native-nitro-advertising-id';
const requestPermission = async () => {
try {
const status = await NitroAdvertisingIdHybridObject.requestPermission();
console.log('Permission status:', status);
} catch (error) {
console.error('Error requesting permission:', error);
}
};📲 Getting the Advertising ID
Retrieve the device's advertising identifier:
import { NitroAdvertisingIdHybridObject } from 'react-native-nitro-advertising-id';
const getAdId = () => {
try {
const advertisingId = NitroAdvertisingIdHybridObject.getAdvertisingId();
console.log('Advertising ID:', advertisingId);
} catch (error) {
console.error('Error getting advertising ID:', error);
}
};🤝 Contributing
📄 License
MIT
Made with create-react-native-library
