-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle permission denied in geolocation service #22535
Closed
3 tasks done
LaurelOlson opened this issue
Dec 6, 2018
· 5 comments
· Fixed by michalchudziak/react-native-geolocation#1
Closed
3 tasks done
Handle permission denied in geolocation service #22535
LaurelOlson opened this issue
Dec 6, 2018
· 5 comments
· Fixed by michalchudziak/react-native-geolocation#1
Labels
API: Geolocation
Bug
Help Wanted
Issues ideal for external contributors.
Platform: Android
Android applications.
Resolution: Locked
This issue was locked by the bot.
Comments
react-native-bot
added
🔶APIs
API: Geolocation
Platform: Android
Android applications.
labels
Dec 6, 2018
hramos
changed the title
[Android] - handle permission denied in geolocation service
Handle permission denied in geolocation service
Dec 14, 2018
Jyrno42
added a commit
to Jyrno42/react-native
that referenced
this issue
Dec 26, 2018
Jyrno42
added a commit
to Jyrno42/react-native
that referenced
this issue
Dec 26, 2018
Working on this |
Jyrno42
added a commit
to Jyrno42/react-native
that referenced
this issue
Dec 31, 2018
Jyrno42
added a commit
to Jyrno42/react-native
that referenced
this issue
Jan 2, 2019
…ts the Promise fixes facebook#22535 Moves the permission request logic on Android M and above to Native side to mimic IOS behavior. Changelog: ---------- [Android] [Fixed] - Ensure permission denied in geolocation.getCurrentPosition rejects the promise Test Plan: ---------- Verified via my test project which requests location via Geolocation service. If the permission request is denied by the user the promise is rejected as well. https://github.com/Jyrno42/rn-geoloctest
Jyrno42
added a commit
to Jyrno42/react-native
that referenced
this issue
Jan 2, 2019
…ts the Promise fixes facebook#22535 Moves the permission request logic on Android M and above to Native side to mimic IOS behavior. Changelog: ---------- [Android] [Fixed] - Ensure permission denied in geolocation.getCurrentPosition rejects the promise Test Plan: ---------- Verified via my test project which requests location via Geolocation service. If the permission request is denied by the user the promise is rejected as well. https://github.com/Jyrno42/rn-geoloctest
Jyrno42
added a commit
to Jyrno42/react-native
that referenced
this issue
Jan 25, 2019
…ts the Promise fixes facebook#22535 Moves the permission request logic on Android M and above to Native side to mimic IOS behavior. Changelog: ---------- [Android] [Fixed] - Ensure permission denied in geolocation.getCurrentPosition rejects the promise Test Plan: ---------- Verified via my test project which requests location via Geolocation service. If the permission request is denied by the user the promise is rejected as well. https://github.com/Jyrno42/rn-geoloctest
Jyrno42
added a commit
to Jyrno42/react-native
that referenced
this issue
Feb 8, 2019
…ts the Promise fixes facebook#22535 Moves the permission request logic on Android M and above to Native side to mimic IOS behavior. Changelog: ---------- [Android] [Fixed] - Ensure permission denied in geolocation.getCurrentPosition rejects the promise Test Plan: ---------- Verified via my test project which requests location via Geolocation service. If the permission request is denied by the user the promise is rejected as well. https://github.com/Jyrno42/rn-geoloctest
Quick Workaround I'm using: function getLocation(): Promise<Position, PositionError> {
return new Promise(async (resolve, reject) => {
if (Platform.OS === 'android') {
// https://github.com/facebook/react-native/issues/22535
const permission = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION)
if (permission === PermissionsAndroid.RESULTS.GRANTED) {
return navigator.geolocation.getCurrentPosition(resolve, reject)
} else {
reject(new Error('Refused the permission ACCESS_FINE_LOCATION'))
}
} else {
navigator.geolocation.getCurrentPosition(resolve, reject)
}
})
} |
Jyrno42
added a commit
to Jyrno42/react-native-geolocation
that referenced
this issue
Mar 30, 2019
…ts the Promise fixes facebook/react-native#22535 Moves the permission request logic on Android M and above to Native side to mimic IOS behavior. Changelog: ---------- [Android] [Fixed] - Ensure permission denied in geolocation.getCurrentPosition rejects the promise Test Plan: ---------- Was originally reviewed and accepted as facebook/react-native#22843 as part of core react-native. That PR was verified via my test project which requested location via Geolocation service. If the permission request was denied by the user the promise was rejected as well. https://github.com/Jyrno42/rn-geoloctest
This issue can probably be closed once GeoLocation has been removed from core RN. The fix for this bug has been filed in the new repository as: michalchudziak/react-native-geolocation#1 |
Thanks @Jyrno42, Looking at your PR now! |
Good job. Working for me |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
API: Geolocation
Bug
Help Wanted
Issues ideal for external contributors.
Platform: Android
Android applications.
Resolution: Locked
This issue was locked by the bot.
Environment
Description
On Android, if the user denies location permissions, the
getCurrentPosition
function inGeolocation.js
does not call thegeo_error
callback as expected.As per the docs regarding permissions for android SDK 23+, access must be granted for certain permissions. In the case of the location permission, the RN Geolocation service handles this in the
getCurrentPosition
function (with some issues). These issues could be avoided by doing the android permission request yourself but it seems like this should either be fixed or removed from the geolocation service code to avoid confusion.It appears the correct fix would involve moving the android permission check/request code into the android
LocationModule.java
file, as the rest of the error handling knowledge live within the java code and this is how it is done in iOS.We have added a temporary fix for this internally by patching
getCurrentPosition
so it calls thegeo_error
callback if permission is denied (see below) but as mentioned, this does not seem to be the proper place for this code.Figured I would open the issue in case anyone else is running into a similar issue, and with the hopes that this will eventually get properly fixed.
Reproducible Demo
Create a react native app and request location via the Geolocation servie. If location is denied on android, the
geo_error
callback will not be triggered as it is on iOS.The text was updated successfully, but these errors were encountered: