react-native-radar 3.1.7 → 3.2.3

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/README.md CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/react-native-radar.svg)](https://www.npmjs.com/package/react-native-radar)
4
4
 
5
- [Radar](https://radar.io) is the leading geofencing and location tracking platform.
5
+ [Radar](https://radar.com) is the leading geofencing and location tracking platform.
6
6
 
7
7
  The Radar SDK abstracts away cross-platform differences between location services, allowing you to add geofencing, location tracking, trip tracking, geocoding, and search to your apps with just a few lines of code.
8
8
 
9
9
  ## Documentation
10
10
 
11
- See the Radar overview documentation [here](https://radar.io/documentation).
11
+ See the Radar overview documentation [here](https://radar.com/documentation).
12
12
 
13
- Then, see the Radar React Native module documentation [here](https://radar.io/documentation/sdk/react-native).
13
+ Then, see the Radar React Native module documentation [here](https://radar.com/documentation/sdk/react-native).
14
14
 
15
15
  ## Examples
16
16
 
@@ -18,4 +18,4 @@ See an example app in `example/`.
18
18
 
19
19
  ## Support
20
20
 
21
- Have questions? We're here to help! Email us at [support@radar.io](mailto:support@radar.io).
21
+ Have questions? We're here to help! Email us at [support@radar.com](mailto:support@radar.com).
@@ -1,26 +1,24 @@
1
1
  buildscript {
2
2
  repositories {
3
- maven {
4
- url 'https://maven.google.com'
5
- }
6
- jcenter()
3
+ google()
4
+ mavenCentral()
7
5
  }
8
6
 
9
7
  dependencies {
10
- classpath 'com.android.tools.build:gradle:3.1.3'
8
+ classpath 'com.android.tools.build:gradle:7.0.3'
11
9
  }
12
10
  }
13
11
 
14
12
  apply plugin: 'com.android.library'
15
13
 
16
14
  android {
17
- compileSdkVersion 29
15
+ compileSdkVersion 31
18
16
 
19
17
  defaultConfig {
20
18
  minSdkVersion 16
21
- targetSdkVersion 29
19
+ targetSdkVersion 31
22
20
  versionCode 1
23
- versionName '3.1.7'
21
+ versionName '3.2.3'
24
22
  }
25
23
  lintOptions {
26
24
  abortOnError false
@@ -28,14 +26,17 @@ android {
28
26
  testOptions {
29
27
  unitTests.returnDefaultValues = true
30
28
  }
29
+ configurations.all {
30
+ resolutionStrategy {
31
+ force 'androidx.core:core:1.6.0'
32
+ force 'androidx.core:core-ktx:1.6.0'
33
+ }
34
+ }
31
35
  }
32
36
 
33
37
  repositories {
34
38
  mavenCentral()
35
- maven {
36
- url 'https://maven.google.com'
37
- }
38
- jcenter()
39
+ google()
39
40
  maven {
40
41
  // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
41
42
  url "$rootDir/../node_modules/react-native/android"
@@ -44,5 +45,5 @@ repositories {
44
45
 
45
46
  dependencies {
46
47
  api 'com.facebook.react:react-native:+'
47
- api 'io.radar:sdk:3.1.15'
48
+ api 'io.radar:sdk:3.2.4'
48
49
  }
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
3
3
  distributionPath=wrapper/dists
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
@@ -0,0 +1 @@
1
+ android.useAndroidX=true
@@ -1,15 +1,4 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
2
  package="io.radar.react">
3
3
 
4
- <application>
5
- <receiver
6
- android:name="io.radar.react.RNRadarReceiver"
7
- android:enabled="true"
8
- android:exported="false">
9
- <intent-filter>
10
- <action android:name="io.radar.sdk.RECEIVED" />
11
- </intent-filter>
12
- </receiver>
13
- </application>
14
-
15
4
  </manifest>
@@ -31,6 +31,7 @@ import io.radar.sdk.model.RadarGeofence;
31
31
  import io.radar.sdk.model.RadarPlace;
32
32
  import io.radar.sdk.model.RadarRouteMatrix;
33
33
  import io.radar.sdk.model.RadarRoutes;
34
+ import io.radar.sdk.model.RadarTrip;
34
35
  import io.radar.sdk.model.RadarUser;
35
36
 
36
37
  import org.json.JSONException;
@@ -46,6 +47,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
46
47
 
47
48
  public RNRadarModule(ReactApplicationContext reactContext) {
48
49
  super(reactContext);
50
+ Radar.setReceiver(new RNRadarReceiver());
49
51
  }
50
52
 
51
53
  @Override
@@ -329,41 +331,165 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
329
331
  }
330
332
 
331
333
  @ReactMethod
332
- public void startTrip(ReadableMap optionsMap) {
334
+ public void startTrip(ReadableMap optionsMap, final Promise promise) {
333
335
  try {
334
336
  JSONObject optionsObj = RNRadarUtils.jsonForMap(optionsMap);
335
337
  RadarTripOptions options = RadarTripOptions.fromJson(optionsObj);
336
338
  Radar.startTrip(options, new Radar.RadarTripCallback() {
337
339
  @Override
338
- public void onComplete(@NonNull Radar.RadarStatus status) {
339
-
340
+ public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
341
+ if (promise == null) {
342
+ return;
343
+ }
344
+ try {
345
+ if (status == Radar.RadarStatus.SUCCESS) {
346
+ WritableMap map = Arguments.createMap();
347
+ map.putString("status", status.toString());
348
+ if (trip != null) {
349
+ map.putMap("trip", RNRadarUtils.mapForJson(trip.toJson()));
350
+ }
351
+ if (events != null) {
352
+ map.putArray("events", RNRadarUtils.arrayForJson(RadarEvent.toJson(events)));
353
+ }
354
+ promise.resolve(map);
355
+ } else {
356
+ promise.reject(status.toString(), status.toString());
357
+ }
358
+ } catch (JSONException e) {
359
+ Log.e(TAG, "JSONException", e);
360
+ promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
361
+ }
340
362
  }
341
363
  });
342
364
  } catch (JSONException e) {
343
365
  Log.e(TAG, "JSONException", e);
366
+ promise.reject(Radar.RadarStatus.ERROR_BAD_REQUEST.toString(), Radar.RadarStatus.ERROR_BAD_REQUEST.toString());
344
367
  }
345
368
  }
346
369
 
347
370
  @ReactMethod
348
- public void completeTrip() {
371
+ public void completeTrip(final Promise promise) {
349
372
  Radar.completeTrip(new Radar.RadarTripCallback() {
350
373
  @Override
351
- public void onComplete(@NonNull Radar.RadarStatus status) {
352
-
374
+ public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
375
+ if (promise == null) {
376
+ return;
377
+ }
378
+ try {
379
+ if (status == Radar.RadarStatus.SUCCESS) {
380
+ WritableMap map = Arguments.createMap();
381
+ map.putString("status", status.toString());
382
+ if (trip != null) {
383
+ map.putMap("trip", RNRadarUtils.mapForJson(trip.toJson()));
384
+ }
385
+ if (events != null) {
386
+ map.putArray("events", RNRadarUtils.arrayForJson(RadarEvent.toJson(events)));
387
+ }
388
+ promise.resolve(map);
389
+ } else {
390
+ promise.reject(status.toString(), status.toString());
391
+ }
392
+ } catch (JSONException e) {
393
+ Log.e(TAG, "JSONException", e);
394
+ promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
395
+ }
353
396
  }
354
397
  });
355
398
  }
356
399
 
357
400
  @ReactMethod
358
- public void cancelTrip() {
401
+ public void cancelTrip(final Promise promise) {
359
402
  Radar.cancelTrip(new Radar.RadarTripCallback() {
360
403
  @Override
361
- public void onComplete(@NonNull Radar.RadarStatus status) {
362
-
404
+ public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
405
+ if (promise == null) {
406
+ return;
407
+ }
408
+ try {
409
+ if (status == Radar.RadarStatus.SUCCESS) {
410
+ WritableMap map = Arguments.createMap();
411
+ map.putString("status", status.toString());
412
+ if (trip != null) {
413
+ map.putMap("trip", RNRadarUtils.mapForJson(trip.toJson()));
414
+ }
415
+ if (events != null) {
416
+ map.putArray("events", RNRadarUtils.arrayForJson(RadarEvent.toJson(events)));
417
+ }
418
+ promise.resolve(map);
419
+ } else {
420
+ promise.reject(status.toString(), status.toString());
421
+ }
422
+ } catch (JSONException e) {
423
+ Log.e(TAG, "JSONException", e);
424
+ promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
425
+ }
363
426
  }
364
427
  });
365
428
  }
366
429
 
430
+ @ReactMethod
431
+ public void updateTrip(ReadableMap optionsMap, final Promise promise) {
432
+
433
+ try {
434
+ JSONObject optionsObj = RNRadarUtils.jsonForMap(optionsMap);
435
+ RadarTripOptions options = RadarTripOptions.fromJson(optionsObj.getJSONObject("options"));
436
+ RadarTrip.RadarTripStatus status = RadarTrip.RadarTripStatus.UNKNOWN;
437
+
438
+ if (optionsObj.has("status")) {
439
+ String statusStr = optionsObj.getString("status");
440
+ if (statusStr != null) {
441
+ if (statusStr.equalsIgnoreCase("started")) {
442
+ status = RadarTrip.RadarTripStatus.STARTED;
443
+ } else if (statusStr.equalsIgnoreCase("approaching")) {
444
+ status = RadarTrip.RadarTripStatus.APPROACHING;
445
+ } else if (statusStr.equalsIgnoreCase("arrived")) {
446
+ status = RadarTrip.RadarTripStatus.ARRIVED;
447
+ } else if (statusStr.equalsIgnoreCase("completed")) {
448
+ status = RadarTrip.RadarTripStatus.COMPLETED;
449
+ } else if (statusStr.equalsIgnoreCase("canceled")) {
450
+ status = RadarTrip.RadarTripStatus.CANCELED;
451
+ } else if (statusStr.equalsIgnoreCase("unknown")) {
452
+ status = RadarTrip.RadarTripStatus.UNKNOWN;
453
+ } else {
454
+ promise.reject(Radar.RadarStatus.ERROR_BAD_REQUEST.toString(), Radar.RadarStatus.ERROR_BAD_REQUEST.toString());
455
+ }
456
+ }
457
+ } else {
458
+ promise.reject(Radar.RadarStatus.ERROR_BAD_REQUEST.toString(), Radar.RadarStatus.ERROR_BAD_REQUEST.toString());
459
+ }
460
+
461
+ Radar.updateTrip(options, status, new Radar.RadarTripCallback() {
462
+ @Override
463
+ public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarTrip trip, @Nullable RadarEvent[] events) {
464
+ if (promise == null) {
465
+ return;
466
+ }
467
+ try {
468
+ if (status == Radar.RadarStatus.SUCCESS) {
469
+ WritableMap map = Arguments.createMap();
470
+ map.putString("status", status.toString());
471
+ if (trip != null) {
472
+ map.putMap("trip", RNRadarUtils.mapForJson(trip.toJson()));
473
+ }
474
+ if (events != null) {
475
+ map.putArray("events", RNRadarUtils.arrayForJson(RadarEvent.toJson(events)));
476
+ }
477
+ promise.resolve(map);
478
+ } else {
479
+ promise.reject(status.toString(), status.toString());
480
+ }
481
+ } catch (JSONException e) {
482
+ Log.e(TAG, "JSONException", e);
483
+ promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
484
+ }
485
+ }
486
+ });
487
+ } catch (JSONException e) {
488
+ Log.e(TAG, "JSONException", e);
489
+ promise.reject(Radar.RadarStatus.ERROR_BAD_REQUEST.toString(), Radar.RadarStatus.ERROR_BAD_REQUEST.toString());
490
+ }
491
+ }
492
+
367
493
  @ReactMethod
368
494
  public void getContext(final Promise promise) {
369
495
  if (promise == null) {
@@ -5,6 +5,7 @@ import android.location.Location;
5
5
  import android.util.Log;
6
6
 
7
7
  import androidx.annotation.NonNull;
8
+ import androidx.annotation.Nullable;
8
9
 
9
10
  import com.facebook.react.ReactApplication;
10
11
  import com.facebook.react.ReactInstanceManager;
@@ -23,49 +24,27 @@ import java.util.concurrent.atomic.AtomicInteger;
23
24
  public class RNRadarReceiver extends RadarReceiver {
24
25
 
25
26
  private ReactNativeHost reactNativeHost;
26
- private PendingResult result;
27
- private AtomicInteger pendingCount = new AtomicInteger(0);
28
27
  private static final String TAG = "RNRadarReceiver";
29
28
 
30
- private void invokeSendEvent(ReactContext reactContext, String eventName, Object data) {
31
- reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data);
32
- }
33
-
34
29
  private void sendEvent(final String eventName, final Object data) {
35
30
  final ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
36
31
  ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
37
- if (reactContext == null) {
38
- if (result == null) {
39
- result = goAsync();
40
- }
41
- pendingCount.incrementAndGet();
42
- reactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
43
- @Override
44
- public void onReactContextInitialized(ReactContext reactContext) {
45
- invokeSendEvent(reactContext, eventName, data);
46
- reactInstanceManager.removeReactInstanceEventListener(this);
47
- if (pendingCount.decrementAndGet() == 0) {
48
- result.finish();
49
- }
50
- }
51
- });
52
- if (!reactInstanceManager.hasStartedCreatingInitialContext()) {
53
- reactInstanceManager.createReactContextInBackground();
54
- }
55
- } else {
56
- invokeSendEvent(reactContext, eventName, data);
32
+ if (reactContext != null) {
33
+ reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data);
57
34
  }
58
35
  }
59
36
 
60
37
  @Override
61
- public void onEventsReceived(@NonNull Context context, @NonNull RadarEvent[] events, @NonNull RadarUser user) {
38
+ public void onEventsReceived(@NonNull Context context, @NonNull RadarEvent[] events, @Nullable RadarUser user) {
62
39
  try {
63
40
  ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
64
41
  reactNativeHost = reactApplication.getReactNativeHost();
65
42
 
66
43
  WritableMap map = Arguments.createMap();
67
44
  map.putArray("events", RNRadarUtils.arrayForJson(RadarEvent.toJson(events)));
68
- map.putMap("user", RNRadarUtils.mapForJson(user.toJson()));
45
+ if (user != null) {
46
+ map.putMap("user", RNRadarUtils.mapForJson(user.toJson()));
47
+ }
69
48
 
70
49
  sendEvent("events", map);
71
50
  } catch (Exception e) {
@@ -1 +1 @@
1
- github "radarlabs/radar-sdk-ios" "3.1.7"
1
+ github "radarlabs/radar-sdk-ios" "3.2.3"
package/ios/RNRadar.m CHANGED
@@ -49,13 +49,14 @@ RCT_EXPORT_MODULE();
49
49
  hasListeners = NO;
50
50
  }
51
51
 
52
- - (void)didReceiveEvents:(NSArray<RadarEvent *> *)events user:(RadarUser *)user {
52
+ - (void)didReceiveEvents:(NSArray<RadarEvent *> *)events user:(RadarUser * _Nullable )user {
53
53
  if (hasListeners) {
54
- [self sendEventWithName:@"events" body:@{
55
- @"events": [RadarEvent arrayForEvents:events],
56
- @"user": [user dictionaryValue]
57
-
58
- }];
54
+ NSMutableDictionary *body = [NSMutableDictionary new];
55
+ [body setValue:[RadarEvent arrayForEvents:events] forKey:@"events"];
56
+ if (user) {
57
+ [body setValue:[user dictionaryValue] forKey:@"user"];
58
+ }
59
+ [self sendEventWithName:@"events" body:body];
59
60
  }
60
61
  }
61
62
 
@@ -73,7 +74,7 @@ RCT_EXPORT_MODULE();
73
74
  [self sendEventWithName:@"clientLocation" body:@{
74
75
  @"location": [Radar dictionaryForLocation:location],
75
76
  @"stopped": @(stopped),
76
- @"source": [Radar stringForSource:source]
77
+ @"source": [Radar stringForLocationSource:source]
77
78
  }];
78
79
  }
79
80
  }
@@ -245,15 +246,15 @@ RCT_EXPORT_METHOD(trackOnce:(NSDictionary *)locationDict resolve:(RCTPromiseReso
245
246
  }
246
247
 
247
248
  RCT_EXPORT_METHOD(startTrackingEfficient) {
248
- [Radar startTrackingWithOptions:RadarTrackingOptions.efficient];
249
+ [Radar startTrackingWithOptions:RadarTrackingOptions.presetEfficient];
249
250
  }
250
251
 
251
252
  RCT_EXPORT_METHOD(startTrackingResponsive) {
252
- [Radar startTrackingWithOptions:RadarTrackingOptions.responsive];
253
+ [Radar startTrackingWithOptions:RadarTrackingOptions.presetResponsive];
253
254
  }
254
255
 
255
256
  RCT_EXPORT_METHOD(startTrackingContinuous) {
256
- [Radar startTrackingWithOptions:RadarTrackingOptions.continuous];
257
+ [Radar startTrackingWithOptions:RadarTrackingOptions.presetContinuous];
257
258
  }
258
259
 
259
260
  RCT_EXPORT_METHOD(startTrackingCustom:(NSDictionary *)optionsDict) {
@@ -313,17 +314,140 @@ RCT_EXPORT_METHOD(rejectEvent:(NSString *)eventId) {
313
314
  [Radar rejectEventId:eventId];
314
315
  }
315
316
 
316
- RCT_EXPORT_METHOD(startTrip:(NSDictionary *)optionsDict) {
317
+ RCT_EXPORT_METHOD(startTrip:(NSDictionary *)optionsDict resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
317
318
  RadarTripOptions *options = [RadarTripOptions tripOptionsFromDictionary:optionsDict];
318
- [Radar startTripWithOptions:options];
319
+
320
+ __block RCTPromiseResolveBlock resolver = resolve;
321
+ __block RCTPromiseRejectBlock rejecter = reject;
322
+
323
+ [Radar startTripWithOptions:options completionHandler:^(RadarStatus status, RadarTrip * _Nullable trip, NSArray<RadarEvent *> * _Nullable events) {
324
+
325
+ if (status == RadarStatusSuccess && resolver) {
326
+ NSMutableDictionary *dict = [NSMutableDictionary new];
327
+ [dict setObject:[Radar stringForStatus:status] forKey:@"status"];
328
+ if (trip) {
329
+ [dict setObject:[trip dictionaryValue] forKey:@"trip"];
330
+ }
331
+ if (events) {
332
+ [dict setObject:[RadarEvent arrayForEvents:events] forKey:@"events"];
333
+ }
334
+ resolver(dict);
335
+ } else if (rejecter) {
336
+ rejecter([Radar stringForStatus:status], [Radar stringForStatus:status], nil);
337
+ }
338
+ resolver = nil;
339
+ rejecter = nil;
340
+ }];
319
341
  }
320
342
 
321
- RCT_EXPORT_METHOD(completeTrip) {
322
- [Radar completeTrip];
343
+ RCT_EXPORT_METHOD(completeTrip:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
344
+
345
+ __block RCTPromiseResolveBlock resolver = resolve;
346
+ __block RCTPromiseRejectBlock rejecter = reject;
347
+
348
+ [Radar completeTripWithCompletionHandler:^(RadarStatus status, RadarTrip * _Nullable trip, NSArray<RadarEvent *> * _Nullable events) {
349
+ if (status == RadarStatusSuccess && resolver) {
350
+ NSMutableDictionary *dict = [NSMutableDictionary new];
351
+ [dict setObject:[Radar stringForStatus:status] forKey:@"status"];
352
+ if (trip) {
353
+ [dict setObject:[trip dictionaryValue] forKey:@"trip"];
354
+ }
355
+ if (events) {
356
+ [dict setObject:[RadarEvent arrayForEvents:events] forKey:@"events"];
357
+ }
358
+ resolver(dict);
359
+ } else if (rejecter) {
360
+ rejecter([Radar stringForStatus:status], [Radar stringForStatus:status], nil);
361
+ }
362
+ resolver = nil;
363
+ rejecter = nil;
364
+ }];
323
365
  }
324
366
 
325
- RCT_EXPORT_METHOD(cancelTrip) {
326
- [Radar cancelTrip];
367
+ RCT_EXPORT_METHOD(cancelTrip:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
368
+ __block RCTPromiseResolveBlock resolver = resolve;
369
+ __block RCTPromiseRejectBlock rejecter = reject;
370
+
371
+ [Radar cancelTripWithCompletionHandler:^(RadarStatus status, RadarTrip * _Nullable trip, NSArray<RadarEvent *> * _Nullable events) {
372
+ if (status == RadarStatusSuccess && resolver) {
373
+ NSMutableDictionary *dict = [NSMutableDictionary new];
374
+ [dict setObject:[Radar stringForStatus:status] forKey:@"status"];
375
+ if (trip) {
376
+ [dict setObject:[trip dictionaryValue] forKey:@"trip"];
377
+ }
378
+ if (events) {
379
+ [dict setObject:[RadarEvent arrayForEvents:events] forKey:@"events"];
380
+ }
381
+ resolver(dict);
382
+ } else if (rejecter) {
383
+ rejecter([Radar stringForStatus:status], [Radar stringForStatus:status], nil);
384
+ }
385
+ resolver = nil;
386
+ rejecter = nil;
387
+ }];
388
+ }
389
+
390
+ RCT_EXPORT_METHOD(updateTrip:(NSDictionary *)optionsDict resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
391
+ if (optionsDict == nil) {
392
+ if (reject) {
393
+ reject([Radar stringForStatus:RadarStatusErrorBadRequest], [Radar stringForStatus:RadarStatusErrorBadRequest], nil);
394
+ }
395
+
396
+ return;
397
+ }
398
+
399
+ RadarTripOptions *options = [RadarTripOptions tripOptionsFromDictionary:optionsDict[@"options"]];
400
+ NSString *statusStr = optionsDict[@"status"];
401
+
402
+ RadarTripStatus status = RadarTripStatusUnknown;
403
+ if (statusStr) {
404
+ if ([statusStr isEqualToString:@"started"]) {
405
+ status = RadarTripStatusStarted;
406
+ } else if ([statusStr isEqualToString:@"approaching"]) {
407
+ status = RadarTripStatusApproaching;
408
+ } else if ([statusStr isEqualToString:@"arrived"]) {
409
+ status = RadarTripStatusArrived;
410
+ } else if ([statusStr isEqualToString:@"completed"]) {
411
+ status = RadarTripStatusCompleted;
412
+ } else if ([statusStr isEqualToString:@"canceled"]) {
413
+ status = RadarTripStatusCanceled;
414
+ } else if ([statusStr isEqualToString:@"unknown"]) {
415
+ status = RadarTripStatusUnknown;
416
+ } else {
417
+ if (reject) {
418
+ reject([Radar stringForStatus:RadarStatusErrorBadRequest], [Radar stringForStatus:RadarStatusErrorBadRequest], nil);
419
+ }
420
+
421
+ return;
422
+ }
423
+ } else {
424
+ if (reject) {
425
+ reject([Radar stringForStatus:RadarStatusErrorBadRequest], [Radar stringForStatus:RadarStatusErrorBadRequest], nil);
426
+ }
427
+
428
+ return;
429
+ }
430
+
431
+ __block RCTPromiseResolveBlock resolver = resolve;
432
+ __block RCTPromiseRejectBlock rejecter = reject;
433
+
434
+ [Radar updateTripWithOptions:options status:status completionHandler:^(RadarStatus status, RadarTrip * _Nullable trip, NSArray<RadarEvent *> * _Nullable events) {
435
+ if (status == RadarStatusSuccess && resolver) {
436
+ NSMutableDictionary *dict = [NSMutableDictionary new];
437
+ [dict setObject:[Radar stringForStatus:status] forKey:@"status"];
438
+ if (trip) {
439
+ [dict setObject:[trip dictionaryValue] forKey:@"trip"];
440
+ }
441
+ if (events) {
442
+ [dict setObject:[RadarEvent arrayForEvents:events] forKey:@"events"];
443
+ }
444
+ resolver(dict);
445
+ } else if (rejecter) {
446
+ rejecter([Radar stringForStatus:status], [Radar stringForStatus:status], nil);
447
+ }
448
+ resolver = nil;
449
+ rejecter = nil;
450
+ }];
327
451
  }
328
452
 
329
453
  RCT_EXPORT_METHOD(getContext:(NSDictionary *)locationDict resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
package/js/index.js CHANGED
@@ -74,6 +74,10 @@ const cancelTrip = () => (
74
74
  NativeModules.RNRadar.cancelTrip()
75
75
  );
76
76
 
77
+ const updateTrip = options => (
78
+ NativeModules.RNRadar.updateTrip(options)
79
+ );
80
+
77
81
  const acceptEvent = (eventId, verifiedPlaceId) => (
78
82
  NativeModules.RNRadar.acceptEvent(eventId, verifiedPlaceId)
79
83
  );
@@ -148,6 +152,7 @@ const Radar = {
148
152
  acceptEvent,
149
153
  rejectEvent,
150
154
  startTrip,
155
+ updateTrip,
151
156
  completeTrip,
152
157
  cancelTrip,
153
158
  getContext,
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "react-native-radar",
3
3
  "description": "React Native module for Radar, the leading geofencing and location tracking platform",
4
- "homepage": "https://radar.io",
4
+ "homepage": "https://radar.com",
5
5
  "license": "Apache-2.0",
6
- "version": "3.1.7",
6
+ "version": "3.2.3",
7
7
  "main": "js/index.js",
8
8
  "files": [
9
9
  "android",
@@ -56,5 +56,8 @@
56
56
  "repository": {
57
57
  "type": "git",
58
58
  "url": "https://github.com/radarlabs/react-native-radar.git"
59
+ },
60
+ "dependencies": {
61
+ "@react-native-community/netinfo": "^7.1.3"
59
62
  }
60
63
  }
@@ -15,5 +15,5 @@ Pod::Spec.new do |s|
15
15
  s.platform = :ios, "10.0"
16
16
 
17
17
  s.dependency "React"
18
- s.dependency "RadarSDK", "3.1.10"
18
+ s.dependency "RadarSDK", "~> 3.2.3"
19
19
  end