npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-advertising-identifier

v2.0.0

Published

Get the Google Advertising ID (Android) and IDFA (iOS) in React Native, with App Tracking Transparency support

Readme

react-native-advertising-identifier

Get the device advertising identifier in React Native:

  • Android — the Google Advertising ID (GAID) via Google Play services
  • iOS — the IDFA, with App Tracking Transparency (ATT) support

Written as a TurboModule with a backward-compatible spec, so it works on both the new architecture and the old architecture.

Requirements

  • React Native 0.74 or newer
  • Android minSdk 24, com.google.android.gms:play-services-ads-identifier (bundled)
  • iOS: the minimum iOS version supported by your React Native version

Installation

npm install react-native-advertising-identifier
# or
yarn add react-native-advertising-identifier

Then install pods:

cd ios && pod install

Autolinking takes care of the rest — no manual linking or react-native link.

Usage

import {
  getAdvertisingId,
  requestTrackingAuthorization,
} from 'react-native-advertising-identifier';

// iOS 14+: ask for tracking permission first, otherwise the IDFA is all zeros.
// On Android this resolves immediately with 'authorized'.
const status = await requestTrackingAuthorization();

const { advertisingId, isLimitAdTrackingEnabled } = await getAdvertisingId();

The default export keeps the v1 call style working:

import RNAdvertisingId from 'react-native-advertising-identifier';

RNAdvertisingId.getAdvertisingId()
  .then(({ advertisingId, isLimitAdTrackingEnabled }) => { /* ... */ })
  .catch(console.error);

API

getAdvertisingId(): Promise<AdvertisingIdInfo>

Resolves with:

| Field | Type | Description | | --- | --- | --- | | advertisingId | string \| null | GAID on Android, IDFA on iOS. All zeros when the user has opted out / not authorized tracking. | | isLimitAdTrackingEnabled | boolean | true when the user has limited ad tracking (Android) or has not authorized tracking via ATT (iOS 14+). |

Rejects on Android when Google Play services is unavailable or out of date (error code E_ADVERTISING_ID).

requestTrackingAuthorization(): Promise<TrackingStatus>

Shows the iOS App Tracking Transparency prompt and resolves with 'authorized' | 'denied' | 'restricted' | 'notDetermined'. On Android (and iOS < 14) it resolves with 'authorized' without showing anything.

If the app's Info.plist is missing NSUserTrackingUsageDescription, the promise rejects with code E_MISSING_USAGE_DESCRIPTION instead of letting iOS terminate the app (which is what happens when the ATT prompt is requested without it).

Platform notes

Android

  • The library's manifest already declares the permission required on Android 13+:

    <uses-permission android:name="com.google.android.gms.permission.AD_ID" />

    If your app must not request it (e.g. a kids' app), remove it in your app manifest:

    <uses-permission
        android:name="com.google.android.gms.permission.AD_ID"
        tools:node="remove" />
  • On Android 12+, when the user deletes their advertising ID, the returned ID is 00000000-0000-0000-0000-000000000000 and isLimitAdTrackingEnabled is true.

iOS

  • Add a usage description to your app's Info.plist (required for the ATT prompt):

    <key>NSUserTrackingUsageDescription</key>
    <string>This identifier will be used to deliver personalized ads to you.</string>
  • Call requestTrackingAuthorization() before getAdvertisingId(); without authorization iOS returns an all-zeros IDFA.

License

MIT