1.0.0 • Published 3 years ago

react-native-advertising-info v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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.