I’m encountering an issue with location permissions in my React Native iOS app. When the permission prompt appears, I select “When In Use” for location access, but when I later check the “Always” permission, it’s also granted, even though I never selected it.
Here’s my code:
if (Platform.OS === 'ios') {
console.log('Requesting "When In Use" location permission for iOS...');
const whenInUseStatus = await request(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);
console.log('whenInUseStatus:', whenInUseStatus);
if (whenInUseStatus === RESULTS.GRANTED) {
// Checking for "Always" permission
const alwaysStatus = await check(PERMISSIONS.IOS.LOCATION_ALWAYS);
console.log('alwaysStatus:', alwaysStatus);
if (alwaysStatus !== RESULTS.GRANTED) {
Alert.alert(
'Enable "Always" Location Access',
'To provide a better experience, please enable "Always" location access in the app settings.',
[
{
text: 'Go to Settings',
onPress: () => {
Linking.openURL('app-settings:');
},
},
{ text: 'Cancel', style: 'cancel' },
]
);
}
}
}
In Info.plist, I have these added:
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
The popup shows the correct options for “When In Use”, “Only Once” and “Never”. However, when I select “When In Use”, I’m finding that the app also gets the “Always” permission granted, which is not what I expect.
Has anyone faced a similar issue where selecting “When In Use” also grants the “Always” permission? Why might this be happening, and how can I ensure that “Always” is only granted when explicitly selected?
Any guidance would be appreciated!
I expected that when I selected “When In Use” location permission in the popup, only that permission would be granted. However, after selecting “When In Use”, I checked the “Always” permission, and it was also granted, which is not what I expected. I tried checking the status of both permissions using request and check, but I’m still seeing this behavior.
2