react-native-radar 3.5.4 → 3.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/radar/react/RNRadarModule.java +6 -6
- package/ios/RNRadar.m +13 -13
- package/js/index.js +7 -182
- package/js/index.native.js +184 -0
- package/js/index.web.js +400 -0
- package/package.json +3 -2
package/android/build.gradle
CHANGED
|
@@ -192,15 +192,15 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
192
192
|
location.setLongitude(longitude);
|
|
193
193
|
location.setAccuracy(accuracy);
|
|
194
194
|
}
|
|
195
|
-
if (optionsMap.hasKey("
|
|
196
|
-
String
|
|
197
|
-
if (
|
|
195
|
+
if (optionsMap.hasKey("desiredAccuracy")) {
|
|
196
|
+
String desiredAccuracy = optionsMap.getString("desiredAccuracy").toLowerCase();
|
|
197
|
+
if (desiredAccuracy.equals("none")) {
|
|
198
198
|
accuracyLevel = RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.NONE;
|
|
199
|
-
} else if (
|
|
199
|
+
} else if (desiredAccuracy.equals("low")) {
|
|
200
200
|
accuracyLevel = RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.LOW;
|
|
201
|
-
} else if (
|
|
201
|
+
} else if (desiredAccuracy.equals("medium")) {
|
|
202
202
|
accuracyLevel = RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.MEDIUM;
|
|
203
|
-
} else if (
|
|
203
|
+
} else if (desiredAccuracy.equals("high")) {
|
|
204
204
|
accuracyLevel = RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.HIGH;
|
|
205
205
|
}
|
|
206
206
|
}
|
package/ios/RNRadar.m
CHANGED
|
@@ -219,22 +219,22 @@ RCT_EXPORT_METHOD(trackOnce:(NSDictionary *)optionsDict resolve:(RCTPromiseResol
|
|
|
219
219
|
rejecter = nil;
|
|
220
220
|
};
|
|
221
221
|
|
|
222
|
-
NSString *accuracy = optionsDict[@"accuracy"];
|
|
223
|
-
|
|
224
|
-
if (accuracy != nil && [accuracy isKindOfClass:[NSString class]]) {
|
|
225
|
-
NSString *lowerAccuracy = [accuracy lowercaseString];
|
|
226
|
-
if ([lowerAccuracy isEqualToString:@"high"]) {
|
|
227
|
-
desiredAccuracy = RadarTrackingOptionsDesiredAccuracyHigh;
|
|
228
|
-
} else if ([lowerAccuracy isEqualToString:@"medium"]) {
|
|
229
|
-
desiredAccuracy = RadarTrackingOptionsDesiredAccuracyMedium;
|
|
230
|
-
} else if ([lowerAccuracy isEqualToString:@"low"]) {
|
|
231
|
-
desiredAccuracy = RadarTrackingOptionsDesiredAccuracyLow;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
222
|
if (location) {
|
|
236
223
|
[Radar trackOnceWithLocation:location completionHandler:completionHandler];
|
|
237
224
|
} else {
|
|
225
|
+
NSString *accuracy = optionsDict[@"desiredAccuracy"];
|
|
226
|
+
|
|
227
|
+
if (accuracy != nil && [accuracy isKindOfClass:[NSString class]]) {
|
|
228
|
+
NSString *lowerAccuracy = [accuracy lowercaseString];
|
|
229
|
+
if ([lowerAccuracy isEqualToString:@"high"]) {
|
|
230
|
+
desiredAccuracy = RadarTrackingOptionsDesiredAccuracyHigh;
|
|
231
|
+
} else if ([lowerAccuracy isEqualToString:@"medium"]) {
|
|
232
|
+
desiredAccuracy = RadarTrackingOptionsDesiredAccuracyMedium;
|
|
233
|
+
} else if ([lowerAccuracy isEqualToString:@"low"]) {
|
|
234
|
+
desiredAccuracy = RadarTrackingOptionsDesiredAccuracyLow;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
238
|
BOOL beacons = optionsDict[@"beacons"];
|
|
239
239
|
|
|
240
240
|
if (beacons) {
|
package/js/index.js
CHANGED
|
@@ -1,184 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
let module = {};
|
|
4
|
+
if (Platform.OS === 'web')
|
|
5
|
+
module = require('./index.web').default;
|
|
6
|
+
else
|
|
7
|
+
module = require('./index.native').default;
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const setLogLevel = (level) => {
|
|
10
|
-
NativeModules.RNRadar.setLogLevel(level);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const setUserId = (userId) => {
|
|
14
|
-
NativeModules.RNRadar.setUserId(userId);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const setDescription = (description) => {
|
|
18
|
-
NativeModules.RNRadar.setDescription(description);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const setMetadata = (metadata) => {
|
|
22
|
-
NativeModules.RNRadar.setMetadata(metadata);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const getPermissionsStatus = () => (
|
|
26
|
-
NativeModules.RNRadar.getPermissionsStatus()
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const requestPermissions = background => (
|
|
30
|
-
NativeModules.RNRadar.requestPermissions(background)
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const getLocation = () => (
|
|
34
|
-
NativeModules.RNRadar.getLocation()
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const trackOnce = options => {
|
|
38
|
-
let backCompatibleOptions = options;
|
|
39
|
-
if (options && options.latitude) {
|
|
40
|
-
backCompatibleOptions = {
|
|
41
|
-
location: {
|
|
42
|
-
...options
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return NativeModules.RNRadar.trackOnce(backCompatibleOptions)
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const startTrackingEfficient = () => (
|
|
50
|
-
NativeModules.RNRadar.startTrackingEfficient()
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
const startTrackingResponsive = () => (
|
|
54
|
-
NativeModules.RNRadar.startTrackingResponsive()
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const startTrackingContinuous = () => (
|
|
58
|
-
NativeModules.RNRadar.startTrackingContinuous()
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
const startTrackingCustom = options => (
|
|
62
|
-
NativeModules.RNRadar.startTrackingCustom(options)
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const mockTracking = options => (
|
|
66
|
-
NativeModules.RNRadar.mockTracking(options)
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
const stopTracking = () => (
|
|
70
|
-
NativeModules.RNRadar.stopTracking()
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const setForegroundServiceOptions = options => (
|
|
74
|
-
NativeModules.RNRadar.setForegroundServiceOptions(options)
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const startTrip = options => (
|
|
78
|
-
NativeModules.RNRadar.startTrip(options)
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const completeTrip = () => (
|
|
82
|
-
NativeModules.RNRadar.completeTrip()
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const cancelTrip = () => (
|
|
86
|
-
NativeModules.RNRadar.cancelTrip()
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
const updateTrip = options => (
|
|
90
|
-
NativeModules.RNRadar.updateTrip(options)
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
const acceptEvent = (eventId, verifiedPlaceId) => (
|
|
94
|
-
NativeModules.RNRadar.acceptEvent(eventId, verifiedPlaceId)
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
const rejectEvent = eventId => (
|
|
98
|
-
NativeModules.RNRadar.rejectEvent(eventId)
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const getContext = location => (
|
|
102
|
-
NativeModules.RNRadar.getContext(location)
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
const searchPlaces = options => (
|
|
106
|
-
NativeModules.RNRadar.searchPlaces(options)
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
const searchGeofences = options => (
|
|
110
|
-
NativeModules.RNRadar.searchGeofences(options)
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const autocomplete = options => (
|
|
114
|
-
NativeModules.RNRadar.autocomplete(options)
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
const geocode = address => (
|
|
118
|
-
NativeModules.RNRadar.geocode(address)
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
const reverseGeocode = location => (
|
|
122
|
-
NativeModules.RNRadar.reverseGeocode(location)
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
const ipGeocode = () => (
|
|
126
|
-
NativeModules.RNRadar.ipGeocode()
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
const getDistance = options => (
|
|
130
|
-
NativeModules.RNRadar.getDistance(options)
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
const getMatrix = options => (
|
|
134
|
-
NativeModules.RNRadar.getMatrix(options)
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
const on = (event, callback) => (
|
|
138
|
-
eventEmitter.addListener(event, callback)
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
const off = (event, callback) => {
|
|
142
|
-
if (callback) {
|
|
143
|
-
eventEmitter.removeListener(event, callback);
|
|
144
|
-
} else {
|
|
145
|
-
eventEmitter.removeAllListeners(event);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const Radar = {
|
|
150
|
-
setLogLevel,
|
|
151
|
-
setUserId,
|
|
152
|
-
setDescription,
|
|
153
|
-
setMetadata,
|
|
154
|
-
getPermissionsStatus,
|
|
155
|
-
requestPermissions,
|
|
156
|
-
getLocation,
|
|
157
|
-
trackOnce,
|
|
158
|
-
startTrackingEfficient,
|
|
159
|
-
startTrackingResponsive,
|
|
160
|
-
startTrackingContinuous,
|
|
161
|
-
startTrackingCustom,
|
|
162
|
-
mockTracking,
|
|
163
|
-
stopTracking,
|
|
164
|
-
setForegroundServiceOptions,
|
|
165
|
-
acceptEvent,
|
|
166
|
-
rejectEvent,
|
|
167
|
-
startTrip,
|
|
168
|
-
updateTrip,
|
|
169
|
-
completeTrip,
|
|
170
|
-
cancelTrip,
|
|
171
|
-
getContext,
|
|
172
|
-
searchPlaces,
|
|
173
|
-
searchGeofences,
|
|
174
|
-
autocomplete,
|
|
175
|
-
geocode,
|
|
176
|
-
reverseGeocode,
|
|
177
|
-
ipGeocode,
|
|
178
|
-
getDistance,
|
|
179
|
-
getMatrix,
|
|
180
|
-
on,
|
|
181
|
-
off,
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
export default Radar;
|
|
9
|
+
export default module;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
if (!NativeModules.RNRadar && (Platform.OS === 'ios' || Platform.OS === 'android')) {
|
|
4
|
+
throw new Error('NativeModules.RNRadar is undefined');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const eventEmitter = new NativeEventEmitter(NativeModules.RNRadar);
|
|
8
|
+
|
|
9
|
+
const setLogLevel = (level) => {
|
|
10
|
+
NativeModules.RNRadar.setLogLevel(level);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const setUserId = (userId) => {
|
|
14
|
+
NativeModules.RNRadar.setUserId(userId);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const setDescription = (description) => {
|
|
18
|
+
NativeModules.RNRadar.setDescription(description);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const setMetadata = (metadata) => {
|
|
22
|
+
NativeModules.RNRadar.setMetadata(metadata);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const getPermissionsStatus = () => (
|
|
26
|
+
NativeModules.RNRadar.getPermissionsStatus()
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const requestPermissions = background => (
|
|
30
|
+
NativeModules.RNRadar.requestPermissions(background)
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const getLocation = () => (
|
|
34
|
+
NativeModules.RNRadar.getLocation()
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const trackOnce = options => {
|
|
38
|
+
let backCompatibleOptions = options;
|
|
39
|
+
if (options && options.latitude) {
|
|
40
|
+
backCompatibleOptions = {
|
|
41
|
+
location: {
|
|
42
|
+
...options
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return NativeModules.RNRadar.trackOnce(backCompatibleOptions)
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const startTrackingEfficient = () => (
|
|
50
|
+
NativeModules.RNRadar.startTrackingEfficient()
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const startTrackingResponsive = () => (
|
|
54
|
+
NativeModules.RNRadar.startTrackingResponsive()
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const startTrackingContinuous = () => (
|
|
58
|
+
NativeModules.RNRadar.startTrackingContinuous()
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const startTrackingCustom = options => (
|
|
62
|
+
NativeModules.RNRadar.startTrackingCustom(options)
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const mockTracking = options => (
|
|
66
|
+
NativeModules.RNRadar.mockTracking(options)
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const stopTracking = () => (
|
|
70
|
+
NativeModules.RNRadar.stopTracking()
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const setForegroundServiceOptions = options => (
|
|
74
|
+
NativeModules.RNRadar.setForegroundServiceOptions(options)
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const startTrip = options => (
|
|
78
|
+
NativeModules.RNRadar.startTrip(options)
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const completeTrip = () => (
|
|
82
|
+
NativeModules.RNRadar.completeTrip()
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const cancelTrip = () => (
|
|
86
|
+
NativeModules.RNRadar.cancelTrip()
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const updateTrip = options => (
|
|
90
|
+
NativeModules.RNRadar.updateTrip(options)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const acceptEvent = (eventId, verifiedPlaceId) => (
|
|
94
|
+
NativeModules.RNRadar.acceptEvent(eventId, verifiedPlaceId)
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const rejectEvent = eventId => (
|
|
98
|
+
NativeModules.RNRadar.rejectEvent(eventId)
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const getContext = location => (
|
|
102
|
+
NativeModules.RNRadar.getContext(location)
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const searchPlaces = options => (
|
|
106
|
+
NativeModules.RNRadar.searchPlaces(options)
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const searchGeofences = options => (
|
|
110
|
+
NativeModules.RNRadar.searchGeofences(options)
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const autocomplete = options => (
|
|
114
|
+
NativeModules.RNRadar.autocomplete(options)
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const geocode = address => (
|
|
118
|
+
NativeModules.RNRadar.geocode(address)
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const reverseGeocode = location => (
|
|
122
|
+
NativeModules.RNRadar.reverseGeocode(location)
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const ipGeocode = () => (
|
|
126
|
+
NativeModules.RNRadar.ipGeocode()
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const getDistance = options => (
|
|
130
|
+
NativeModules.RNRadar.getDistance(options)
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
const getMatrix = options => (
|
|
134
|
+
NativeModules.RNRadar.getMatrix(options)
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const on = (event, callback) => (
|
|
138
|
+
eventEmitter.addListener(event, callback)
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const off = (event, callback) => {
|
|
142
|
+
if (callback) {
|
|
143
|
+
eventEmitter.removeListener(event, callback);
|
|
144
|
+
} else {
|
|
145
|
+
eventEmitter.removeAllListeners(event);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const Radar = {
|
|
150
|
+
setLogLevel,
|
|
151
|
+
setUserId,
|
|
152
|
+
setDescription,
|
|
153
|
+
setMetadata,
|
|
154
|
+
getPermissionsStatus,
|
|
155
|
+
requestPermissions,
|
|
156
|
+
getLocation,
|
|
157
|
+
trackOnce,
|
|
158
|
+
startTrackingEfficient,
|
|
159
|
+
startTrackingResponsive,
|
|
160
|
+
startTrackingContinuous,
|
|
161
|
+
startTrackingCustom,
|
|
162
|
+
mockTracking,
|
|
163
|
+
stopTracking,
|
|
164
|
+
setForegroundServiceOptions,
|
|
165
|
+
acceptEvent,
|
|
166
|
+
rejectEvent,
|
|
167
|
+
startTrip,
|
|
168
|
+
updateTrip,
|
|
169
|
+
completeTrip,
|
|
170
|
+
cancelTrip,
|
|
171
|
+
getContext,
|
|
172
|
+
searchPlaces,
|
|
173
|
+
searchGeofences,
|
|
174
|
+
autocomplete,
|
|
175
|
+
geocode,
|
|
176
|
+
reverseGeocode,
|
|
177
|
+
ipGeocode,
|
|
178
|
+
getDistance,
|
|
179
|
+
getMatrix,
|
|
180
|
+
on,
|
|
181
|
+
off,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export default Radar;
|
package/js/index.web.js
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import RadarJS from 'radar-sdk-js';
|
|
2
|
+
|
|
3
|
+
const initialize = (publishableKey) => {
|
|
4
|
+
RadarJS.initialize(publishableKey);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const setLogLevel = (level) => {
|
|
8
|
+
// not implemented
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const setUserId = (userId) => {
|
|
12
|
+
RadarJS.setUserId(userId);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const setDeviceId = (deviceId, installId) => {
|
|
16
|
+
RadarJS.setDeviceId(deviceId, installId);
|
|
17
|
+
}
|
|
18
|
+
const setDeviceType = (deviceType) => {
|
|
19
|
+
RadarJS.setDeviceType(deviceType);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const setRequestHeaders = (headers) => {
|
|
23
|
+
RadarJS.setRequestHeaders(headers);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const setDescription = (description) => {
|
|
27
|
+
RadarJS.setDescription(description);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const setMetadata = (metadata) => {
|
|
31
|
+
RadarJS.setMetadata(metadata);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const getPermissionsStatus = () => {
|
|
35
|
+
return new Promise(resolve => {
|
|
36
|
+
const navigator = window.navigator;
|
|
37
|
+
|
|
38
|
+
if (!navigator.permissions) {
|
|
39
|
+
resolve({
|
|
40
|
+
status: 'UNKNOWN'
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
navigator.permissions.query({ name: 'geolocation' }).then((result) => {
|
|
44
|
+
resolve({
|
|
45
|
+
status: result.state === 'granted' ? 'GRANTED_FOREGROUND' : 'DENIED',
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const requestPermissions = background => {
|
|
53
|
+
// not implemented
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const getLocation = () => {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
RadarJS.getLocation((err, result) => {
|
|
59
|
+
if (err)
|
|
60
|
+
reject(err);
|
|
61
|
+
else
|
|
62
|
+
resolve(result);
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const trackOnce = options => {
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
const callback = (err, { status, location, user, events }) => {
|
|
70
|
+
if (err) {
|
|
71
|
+
reject(err);
|
|
72
|
+
} else {
|
|
73
|
+
resolve({
|
|
74
|
+
status,
|
|
75
|
+
location,
|
|
76
|
+
user,
|
|
77
|
+
events,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
if (options) {
|
|
83
|
+
RadarJS.trackOnce(options.location ? options.location : options, callback);
|
|
84
|
+
} else {
|
|
85
|
+
RadarJS.trackOnce(callback);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const startTrackingEfficient = () => {
|
|
91
|
+
// not implemented
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const startTrackingResponsive = () => {
|
|
95
|
+
// not implemented
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const startTrackingContinuous = () => {
|
|
99
|
+
// not implemented
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const startTrackingCustom = options => {
|
|
103
|
+
// not implemented
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const mockTracking = options => {
|
|
107
|
+
// not implemented
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const stopTracking = () => {
|
|
111
|
+
// not implemented
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const setForegroundServiceOptions = options => {
|
|
115
|
+
// not implemented
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const startTrip = options => {
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
const callback = (err, { trip, events, status }) => {
|
|
121
|
+
if (err) {
|
|
122
|
+
reject(err);
|
|
123
|
+
} else {
|
|
124
|
+
resolve({
|
|
125
|
+
trip,
|
|
126
|
+
events,
|
|
127
|
+
status
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
RadarJS.startTrip(options, callback);
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const completeTrip = () => {
|
|
137
|
+
return new Promise((resolve, reject) => {
|
|
138
|
+
const callback = (err, { trip, events, status }) => {
|
|
139
|
+
if (err) {
|
|
140
|
+
reject(err);
|
|
141
|
+
} else {
|
|
142
|
+
resolve({
|
|
143
|
+
trip,
|
|
144
|
+
events,
|
|
145
|
+
status
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
RadarJS.completeTrip(callback);
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const cancelTrip = () => {
|
|
155
|
+
return new Promise((resolve, reject) => {
|
|
156
|
+
const callback = (err, { trip, events, status }) => {
|
|
157
|
+
if (err) {
|
|
158
|
+
reject(err);
|
|
159
|
+
} else {
|
|
160
|
+
resolve({
|
|
161
|
+
trip,
|
|
162
|
+
events,
|
|
163
|
+
status
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
RadarJS.cancelTrip(callback);
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const updateTrip = (tripOptions) => {
|
|
173
|
+
return new Promise((resolve, reject) => {
|
|
174
|
+
const callback = (err, { trip, events, status }) => {
|
|
175
|
+
if (err) {
|
|
176
|
+
reject(err);
|
|
177
|
+
} else {
|
|
178
|
+
resolve({
|
|
179
|
+
trip,
|
|
180
|
+
events,
|
|
181
|
+
status
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
RadarJS.updateTrip(tripOptions.options, tripOptions.status, callback);
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const acceptEvent = (eventId, verifiedPlaceId) => {
|
|
191
|
+
// not implemented
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const rejectEvent = eventId => {
|
|
195
|
+
// not implemented
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const getContext = options => {
|
|
199
|
+
return new Promise((resolve, reject) => {
|
|
200
|
+
const callback = (err, { status, location, context }) => {
|
|
201
|
+
if (err) {
|
|
202
|
+
reject(err);
|
|
203
|
+
} else {
|
|
204
|
+
resolve({
|
|
205
|
+
status,
|
|
206
|
+
location,
|
|
207
|
+
context,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
if (options) {
|
|
213
|
+
RadarJS.getContext(options, callback);
|
|
214
|
+
} else {
|
|
215
|
+
RadarJS.getContext(callback);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const searchPlaces = options => {
|
|
221
|
+
return new Promise((resolve, reject) => {
|
|
222
|
+
RadarJS.searchPlaces(options, (err, { status, location, places }) => {
|
|
223
|
+
if (err) {
|
|
224
|
+
reject(err);
|
|
225
|
+
} else {
|
|
226
|
+
resolve({
|
|
227
|
+
status,
|
|
228
|
+
location,
|
|
229
|
+
places,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const searchGeofences = options => {
|
|
237
|
+
return new Promise((resolve, reject) => {
|
|
238
|
+
RadarJS.searchGeofences(options, (err, { status, location, geofences }) => {
|
|
239
|
+
if (err) {
|
|
240
|
+
reject(err);
|
|
241
|
+
} else {
|
|
242
|
+
resolve({
|
|
243
|
+
status,
|
|
244
|
+
location,
|
|
245
|
+
geofences,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
const autocomplete = options => {
|
|
253
|
+
return new Promise((resolve, reject) => {
|
|
254
|
+
RadarJS.autocomplete(options, (err, { status, addresses }) => {
|
|
255
|
+
if (err) {
|
|
256
|
+
reject(err);
|
|
257
|
+
} else {
|
|
258
|
+
resolve({
|
|
259
|
+
status,
|
|
260
|
+
addresses,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
const geocode = options => {
|
|
268
|
+
return new Promise((resolve, reject) => {
|
|
269
|
+
let newOptions = options;
|
|
270
|
+
if (typeof options === 'string')
|
|
271
|
+
newOptions = {
|
|
272
|
+
query: options
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
RadarJS.geocode(newOptions, (err, { status, addresses }) => {
|
|
276
|
+
if (err) {
|
|
277
|
+
reject(err);
|
|
278
|
+
} else {
|
|
279
|
+
resolve({
|
|
280
|
+
status,
|
|
281
|
+
addresses,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const reverseGeocode = options => {
|
|
289
|
+
return new Promise((resolve, reject) => {
|
|
290
|
+
const callback = (err, { status, addresses }) => {
|
|
291
|
+
if (err) {
|
|
292
|
+
reject(err);
|
|
293
|
+
} else {
|
|
294
|
+
resolve({
|
|
295
|
+
status,
|
|
296
|
+
addresses,
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
if (options) {
|
|
302
|
+
RadarJS.reverseGeocode(options, callback);
|
|
303
|
+
} else {
|
|
304
|
+
RadarJS.reverseGeocode(callback);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const ipGeocode = () => {
|
|
310
|
+
return new Promise((resolve, reject) => {
|
|
311
|
+
RadarJS.ipGeocode((err, { status, address }) => {
|
|
312
|
+
if (err) {
|
|
313
|
+
reject(err);
|
|
314
|
+
} else {
|
|
315
|
+
resolve({
|
|
316
|
+
status,
|
|
317
|
+
address,
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const getDistance = options => {
|
|
325
|
+
return new Promise((resolve, reject) => {
|
|
326
|
+
RadarJS.getDistance(options, (err, { status, routes }) => {
|
|
327
|
+
if (err) {
|
|
328
|
+
reject(err);
|
|
329
|
+
} else {
|
|
330
|
+
resolve({
|
|
331
|
+
status,
|
|
332
|
+
routes,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
const getMatrix = options => {
|
|
340
|
+
return new Promise((resolve, reject) => {
|
|
341
|
+
RadarJS.getMatrix(options, (err, { origins, destinations, matrix, status }) => {
|
|
342
|
+
if (err) {
|
|
343
|
+
reject(err);
|
|
344
|
+
} else {
|
|
345
|
+
resolve({
|
|
346
|
+
origins,
|
|
347
|
+
destinations,
|
|
348
|
+
matrix,
|
|
349
|
+
status,
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const on = (event, callback) => {
|
|
357
|
+
// not implemented
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
const off = (event, callback) => {
|
|
361
|
+
// not implemented
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
const Radar = {
|
|
365
|
+
initialize,
|
|
366
|
+
setLogLevel,
|
|
367
|
+
setUserId,
|
|
368
|
+
setDescription,
|
|
369
|
+
setMetadata,
|
|
370
|
+
getPermissionsStatus,
|
|
371
|
+
requestPermissions,
|
|
372
|
+
getLocation,
|
|
373
|
+
trackOnce,
|
|
374
|
+
startTrackingEfficient,
|
|
375
|
+
startTrackingResponsive,
|
|
376
|
+
startTrackingContinuous,
|
|
377
|
+
startTrackingCustom,
|
|
378
|
+
mockTracking,
|
|
379
|
+
stopTracking,
|
|
380
|
+
setForegroundServiceOptions,
|
|
381
|
+
acceptEvent,
|
|
382
|
+
rejectEvent,
|
|
383
|
+
startTrip,
|
|
384
|
+
updateTrip,
|
|
385
|
+
completeTrip,
|
|
386
|
+
cancelTrip,
|
|
387
|
+
getContext,
|
|
388
|
+
searchPlaces,
|
|
389
|
+
searchGeofences,
|
|
390
|
+
autocomplete,
|
|
391
|
+
geocode,
|
|
392
|
+
reverseGeocode,
|
|
393
|
+
ipGeocode,
|
|
394
|
+
getDistance,
|
|
395
|
+
getMatrix,
|
|
396
|
+
on,
|
|
397
|
+
off,
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
export default Radar;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "React Native module for Radar, the leading geofencing and location tracking platform",
|
|
4
4
|
"homepage": "https://radar.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"version": "3.5.
|
|
6
|
+
"version": "3.5.6",
|
|
7
7
|
"main": "js/index.js",
|
|
8
8
|
"files": [
|
|
9
9
|
"android",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"metro-react-native-babel-preset": "^0.51.1",
|
|
49
49
|
"npm-run-all": "^4.1.5",
|
|
50
50
|
"react": "16.8.6",
|
|
51
|
-
"react-native": "0.60.0"
|
|
51
|
+
"react-native": "0.60.0",
|
|
52
|
+
"radar-sdk-js": "^3.3.0"
|
|
52
53
|
},
|
|
53
54
|
"bugs": {
|
|
54
55
|
"url": "https://github.com/radarlabs/react-native-radar/issues"
|