react-native-advertising-info
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

react-native-advertising-info

With this module you are able to get advertising identifier in your React Native project.
(IDFA for iOS, and AAID for Android)


Installation

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

Platforms and configuration

  • Android:
    No additional configuration required

  • iOS:

cd ios && pod install
// Info.plist
<key>NSUserTrackingUsageDescription</key>
<string>Your usage description here</string>

Usage

In your React Native app use one of these:

getAdvertisingInfo

import { getAdvertisingInfo } from 'react-native-advertising-info'

React.useEffect(() => {
    getAdvertisingInfo().then((adInfo) => console.log(adInfo))
}, [])

or

useAdTrackingInfo

import { useAdTrackingInfo } from 'react-native-advertising-info'

const adInfo = useAdTrackingInfo()

Types

// Response
type AdvertisingInfo = {
    adTrackingEnabled: boolean
    advertisingId: string
    status: TrackingStatus
}

// TrackingStatus
type TrackingStatus = 'Authorized' | 'Denied' | 'Not Determined' | 'Restricted' | 'Unknown' | 'Not Required'

adTrackingEnabled

  • true: status Authorized or Not required
  • false: different status

advertisingId

Phone advertising identifier. Empty string if tracking not enabled

status

For Android devices the request prompt isn't required and status is either:

  • Not Required - default
  • Denied - A user has blocked tracking globally in phone settings

For iOS < 14 the request prompt isn't required and the status is Not Required
For iOS >= 14 the request prompt is required. The status can be one of these values

Example

You can find an exmaple here

License

MIT

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Package Sidebar

Install

npm i react-native-advertising-info

Weekly Downloads

31

Version

1.0.0

License

MIT

Unpacked Size

30.2 kB

Total Files

19

Last publish

Collaborators

  • iceu-bb