Closed fikkatra closed 9 months ago
This is intentional, as this is the state of the permission, not of the feature + the behavior is unified with android now.
If you use a library to get the user geolocation, you should be able to perform this check with it.
I do appreciate the efforts of having unified behavior with Android. However, I don't think it is in fact unified? In the scenario where permissions are given, but GPS is disabled, a check
on Android returns 'granted' or 'denied' depending on the permissions given. On iOS, we receive 'blocked', regardless of the permissions given. So it's not exactly unified behavior.
This has an impact on deriving whether GPS is disabled or not. For Android, in case of 'granted', if we don't receive actual gps coordinates or we get an error, we can conclude the GPS is disabled.
In case of iOS, when receiving 'blocked' there is no way of knowing the reason (either missing permissions, or GPS disabled). A library to get the user geolocation will return an error in both cases.
You are correct that disabling the GPS has nothing to do with permissions. However, in that case I'd expect check
to return something like null or 'unknown' (or 'granted', 'denied' or 'blocked', depending on actual permissions given). This would indicate the permission state more clearly, imo.
It's unified in the way we now don't check location services statuses before checking permissions on both platforms.
iOS choose to return blocked, android to return denied / granted.
The key is to not start the GPS, but to check if location services is on:
Ok, that seems indeed logical. Thanks for taking the time to explain!
@fikkatra how did you solve the issue to differentiate between the 2 (location services vs app specific permission)
@johhansantana for the status of the location services, we ended up using DeviceInfo.isLocationEnabled()
from react-native-device-info.
Before submitting a new issue
Bug summary
We upgraded from v3.9.2 to v4.1.4 and noticed a change in behavior when checking location permissions on iOS.
When the user granted location permissions to the app, but location services are disabled for the entire device, check(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE) returns blocked.
In prior versions, this used to be unavailable, which makes more sense imo.
The current behavior makes it impossible to make a distinction between permissions not being granted, and location services being disabled completely.
Library version
4.1.4
Environment info
Steps to reproduce
Result: 'blocked'. Expected result (observed in previous versions): 'unavailable' Using real device iPhone 13 Pro
Reproducible sample code