'React native expo implementing Apple App Tracking Transparency (ATT) for iOS 14.5

What is the best way of implementing the Apple App Transparency Tracker (ATT) feature on react native expo? My app keeps getting rejected by apple even after I add:

app.json file :

"infoPlist": {
  "NSUserTrackingUsageDescription": "App requires permission...."
}


Solution 1:[1]

You need to request Tracking permissions first (I used react-native-permissions):

import { request, RESULTS, PERMISSIONS } from 'react-native-permissions'

export const requestPermissionTransparency = async () => {
  return await request(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY)
}

useEffect(() => {
    ;(async () => {
      const result = await requestPermissionTransparency()
      if (result === RESULTS.GRANTED) {
        //You need to enable analytics (fb,google,etc...)
        await firebase.analytics().setAnalyticsCollectionEnabled(true)
        console.log('Firebase Analytics: ENABLED')
      }
    })()
  }, [])

Remember to add this file in the root project:

// <project-root>/firebase.json
{
  "react-native": {
    "analytics_auto_collection_enabled": false
  }
}

References: https://rnfirebase.io/analytics/usage

Solution 2:[2]

The solution I ended up using from expo was using the Facebook.getPermissionsAsync()

https://expo.canny.io/feature-requests/p/expo-permissions-add-support-to-apptrackingtransparency-permission-on-ios

Solution 3:[3]

Expo 41+

TrackingTransparency: https://docs.expo.io/versions/latest/sdk/tracking-transparency/

import { requestTrackingPermissionsAsync } from 'expo-tracking-transparency';
const { status } = await requestTrackingPermissionsAsync();
if (status === 'granted') // do something

Expo 40 and below

Admob: https://docs.expo.io/versions/latest/sdk/admob/

import { requestPermissionsAsync } from 'expo-ads-admob'
const { status } = await requestPermissionsAsync()
if (status === 'granted') // do something

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Erdanieliko
Solution 2 Nyasha
Solution 3 imstillalive