mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
0f4a781df0
Co-authored-by: Roman Musin <musinrr@gmail.com> Squashed commit of the following: commit c3916ee544d2b59e6b0c760366a9a2b5f821b029 Author: Laurent Cozic <laurent@cozic.net> Date: Fri Jun 5 00:01:18 2020 +0100 Fixed for iOS commit959a8b59d1
Author: Roman Musin <musinrr@gmail.com> Date: Thu Jun 4 21:56:43 2020 +0100 Initialize keychain service when starting mobile app commit2b322352ed
Author: Roman Musin <musinrr@gmail.com> Date: Thu Jun 4 21:32:40 2020 +0100 Mobile: fix geolocation
43 lines
927 B
JavaScript
43 lines
927 B
JavaScript
import Geolocation from '@react-native-community/geolocation';
|
|
|
|
const Setting = require('lib/models/Setting.js');
|
|
|
|
class GeolocationReact {
|
|
static currentPosition_testResponse() {
|
|
return {
|
|
mocked: false,
|
|
timestamp: new Date().getTime(),
|
|
coords: {
|
|
speed: 0,
|
|
heading: 0,
|
|
accuracy: 20,
|
|
longitude: -3.4596633911132812,
|
|
altitude: 0,
|
|
latitude: 48.73219093634444,
|
|
},
|
|
};
|
|
}
|
|
|
|
static currentPosition(options = null) {
|
|
if (Setting.value('env') == 'dev') return this.currentPosition_testResponse();
|
|
|
|
if (!options) options = {};
|
|
if (!('enableHighAccuracy' in options)) options.enableHighAccuracy = true;
|
|
if (!('timeout' in options)) options.timeout = 10000;
|
|
|
|
return new Promise((resolve, reject) => {
|
|
Geolocation.getCurrentPosition(
|
|
data => {
|
|
resolve(data);
|
|
},
|
|
error => {
|
|
reject(error);
|
|
},
|
|
options
|
|
);
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = { GeolocationReact };
|