NSUserTrackingUsageDescription
to your Info.plist to explain how the user will be tracked, otherwise your app will be rejected by Apple.Android Device | Android Emulator | iOS Device | iOS Simulator | Web |
---|---|---|---|---|
→
expo install expo-tracking-transparency
If you're installing this in a bare React Native app, you should also follow these additional installation instructions.
expo-tracking-transparency
using its built-in config plugin if you use config plugins in your project (EAS Build or expo run:[android|ios]
). The plugin allows you to configure various properties that cannot be set at runtime and require building a new app binary to take effect.expo build:[android|ios]
)expo-tracking-transparency
repository.{ "expo": { "plugins": [ [ "expo-tracking-transparency", { "userTrackingPermission": "This identifier will be used to deliver personalized ads to you." } ] ] } }
Name | Default | Description |
---|---|---|
userTrackingPermission | "Allow this app to collect app-related data that can be used for tracking you or your device." | iOS only Sets the iOS `NSUserTrackingUsageDescription` permission message in Info.plist. |
import React, { useEffect } from 'react'; import { Text, StyleSheet, View } from 'react-native'; import { requestTrackingPermissionsAsync } from 'expo-tracking-transparency'; export default function App() { useEffect(() => { (async () => { const { status } = await requestTrackingPermissionsAsync(); if (status === 'granted') { console.log('Yay! I have user permission to track data'); } })(); }, []); return ( <View style={styles.container}> <Text>Tracking Transparency Module Example</Text> </View> ); } %%placeholder-start%%const styles = StyleSheet.create({ ... }); %%placeholder-end%%const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', }, });
import { requestTrackingPermissionsAsync, getTrackingPermissionsAsync, } from 'expo-tracking-transparency';
Name | Type | Description |
---|---|---|
options (optional) | PermissionHookOptions<object> | - |
Check or request the user to authorize or deny access to app-related data that can be used for tracking the user or the device. Examples of data used for tracking include email address, device ID, advertising ID, etc. On iOS 14.5 and above, if the user denies this permission, any attempt to collect the IDFA will return a string of 0s.
The system remembers the user’s choice and doesn’t prompt again unless a user uninstalls and then reinstalls the app on the device.
On Android, web, and iOS 13 and below, this method always returns that the permission was granted.
const [status, requestPermission] = useTrackingPermissions();
[null | PermissionResponse, RequestPermissionMethod<PermissionResponse>, GetPermissionMethod<PermissionResponse>]
Checks whether or not the user has authorized the app to access app-related data that can be used
for tracking the user or the device. See requestTrackingPermissionsAsync
for more details.
On Android, web, and iOS 13 and below, this method always returns that the permission was granted.
const { granted } = await getTrackingPermissionsAsync(); if (granted) { // Your app is authorized to track the user or their device }
Returns whether the TrackingTransparency API is available on the current device.
boolean
Currently this is true
on iOS 14 and above only. On devices where the
Tracking Transparency API is unavailable, the get and request permissions methods will always
resolve to granted
.
Requests the user to authorize or deny access to app-related data that can be used for tracking the user or the device. Examples of data used for tracking include email address, device ID, advertising ID, etc. On iOS 14.5 and above, if the user denies this permission, any attempt to collect the IDFA will return a string of 0s.
The system remembers the user’s choice and doesn’t prompt again unless a user uninstalls and then reinstalls the app on the device.
On Android, web, and iOS 13 and below, this method always returns that the permission was granted.
const { granted } = await requestTrackingPermissionsAsync(); if (granted) { // Your app is authorized to track the user or their device }
Acceptable values are: 'never'
, number
.
Acceptable values are: PermissionHookBehavior
, Options
.
Name | Type | Description |
---|---|---|
canAskAgain | boolean | - |
expires | PermissionExpiration | - |
granted | boolean | - |
status | PermissionStatus | - |
DENIED
PermissionStatus.DENIED = "denied"
GRANTED
PermissionStatus.GRANTED = "granted"
UNDETERMINED
PermissionStatus.UNDETERMINED = "undetermined"
Info.plist Key | Description |
---|---|
A message that informs the user why an app is requesting permission to use data for tracking the user or the device. |