forked from mauron85/react-native-background-geolocation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
126 lines (104 loc) · 3.5 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
'use strict';
var { DeviceEventEmitter, NativeModules } = require('react-native');
const RNBackgroundGeolocation = NativeModules.BackgroundGeolocation;
function emptyFn() {}
var BackgroundGeolocation = {
events: ['location', 'stationary', 'error'],
provider: {
ANDROID_DISTANCE_FILTER_PROVIDER: 0,
ANDROID_ACTIVITY_PROVIDER: 1
},
mode: {
BACKGROUND: 0,
FOREGROUND: 1
},
accuracy: {
HIGH: 0,
MEDIUM: 100,
LOW: 1000,
PASSIVE: 10000
},
configure: function(config, successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.configure(config, successFn, errorFn);
},
start: function(successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.start(successFn, errorFn);
},
stop: function(successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.stop(successFn, errorFn);
},
isLocationEnabled: function(successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.isLocationEnabled(successFn, errorFn);
},
showAppSettings: function() {
RNBackgroundGeolocation.showAppSettings();
},
showLocationSettings: function() {
RNBackgroundGeolocation.showLocationSettings();
},
watchLocationMode: function(successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.watchLocationMode(successFn, errorFn);
},
stopWatchingLocationMode: function(successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.stopWatchingLocationMode(successFn, errorFn);
},
getLocations: function(successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.getLocations(successFn, errorFn);
},
/*
getValidLocations: function(successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.getValidLocations(successFn, errorFn);
},
deleteLocation: function(locationId, successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.deleteLocation(locationId, successFn, errorFn);
},
deleteAllLocations: function(successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.deleteAllLocations(successFn, errorFn);
},
*/
switchMode: function(modeId, successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.switchMode(modeId, successFn, errorFn);
},
getConfig: function(successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.getConfig(successFn, errorFn);
},
getLogEntries: function(limit, successFn, errorFn) {
successFn = successFn || emptyFn;
errorFn = errorFn || emptyFn;
RNBackgroundGeolocation.getLogEntries(limit, successFn, errorFn);
},
on: function(event, callbackFn) {
if (typeof callbackFn !== 'function') {
throw 'RNBackgroundGeolocation: callback function must be provided';
}
if (this.events.indexOf(event) < 0) {
throw 'RNBackgroundGeolocation: Unknown event "' + event + '"';
}
return DeviceEventEmitter.addListener(event, callbackFn);
}
};
module.exports = BackgroundGeolocation;