-
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
FIX: Ensure permission denied in geolocation.getCurrentPosition rejects the Promise #22843
Conversation
54cb006
to
d1f02cd
Compare
The IOS test failure is not releated to this PR. |
error.invoke(PositionError.buildError(PositionError.PERMISSION_DENIED, "Location permission was not granted.")); | ||
} | ||
} | ||
}, new Callback() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you extract these inline Callback ctors to named variables so the code is a bit easier to follow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I will squash the commits once they have been approved.
9edc5d7
to
bf64df4
Compare
I also updated the test project to use the latest commit. |
…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
Generated by 🚫 dangerJS |
Rebased and squashed |
@hramos @matthargett Is there anything else I need to do to get this merged? |
Unfortunately this PR would currently break code at FB. Could you instead create a new native method with this functionality, and keep the old native method around unchanged and then change your JS code to something like: if (RCTLocationObserver.newMethod) {
// handle the new method
} else {
// Old code
} Then I can land this code, and we can remove the old code soon. |
I can, however would like some clarification. So I keep and on the JS side getCurrentPosition becomes this:
Do I understand you correctly? Also, I am wondering do you just strip the new native method during build in FB, or do you depend directly on the old native method not it's js proxy? |
Exactly, that should work for now :) We can then remove the old code in a couple of weeks. |
Hey @Jyrno42, because of App rejections around Geolocation usage we decided to extract Geolocation into https://github.com/react-native-community/react-native-geolocation. You can ship your pull request in that repo, in the original form without the changes that I required as soon as the code appears there. This should be less work for you and allow you to move faster :) |
I was just going to push it but ok :) |
…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
fixes #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 manually with a 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