-
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
[Geolocation] Add permissionTypeIOS option #1506
Conversation
This should probably be an enum instead of a boolean or at least renamed to be clearer. |
@ide something like Does using ios'y terms make sense or are we trying to keep things platform agnostic? |
Android's permissioning is pretty different (coarse vs. fine updates rather than background vs. foreground) so I think we should optimize for iOS in this commit and clearly name the property something like cc @frantic are you the right person to take a look at geolocation diffs (saw you were active on a few others)? |
IIRC @sahrens built the original implementation. Re: this PR, I think we
|
Ok, replaced backgroundMode with I am not sure about the code style here, e.g. is it appropriate to use indexOf in an invariant argument as a surrogate for enum. Should we enum the permissionTypeIOS option again in objC land? Following react style is less obvious when working outside of components :( Would it make sense to expose an explicity |
{ | ||
[self checkLocationConfig]; | ||
NSLog(@"***$$$$$$$$$$$$$$$$$$$$$$$$ START OBS"); |
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.
rm
This seems ok to - @nicklockwood, you re-wrote this recently, any qualms? |
Ah, thanks @sahrens I changed the constants to be in line with react-native conventions, now: |
This is working great in the background. The only time it stops running is when the display is off. If I press the home button, it starts running again (even while locked) but as soon as the display goes black again, it stops running. My code is the same as the React Native - Geolocation Example (with the added Any ideas why this is happening? I will provide more details if needed. Thanks! Love this! |
@timdoes it may be an issue with your app setup. For example make sure the location background mode is enabled: https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/plist/info/UIBackgroundModes This diff only changes the permission type requested, the mechanism for retrieving the location is still the standard startUpdatingLocation method https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/startUpdatingLocation |
My background mode declaration:
Does this need to be used with a custom library class and bridged to React Native? Sorry if this is a rookie question. Just thought this would add full background capabilities by just declaring the background mode and using the https://facebook.github.io/react-native/docs/geolocation.html example. |
@timdoes just tested this out, and I see the same behaivor (no updates with display off). I do not have a definitive answer for you, apple does not make debugging this types of situations easy. You may consider playing around with allowDeferredLocationUpdatesUntilTraveled:timeout or signifigant location changes api or geofencing (none of which are currently supported by react-native gelocation) |
Actually going to pass this one to nick to finish review and import. |
any news on what's causing the events not to fire when screen is locked ? It must be in the way the bridge eventDispatcher works because didUpdateLocations is called. |
@nicklockwood @rt2zz Any updates on this? |
@rt2zz updated the pull request. |
1 similar comment
@rt2zz updated the pull request. |
@rt2zz updated the pull request. |
@satya164 not sure about the status, but fwiw I just rebased against master, so if you want to take this patch for a test drive feel free. |
@rt2zz Everyone is on holiday. This PR might have to wait till next year :D |
@rt2zz updated the pull request. |
ping @nicklockwood :) |
I'm not wholly happy with the implementation, but in the interests of moving forward, I'll accept this and then make some tweaks in a follow-up diff. |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1453225971642005/int_phab to review. |
Thanks @nicklockwood - let me know if there is anything needed from me to follow up / tweak. |
I'm closing this in favour of #5093, which solves the problem without exposing any proprietary props in Geolocation.js |
Fix the spacing on the footer of prev/next buttons
This adds backgroundMode to the geolocation options. When
options.backgroundMode === true
for both gelocation.getCurrentPosition and gelocation.watchPosition:NSLocationAlwaysUsageDescription
is set in Info.plistrequestAlwaysAuthorization
as opposed torequestWhenInUseAuthorization