-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Fix for different geolocation timestamp for Android and iOS #6150
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
Conversation
Timestamp is different for Android and iOs. For Android it is returning in UTC time in milliseconds since January 1, 1970, for iOS it was returned as time interval relative to an absolute reference date (00:00:00 UTC on 1 January 2001). Also for iOS time returned was "current system absolute time" and not the time at which this location was determined. Links for iOS: https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/index.html#//apple_ref/occ/instp/CLLocation/timestamp https://developer.apple.com/library/prerelease/ios/documentation/CoreFoundation/Reference/CFTimeUtils/index.html#//apple_ref/c/func/CFAbsoluteTimeGetCurrent https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/index.html#//apple_ref/swift/cl/c:objc%28cs%29NSDate Link for Android: http://developer.android.com/reference/android/location/Location.html#getTime%28%29
By analyzing the blame information on this pull request, we identified @nicklockwood, @brentvatne and @zjj010104 to be potential reviewers. |
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Oh wow, that's terrible. Thanks for the fix. @facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
Summary:Geolocation timestamp is different for Android and iOs. For Android it is returning in UTC time in milliseconds since January 1, 1970, for iOS it was returned as time interval relative to an absolute reference date (00:00:00 UTC on 1 January 2001). Also for iOS time returned was "current system absolute time" and not the time at which this location was determined. Tested with 0.21.0-rc React Native. Init project with this additional code: `constructor(props) {super(props); navigator.geolocation.getCurrentPosition( (position) => { let initialPosition = JSON.stringify(position); console.log(position.timestamp); }, (error) => alert(error.message), {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } ` Tested with iOs simulator (iPhone 6S plus 9.2; iPhone 5s 8.4 ) sample result with change: 1456407795021.235 sample result without change: 23478100615007.884 Explaining links for iOS: https://developer.apple.com/library/ios/do Closes facebook#6150 Differential Revision: D2976909 Pulled By: nicklockwood fb-gh-sync-id: 9607ed669d7200591f8387e4186cf7c225ae9b3a shipit-source-id: 9607ed669d7200591f8387e4186cf7c225ae9b3a
Geolocation timestamp is different for Android and iOs. For Android it is returning in UTC time in milliseconds since January 1, 1970, for iOS it was returned as time interval relative to an absolute reference date (00:00:00 UTC on 1 January 2001). Also for iOS time returned was "current system absolute time" and not the time at which this location was determined.
Tested with 0.21.0-rc React Native. Init project with this additional code:
constructor(props) {super(props); navigator.geolocation.getCurrentPosition( (position) => { let initialPosition = JSON.stringify(position); console.log(position.timestamp); }, (error) => alert(error.message), {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); }
Tested with iOs simulator (iPhone 6S plus 9.2; iPhone 5s 8.4 )
sample result with change: 1456407795021.235
sample result without change: 23478100615007.884
Explaining links for iOS:
https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/index.html#//apple_ref/occ/instp/CLLocation/timestamp
https://developer.apple.com/library/prerelease/ios/documentation/CoreFoundation/Reference/CFTimeUtils/index.html#//apple_ref/c/func/CFAbsoluteTimeGetCurrent
https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/index.html#//apple_ref/swift/cl/c:objc%28cs%29NSDate
Link for Android:
http://developer.android.com/reference/android/location/Location.html#getTime%28%29