Closed akankshaingle closed 2 months ago
Check "About iOS LOCATION_ALWAYS permission" in the README.
Check "About iOS LOCATION_ALWAYS permission" in the README.
Thank you for your response. I’ve reviewed the README and understand the behavior described regarding iOS location permissions. However, I’m still encountering an issue and would appreciate any assistance or insights.
Current Scenario: Requesting "Always" Permission: I am directly requesting the PERMISSIONS.IOS.LOCATION_ALWAYS permission. However, despite this, the options presented to users are "Allow Once," "Never," and "When In Use," and not "Always."
Impact on Background Service: My app relies on continuous location updates for background services. When users only grant "When In Use" permission, these services do not function as required, impacting the app's functionality.
I have requested PERMISSIONS.IOS.LOCATION_ALWAYS directly.
Request for Assistance: Could anyone provide guidance on how to ensure that the "Always" location permission option is presented to users? Since I am not able to get the "Always" status directly and handle the scenario where "When In Use" is granted, I’m unable to guide users effectively.
How can I ensure that users are prompted for "Always" permission and manage the situation if only "When In Use" permission is granted to ensure my background services function correctly?
Any help or suggestions would be greatly appreciated.
You can't have "Always" by default: https://developer.apple.com/documentation/corelocation/cllocationmanager/requestalwaysauthorization()#Request-Always-Authorization-Directly
But you can check for always level and redirect to the app settings to change it if required.
Before submitting a new issue
Bug summary
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);
}
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.
Library version
"^3.3.1"
Environment info
Steps to reproduce
Add the following code in your React Native app to request PERMISSIONS.IOS.LOCATION_WHEN_IN_USE using react-native-permissions. Ensure that both NSLocationWhenInUseUsageDescription and NSLocationAlwaysUsageDescription are included in the Info.plist. if (Platform.OS === 'ios') { const whenInUseStatus = await request(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE); console.log('When In Use status:', whenInUseStatus); }
After the user selects "When In Use" permission in the popup, check for PERMISSIONS.IOS.LOCATION_ALWAYS status. const alwaysStatus = await check(PERMISSIONS.IOS.LOCATION_ALWAYS); console.log('Always permission status:', alwaysStatus);
Reproducible sample code