What im trying to do is to navigate the user after he registers, to a permission screen, which asks the user to enable the permissions on the settings in order to navigate to other screens.
So if the permission is granted, setNavigate to true, and the user can navigate to other screens.
When the permission is not granted, the user goes to settings, changes the permission to "granted", and returns to the application, the response.status won't be updated. I will have to kill the terminal, to run it in order to update the status.
const PermissionsIntro = ({ navigation}) => {
const [navigate, setNavigate] = useState(false);
useEffect(() => {
Location.requestForegroundPermissionsAsync() // requestBackgroundPermissionsAsync
.then((response) => {
if (response.status === 'granted'){
setNavigate(true)
}
else if (response.status !== 'granted') throw 'Permission to access location was denied';
const getLocation = Location.getCurrentPositionAsync({ accuracy: Location.Accuracy.Balanced
});
return getLocation;
})
}, [])
const openSettings = () => {
Linking.openSettings();
};
const confirm = () => {
if (navigate == true) {
navigation.navigate('CreateProfile');
} else {
console.log('turn the permissions to true!');
openSettings();
}
};
return(
<Button onPress={confirm}>
<GetStartedText>ENABLE ALL</GetStartedText>
</Button>
);
}
export default PermissionsIntro;
How can I update the response.status as soon as the user return from settings in the application without having to kill the terminal(in my case)?