Fix for different geolocation timestamp for Android and iOS

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 https://github.com/facebook/react-native/pull/6150

Differential Revision: D2976909

Pulled By: nicklockwood

fb-gh-sync-id: 9607ed669d7200591f8387e4186cf7c225ae9b3a
shipit-source-id: 9607ed669d7200591f8387e4186cf7c225ae9b3a
This commit is contained in:
Gašper Žnidaršič Bečaj 2016-02-25 07:22:18 -08:00 committed by facebook-github-bot-4
parent f0689cf534
commit 13f2aea85f
1 changed files with 1 additions and 1 deletions

View File

@ -270,7 +270,7 @@ RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options
@"heading": @(location.course), @"heading": @(location.course),
@"speed": @(location.speed), @"speed": @(location.speed),
}, },
@"timestamp": @(CFAbsoluteTimeGetCurrent() * 1000.0) // in ms @"timestamp": @([location.timestamp timeIntervalSince1970] * 1000) // in ms
}; };
// Send event // Send event