react-native-radar 3.4.0 → 3.5.4
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
CHANGED
|
@@ -18,7 +18,7 @@ android {
|
|
|
18
18
|
minSdkVersion 16
|
|
19
19
|
targetSdkVersion 31
|
|
20
20
|
versionCode 1
|
|
21
|
-
versionName '3.
|
|
21
|
+
versionName '3.5.4'
|
|
22
22
|
}
|
|
23
23
|
lintOptions {
|
|
24
24
|
abortOnError false
|
|
@@ -45,5 +45,5 @@ repositories {
|
|
|
45
45
|
|
|
46
46
|
dependencies {
|
|
47
47
|
api 'com.facebook.react:react-native:+'
|
|
48
|
-
api 'io.radar:sdk:3.4
|
|
48
|
+
api 'io.radar:sdk:3.5.4'
|
|
49
49
|
}
|
|
@@ -23,6 +23,7 @@ import com.facebook.react.modules.core.PermissionAwareActivity;
|
|
|
23
23
|
import com.facebook.react.modules.core.PermissionListener;
|
|
24
24
|
import io.radar.sdk.Radar;
|
|
25
25
|
import io.radar.sdk.RadarTrackingOptions;
|
|
26
|
+
import io.radar.sdk.RadarTrackingOptions.RadarTrackingOptionsForegroundService;
|
|
26
27
|
import io.radar.sdk.RadarTripOptions;
|
|
27
28
|
import io.radar.sdk.model.RadarAddress;
|
|
28
29
|
import io.radar.sdk.model.RadarContext;
|
|
@@ -174,56 +175,41 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
@ReactMethod
|
|
177
|
-
public void trackOnce(final Promise promise) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
promise.reject(status.toString(), status.toString());
|
|
178
|
+
public void trackOnce(ReadableMap optionsMap, final Promise promise) {
|
|
179
|
+
|
|
180
|
+
Location location = null;
|
|
181
|
+
RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy accuracyLevel = RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.MEDIUM;
|
|
182
|
+
boolean beaconsTrackingOption = false;
|
|
183
|
+
|
|
184
|
+
if (optionsMap != null) {
|
|
185
|
+
if (optionsMap.hasKey("location")) {
|
|
186
|
+
ReadableMap locationMap = optionsMap.getMap("location");
|
|
187
|
+
location = new Location("RNRadarModule");
|
|
188
|
+
double latitude = locationMap.getDouble("latitude");
|
|
189
|
+
double longitude = locationMap.getDouble("longitude");
|
|
190
|
+
float accuracy = (float)locationMap.getDouble("accuracy");
|
|
191
|
+
location.setLatitude(latitude);
|
|
192
|
+
location.setLongitude(longitude);
|
|
193
|
+
location.setAccuracy(accuracy);
|
|
194
|
+
}
|
|
195
|
+
if (optionsMap.hasKey("accuracy")) {
|
|
196
|
+
String accuracy = optionsMap.getString("accuracy").toLowerCase();
|
|
197
|
+
if (accuracy.equals("none")) {
|
|
198
|
+
accuracyLevel = RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.NONE;
|
|
199
|
+
} else if (accuracy.equals("low")) {
|
|
200
|
+
accuracyLevel = RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.LOW;
|
|
201
|
+
} else if (accuracy.equals("medium")) {
|
|
202
|
+
accuracyLevel = RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.MEDIUM;
|
|
203
|
+
} else if (accuracy.equals("high")) {
|
|
204
|
+
accuracyLevel = RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.HIGH;
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
@ReactMethod
|
|
211
|
-
public void trackOnce(ReadableMap locationMap, final Promise promise) {
|
|
212
|
-
if (locationMap == null) {
|
|
213
|
-
this.trackOnce(promise);
|
|
214
|
-
|
|
215
|
-
return;
|
|
207
|
+
if (optionsMap.hasKey("beacons")) {
|
|
208
|
+
beaconsTrackingOption = optionsMap.getBoolean("beacons");
|
|
209
|
+
}
|
|
216
210
|
}
|
|
217
211
|
|
|
218
|
-
|
|
219
|
-
double longitude = locationMap.getDouble("longitude");
|
|
220
|
-
float accuracy = (float)locationMap.getDouble("accuracy");
|
|
221
|
-
Location location = new Location("RNRadarModule");
|
|
222
|
-
location.setLatitude(latitude);
|
|
223
|
-
location.setLongitude(longitude);
|
|
224
|
-
location.setAccuracy(accuracy);
|
|
225
|
-
|
|
226
|
-
Radar.trackOnce(location, new Radar.RadarTrackCallback() {
|
|
212
|
+
Radar.RadarTrackCallback trackCallback = new Radar.RadarTrackCallback() {
|
|
227
213
|
@Override
|
|
228
214
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable Location location, @Nullable RadarEvent[] events, @Nullable RadarUser user) {
|
|
229
215
|
if (promise == null) {
|
|
@@ -252,7 +238,13 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
252
238
|
promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
|
|
253
239
|
}
|
|
254
240
|
}
|
|
255
|
-
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
if (location != null) {
|
|
244
|
+
Radar.trackOnce(location, trackCallback);
|
|
245
|
+
} else {
|
|
246
|
+
Radar.trackOnce(accuracyLevel, beaconsTrackingOption, trackCallback);
|
|
247
|
+
}
|
|
256
248
|
}
|
|
257
249
|
|
|
258
250
|
@ReactMethod
|
|
@@ -320,6 +312,17 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
320
312
|
Radar.stopTracking();
|
|
321
313
|
}
|
|
322
314
|
|
|
315
|
+
@ReactMethod
|
|
316
|
+
public void setForegroundServiceOptions(ReadableMap optionsMap) {
|
|
317
|
+
try {
|
|
318
|
+
JSONObject optionsObj = RNRadarUtils.jsonForMap(optionsMap);
|
|
319
|
+
RadarTrackingOptionsForegroundService options = RadarTrackingOptionsForegroundService.fromJson(optionsObj);
|
|
320
|
+
Radar.setForegroundServiceOptions(options);
|
|
321
|
+
} catch (JSONException e) {
|
|
322
|
+
Log.e(TAG, "JSONException", e);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
323
326
|
@ReactMethod
|
|
324
327
|
public void acceptEvent(String eventId, String verifiedPlaceId) {
|
|
325
328
|
Radar.acceptEvent(eventId, verifiedPlaceId);
|
package/ios/Cartfile.resolved
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
github "radarlabs/radar-sdk-ios" "3.4
|
|
1
|
+
github "radarlabs/radar-sdk-ios" "3.5.4"
|
package/ios/RNRadar.m
CHANGED
|
@@ -179,44 +179,25 @@ RCT_EXPORT_METHOD(getLocation:(RCTPromiseResolveBlock)resolve reject:(RCTPromise
|
|
|
179
179
|
}];
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
RCT_EXPORT_METHOD(trackOnce:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
182
|
+
RCT_EXPORT_METHOD(trackOnce:(NSDictionary *)optionsDict resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
183
|
+
RadarTrackingOptionsDesiredAccuracy desiredAccuracy;
|
|
184
|
+
BOOL beaconsTrackingOption = NO;
|
|
185
|
+
desiredAccuracy = RadarTrackingOptionsDesiredAccuracyMedium;
|
|
186
|
+
|
|
183
187
|
__block RCTPromiseResolveBlock resolver = resolve;
|
|
184
188
|
__block RCTPromiseRejectBlock rejecter = reject;
|
|
185
189
|
|
|
186
|
-
|
|
187
|
-
if (status == RadarStatusSuccess && resolver) {
|
|
188
|
-
NSMutableDictionary *dict = [NSMutableDictionary new];
|
|
189
|
-
[dict setObject:[Radar stringForStatus:status] forKey:@"status"];
|
|
190
|
-
if (location) {
|
|
191
|
-
[dict setObject:[Radar dictionaryForLocation:location] forKey:@"location"];
|
|
192
|
-
}
|
|
193
|
-
if (events) {
|
|
194
|
-
[dict setObject:[RadarEvent arrayForEvents:events] forKey:@"events"];
|
|
195
|
-
}
|
|
196
|
-
if (user) {
|
|
197
|
-
[dict setObject:[user dictionaryValue] forKey:@"user"];
|
|
198
|
-
}
|
|
199
|
-
resolver(dict);
|
|
200
|
-
} else if (rejecter) {
|
|
201
|
-
rejecter([Radar stringForStatus:status], [Radar stringForStatus:status], nil);
|
|
202
|
-
}
|
|
203
|
-
resolver = nil;
|
|
204
|
-
rejecter = nil;
|
|
205
|
-
}];
|
|
206
|
-
}
|
|
190
|
+
NSDictionary *locationDict = optionsDict[@"location"];
|
|
207
191
|
|
|
208
|
-
RCT_EXPORT_METHOD(trackOnce:(NSDictionary *)locationDict resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
209
192
|
CLLocation *location;
|
|
210
193
|
if (locationDict != nil && [locationDict isKindOfClass:[NSDictionary class]]) {
|
|
211
194
|
double latitude = [RCTConvert double:locationDict[@"latitude"]];
|
|
212
195
|
double longitude = [RCTConvert double:locationDict[@"longitude"]];
|
|
196
|
+
double accuracy = [RCTConvert double:locationDict[@"accuracy"]];
|
|
213
197
|
NSDate *timestamp = [NSDate new];
|
|
214
|
-
location = [[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) altitude:-1 horizontalAccuracy:
|
|
198
|
+
location = [[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) altitude:-1 horizontalAccuracy:accuracy verticalAccuracy:-1 timestamp:timestamp];
|
|
215
199
|
}
|
|
216
200
|
|
|
217
|
-
__block RCTPromiseResolveBlock resolver = resolve;
|
|
218
|
-
__block RCTPromiseRejectBlock rejecter = reject;
|
|
219
|
-
|
|
220
201
|
RadarTrackCompletionHandler completionHandler = ^(RadarStatus status, CLLocation * _Nullable location, NSArray<RadarEvent *> * _Nullable events, RadarUser * _Nullable user) {
|
|
221
202
|
if (status == RadarStatusSuccess && resolver) {
|
|
222
203
|
NSMutableDictionary *dict = [NSMutableDictionary new];
|
|
@@ -238,13 +219,33 @@ RCT_EXPORT_METHOD(trackOnce:(NSDictionary *)locationDict resolve:(RCTPromiseReso
|
|
|
238
219
|
rejecter = nil;
|
|
239
220
|
};
|
|
240
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
|
+
|
|
241
235
|
if (location) {
|
|
242
236
|
[Radar trackOnceWithLocation:location completionHandler:completionHandler];
|
|
243
237
|
} else {
|
|
244
|
-
[
|
|
238
|
+
BOOL beacons = optionsDict[@"beacons"];
|
|
239
|
+
|
|
240
|
+
if (beacons) {
|
|
241
|
+
beaconsTrackingOption = beacons;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
[Radar trackOnceWithDesiredAccuracy:desiredAccuracy beacons:beaconsTrackingOption completionHandler:completionHandler];
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
|
|
248
249
|
RCT_EXPORT_METHOD(startTrackingEfficient) {
|
|
249
250
|
[Radar startTrackingWithOptions:RadarTrackingOptions.presetEfficient];
|
|
250
251
|
}
|
|
@@ -306,6 +307,10 @@ RCT_EXPORT_METHOD(stopTracking) {
|
|
|
306
307
|
[Radar stopTracking];
|
|
307
308
|
}
|
|
308
309
|
|
|
310
|
+
RCT_EXPORT_METHOD(setForegroundServiceOptions) {
|
|
311
|
+
// not implemented
|
|
312
|
+
}
|
|
313
|
+
|
|
309
314
|
RCT_EXPORT_METHOD(acceptEvent:(NSString *)eventId verifiedPlaceId:(NSString *)verifiedPlaceId) {
|
|
310
315
|
[Radar acceptEventId:eventId verifiedPlaceId:verifiedPlaceId];
|
|
311
316
|
}
|
package/js/index.js
CHANGED
|
@@ -34,9 +34,17 @@ const getLocation = () => (
|
|
|
34
34
|
NativeModules.RNRadar.getLocation()
|
|
35
35
|
);
|
|
36
36
|
|
|
37
|
-
const trackOnce =
|
|
38
|
-
|
|
39
|
-
)
|
|
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
|
+
};
|
|
40
48
|
|
|
41
49
|
const startTrackingEfficient = () => (
|
|
42
50
|
NativeModules.RNRadar.startTrackingEfficient()
|
|
@@ -62,6 +70,10 @@ const stopTracking = () => (
|
|
|
62
70
|
NativeModules.RNRadar.stopTracking()
|
|
63
71
|
);
|
|
64
72
|
|
|
73
|
+
const setForegroundServiceOptions = options => (
|
|
74
|
+
NativeModules.RNRadar.setForegroundServiceOptions(options)
|
|
75
|
+
);
|
|
76
|
+
|
|
65
77
|
const startTrip = options => (
|
|
66
78
|
NativeModules.RNRadar.startTrip(options)
|
|
67
79
|
);
|
|
@@ -149,6 +161,7 @@ const Radar = {
|
|
|
149
161
|
startTrackingCustom,
|
|
150
162
|
mockTracking,
|
|
151
163
|
stopTracking,
|
|
164
|
+
setForegroundServiceOptions,
|
|
152
165
|
acceptEvent,
|
|
153
166
|
rejectEvent,
|
|
154
167
|
startTrip,
|
package/package.json
CHANGED