-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ios.js
More file actions
94 lines (79 loc) · 2.68 KB
/
index.ios.js
File metadata and controls
94 lines (79 loc) · 2.68 KB
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
import { NativeModules, AppRegistry, NativeEventEmitter } from 'react-native';
const TAG = "GeofenceEventTask"
export default class RNGeolocation {
static registerHeadlessTask(task) {
AppRegistry.registerHeadlessTask(TAG, () => task);
}
static ready(config) {
NativeModules.RNGeolocation.ready();
}
static addNotifications(arrivingNotification, leavingNotification) {
/*
TODO: cleanup this after testing
*/
}
static onGeofence(geofenceListener) {
const GeofenceEvents = new NativeEventEmitter(NativeModules.RNGeolocation)
GeofenceEvents.addListener('geofence', geofenceListener);
/*
This is handled by the native code on it's own
*/
}
static checkAndTriggerCachedEvents() {
NativeModules.RNGeolocation.checkAndTriggerCachedEvents();
}
static startGeofences(successCallback, failureCallback) {
let promise = new Promise((resolve, reject) => {
let success = () => { resolve() }
let failure = (error) => { reject(error) }
NativeModules.RNGeolocation.startGeofences(success, failure);
});
if (!arguments.length) {
return promise;
} else {
return promise.then(successCallback).catch(failureCallback);
}
}
static stop(successCallback, failureCallback) {
let promise = new Promise((resolve, reject) => {
let success = () => { resolve() }
let failure = (error) => { reject(error) }
NativeModules.RNGeolocation.stopGeofences(success, failure);
});
if (!arguments.length) {
return promise;
} else {
return promise.then(successCallback).catch(failureCallback);
}
}
static stopGeofences(successCallback, failureCallback) {
return RNGeolocation.stop(successCallback, failureCallback);
}
static addGeofences(geofences) {
return new Promise((resolve, reject) => {
NativeModules.RNGeolocation.addGeofences(geofences);
resolve();
});
}
static removeGeofences() {
return new Promise((resolve, reject) => {
NativeModules.RNGeolocation.removeGeofences();
resolve();
});
}
static getCurrentPosition(currentPositionRequest, successCallback, failureCallback) {
let promise = new Promise((resolve, reject) => {
let success = (location) => { resolve(location) }
let failure = (error) => { reject(error) }
NativeModules.RNGeolocation.getCurrentPosition(currentPositionRequest || {}, success, failure);
});
if (arguments.length == 1) {
return promise;
} else {
return promise.then(successCallback).catch(failureCallback);
}
}
static isLocationEnabled() {
return NativeModules.RNGeolocation.isLocationEnabled();
}
}