install react-native-permission #152205
Replies: 1 comment
-
Okay, Youssef is having trouble with the ATT (App Tracking Transparency) popup in his React Native iOS app using react-native-permissions. The popup isn't showing, even though he thinks his code is correct. Here's a breakdown of potential issues and solutions, explained clearly:
The most common cause is a missing or incorrect NSUserTrackingUsageDescription key in Info.plist. This is required by Apple. This is the message the user sees before they get the permission prompt. Make sure it's there and has a clear, user-friendly explanation of why you need tracking permission. Something like: "This app uses tracking to personalize your experience and show you relevant ads." Without this, the prompt will simply not appear, even if your code is perfect.
Did you follow the iOS setup steps exactly? This often involves pod install after installing the NPM package. A missing or outdated native module can cause problems. Double-check the react-native-permissions documentation for the iOS setup. Make sure all the native linking is correct.
Don't call requestTrackingPermission (or your request(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY)) too early. It's best to wait until the app is fully initialized. Calling it in useEffect on the main App component should be okay, but double-check there are no other components mounting first that might be interfering. Try wrapping the request call in a setTimeout with a short delay (e.g., 500ms) to ensure the app is fully ready. This can sometimes help.
Use getTrackingStatus() to check the current authorization status before requesting permission. If the user has already denied permission, the prompt won't appear again unless they go into the iOS settings and manually enable it. You can use the getTrackingStatus() to show message to user to go to setting to enable.
Simulators can sometimes behave differently than real devices. Test on a physical iPhone or iPad if possible.
Youssef's code looks reasonably correct at first glance, but here are a few suggestions: Example Info.plist Entry: NSUserTrackingUsageDescription In summary, Youssef should focus on: Info.plist (NSUserTrackingUsageDescription). react-native-permissions iOS setup (pod install). ATT permission timing. Use getTrackingStatus() to show information to user. If he checks those, the ATT popup should hopefully appear! |
Beta Was this translation helpful? Give feedback.
-
Hello, i have a problem with react-native-permission the popup ATT in ios not visible and not enable and my code is clean
import React, { useEffect } from 'react';
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, Alert, Platform, AppState } from 'react-native';
import { request, PERMISSIONS, RESULTS, check, requestTrackingPermission } from 'react-native-permissions';
import { getTrackingStatus } from 'react-native-tracking-transparency';
import { setAdvertiserTrackingEnabled, AdMobInterstitial } from 'react-native-google-mobile-ads';
export default function App() {
console.log(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY, RESULTS);
const handleAppStateChange = async (nextAppState) => {
//if (nextAppState === 'active') {
// Demande la permission ATT (App Tracking Transparency)
};
useEffect(() => {
const trackingStatus = getTrackingStatus();
if (trackingStatus === 'authorized' || trackingStatus === 'unavailable') {
console.log(trackingStatus);
}
}, []);
return (
Open up App.js to start working on your app!
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Beta Was this translation helpful? Give feedback.
All reactions