@sentiance-react-native/core 6.4.0 → 6.5.0
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/RNSentianceCore.podspec +1 -1
- package/android/src/main/java/com/sentiance/react/bridge/core/SentianceModule.java +35 -37
- package/android/src/main/java/com/sentiance/react/bridge/core/base/AbstractSentianceModule.java +12 -12
- package/ios/RNSentianceCore+Converter.h +2 -0
- package/ios/RNSentianceCore+Converter.m +63 -6
- package/ios/RNSentianceCore.m +16 -0
- package/lib/SentianceEventEmitter.js +1 -0
- package/lib/SentianceEventListenerUtils.js +1 -3
- package/package.json +3 -3
package/RNSentianceCore.podspec
CHANGED
|
@@ -11,7 +11,6 @@ import android.annotation.SuppressLint;
|
|
|
11
11
|
import android.app.Notification;
|
|
12
12
|
import android.os.Handler;
|
|
13
13
|
import android.os.Looper;
|
|
14
|
-
import android.util.Log;
|
|
15
14
|
|
|
16
15
|
import androidx.annotation.NonNull;
|
|
17
16
|
import androidx.annotation.Nullable;
|
|
@@ -24,6 +23,7 @@ import com.facebook.react.bridge.ReadableArray;
|
|
|
24
23
|
import com.facebook.react.bridge.ReadableMap;
|
|
25
24
|
import com.facebook.react.bridge.WritableArray;
|
|
26
25
|
import com.sentiance.react.bridge.core.base.AbstractSentianceModule;
|
|
26
|
+
import com.sentiance.react.bridge.core.common.SentianceSubscriptionsManager;
|
|
27
27
|
import com.sentiance.react.bridge.core.utils.SentianceUtils;
|
|
28
28
|
import com.sentiance.react.bridge.core.utils.UserCreationCompletionHandler;
|
|
29
29
|
import com.sentiance.sdk.InitState;
|
|
@@ -38,14 +38,12 @@ import com.sentiance.sdk.reset.ResetError;
|
|
|
38
38
|
import com.sentiance.sdk.trip.StartTripError;
|
|
39
39
|
import com.sentiance.sdk.trip.StopTripError;
|
|
40
40
|
import com.sentiance.sdk.trip.TransportMode;
|
|
41
|
-
import com.sentiance.sdk.trip.TripTimeoutListener;
|
|
42
41
|
import com.sentiance.sdk.trip.TripType;
|
|
43
42
|
|
|
44
43
|
import java.lang.ref.WeakReference;
|
|
45
44
|
import java.util.ArrayList;
|
|
46
45
|
import java.util.HashMap;
|
|
47
46
|
import java.util.HashSet;
|
|
48
|
-
import java.util.List;
|
|
49
47
|
import java.util.Map;
|
|
50
48
|
import java.util.Set;
|
|
51
49
|
|
|
@@ -57,7 +55,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
57
55
|
private final SentianceEmitter emitter;
|
|
58
56
|
|
|
59
57
|
public SentianceModule(ReactApplicationContext reactContext) {
|
|
60
|
-
super(reactContext);
|
|
58
|
+
super(reactContext, Sentiance.getInstance(reactContext), new SentianceSubscriptionsManager());
|
|
61
59
|
sentianceHelper = SentianceHelper.getInstance(reactContext);
|
|
62
60
|
emitter = new SentianceEmitter(reactContext);
|
|
63
61
|
}
|
|
@@ -153,19 +151,19 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
153
151
|
@ReactMethod
|
|
154
152
|
@SuppressWarnings("unused")
|
|
155
153
|
public void userExists(final Promise promise) {
|
|
156
|
-
promise.resolve(
|
|
154
|
+
promise.resolve(mSdk.userExists());
|
|
157
155
|
}
|
|
158
156
|
|
|
159
157
|
@ReactMethod
|
|
160
158
|
@SuppressWarnings("unused")
|
|
161
159
|
public void isUserLinked(final Promise promise) {
|
|
162
|
-
promise.resolve(
|
|
160
|
+
promise.resolve(mSdk.isUserLinked());
|
|
163
161
|
}
|
|
164
162
|
|
|
165
163
|
@ReactMethod
|
|
166
164
|
@SuppressWarnings("unused")
|
|
167
165
|
public void reset(final Promise promise) {
|
|
168
|
-
|
|
166
|
+
mSdk.reset()
|
|
169
167
|
.addOnCompleteListener(pendingOperation -> {
|
|
170
168
|
if (pendingOperation.isSuccessful()) {
|
|
171
169
|
promise.resolve(SentianceConverter.convertResetResult(pendingOperation.getResult()));
|
|
@@ -179,7 +177,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
179
177
|
@ReactMethod
|
|
180
178
|
@SuppressWarnings("unused")
|
|
181
179
|
public void getInitState(final Promise promise) {
|
|
182
|
-
InitState initState =
|
|
180
|
+
InitState initState = mSdk.getInitState();
|
|
183
181
|
promise.resolve(SentianceConverter.convertInitState(initState));
|
|
184
182
|
}
|
|
185
183
|
|
|
@@ -197,7 +195,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
197
195
|
}
|
|
198
196
|
}
|
|
199
197
|
final TransportMode transportModeHint = SentianceConverter.toTransportMode(hint);
|
|
200
|
-
|
|
198
|
+
mSdk.startTrip(metadataMap, transportModeHint)
|
|
201
199
|
.addOnCompleteListener(pendingOperation -> {
|
|
202
200
|
if (pendingOperation.isSuccessful()) {
|
|
203
201
|
promise.resolve(SentianceConverter.createEmptyResult());
|
|
@@ -215,7 +213,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
215
213
|
if (rejectIfNotInitialized(promise)) {
|
|
216
214
|
return;
|
|
217
215
|
}
|
|
218
|
-
|
|
216
|
+
mSdk.stopTrip()
|
|
219
217
|
.addOnCompleteListener(pendingOperation -> {
|
|
220
218
|
if (pendingOperation.isSuccessful()) {
|
|
221
219
|
promise.resolve(SentianceConverter.createEmptyResult());
|
|
@@ -234,14 +232,14 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
234
232
|
return;
|
|
235
233
|
}
|
|
236
234
|
|
|
237
|
-
SdkStatus sdkStatus =
|
|
235
|
+
SdkStatus sdkStatus = mSdk.getSdkStatus();
|
|
238
236
|
promise.resolve(SentianceConverter.convertSdkStatus(sdkStatus));
|
|
239
237
|
}
|
|
240
238
|
|
|
241
239
|
@ReactMethod
|
|
242
240
|
@SuppressWarnings("unused")
|
|
243
241
|
public void getVersion(final Promise promise) {
|
|
244
|
-
String version =
|
|
242
|
+
String version = mSdk.getVersion();
|
|
245
243
|
promise.resolve(version);
|
|
246
244
|
}
|
|
247
245
|
|
|
@@ -257,7 +255,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
257
255
|
return;
|
|
258
256
|
}
|
|
259
257
|
final TripType type = SentianceConverter.toTripType(typeParam);
|
|
260
|
-
Boolean isTripOngoing =
|
|
258
|
+
Boolean isTripOngoing = mSdk.isTripOngoing(type);
|
|
261
259
|
promise.resolve(isTripOngoing);
|
|
262
260
|
}
|
|
263
261
|
|
|
@@ -268,7 +266,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
268
266
|
return;
|
|
269
267
|
}
|
|
270
268
|
|
|
271
|
-
|
|
269
|
+
mSdk.requestUserAccessToken()
|
|
272
270
|
.addOnCompleteListener(pendingOperation -> {
|
|
273
271
|
if (pendingOperation.isSuccessful()) {
|
|
274
272
|
Token token = pendingOperation.getResult();
|
|
@@ -288,7 +286,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
288
286
|
return;
|
|
289
287
|
}
|
|
290
288
|
|
|
291
|
-
String userId =
|
|
289
|
+
String userId = mSdk.getUserId();
|
|
292
290
|
promise.resolve(userId);
|
|
293
291
|
}
|
|
294
292
|
|
|
@@ -304,7 +302,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
304
302
|
return;
|
|
305
303
|
}
|
|
306
304
|
|
|
307
|
-
|
|
305
|
+
mSdk.addUserMetadataField(label, value);
|
|
308
306
|
promise.resolve(null);
|
|
309
307
|
}
|
|
310
308
|
|
|
@@ -316,7 +314,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
316
314
|
}
|
|
317
315
|
|
|
318
316
|
final Map<String, String> metadata = SentianceConverter.convertReadableMapToMap(inputMetadata);
|
|
319
|
-
boolean result =
|
|
317
|
+
boolean result = mSdk.addTripMetadata(metadata);
|
|
320
318
|
promise.resolve(result);
|
|
321
319
|
}
|
|
322
320
|
|
|
@@ -333,7 +331,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
333
331
|
}
|
|
334
332
|
|
|
335
333
|
final Map<String, String> metadata = SentianceConverter.convertReadableMapToMap(inputMetadata);
|
|
336
|
-
|
|
334
|
+
mSdk.addUserMetadataFields(metadata);
|
|
337
335
|
promise.resolve(null);
|
|
338
336
|
}
|
|
339
337
|
|
|
@@ -349,7 +347,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
349
347
|
return;
|
|
350
348
|
}
|
|
351
349
|
|
|
352
|
-
|
|
350
|
+
mSdk.removeUserMetadataField(label);
|
|
353
351
|
promise.resolve(null);
|
|
354
352
|
}
|
|
355
353
|
|
|
@@ -360,7 +358,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
360
358
|
return;
|
|
361
359
|
}
|
|
362
360
|
|
|
363
|
-
|
|
361
|
+
mSdk.submitDetections()
|
|
364
362
|
.addOnCompleteListener(pendingOperation -> {
|
|
365
363
|
if (pendingOperation.isSuccessful()) {
|
|
366
364
|
promise.resolve(SentianceConverter.createEmptyResult());
|
|
@@ -378,7 +376,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
378
376
|
return;
|
|
379
377
|
}
|
|
380
378
|
|
|
381
|
-
long wifiQuotaLimit =
|
|
379
|
+
long wifiQuotaLimit = mSdk.getWiFiQuotaLimit();
|
|
382
380
|
promise.resolve(Long.toString(wifiQuotaLimit));
|
|
383
381
|
}
|
|
384
382
|
|
|
@@ -389,7 +387,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
389
387
|
return;
|
|
390
388
|
}
|
|
391
389
|
|
|
392
|
-
long wifiQuotaUsage =
|
|
390
|
+
long wifiQuotaUsage = mSdk.getWiFiQuotaUsage();
|
|
393
391
|
promise.resolve(Long.toString(wifiQuotaUsage));
|
|
394
392
|
}
|
|
395
393
|
|
|
@@ -400,7 +398,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
400
398
|
return;
|
|
401
399
|
}
|
|
402
400
|
|
|
403
|
-
long mobileQuotaLimit =
|
|
401
|
+
long mobileQuotaLimit = mSdk.getMobileQuotaLimit();
|
|
404
402
|
promise.resolve(Long.toString(mobileQuotaLimit));
|
|
405
403
|
}
|
|
406
404
|
|
|
@@ -411,7 +409,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
411
409
|
return;
|
|
412
410
|
}
|
|
413
411
|
|
|
414
|
-
long mobileQuotaUsage =
|
|
412
|
+
long mobileQuotaUsage = mSdk.getMobileQuotaUsage();
|
|
415
413
|
promise.resolve(Long.toString(mobileQuotaUsage));
|
|
416
414
|
}
|
|
417
415
|
|
|
@@ -422,7 +420,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
422
420
|
return;
|
|
423
421
|
}
|
|
424
422
|
|
|
425
|
-
long diskQuotaLimit =
|
|
423
|
+
long diskQuotaLimit = mSdk.getDiskQuotaLimit();
|
|
426
424
|
promise.resolve(Long.toString(diskQuotaLimit));
|
|
427
425
|
}
|
|
428
426
|
|
|
@@ -433,7 +431,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
433
431
|
return;
|
|
434
432
|
}
|
|
435
433
|
|
|
436
|
-
long diskQuotaUsage =
|
|
434
|
+
long diskQuotaUsage = mSdk.getDiskQuotaUsage();
|
|
437
435
|
promise.resolve(Long.toString(diskQuotaUsage));
|
|
438
436
|
}
|
|
439
437
|
|
|
@@ -445,7 +443,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
445
443
|
return;
|
|
446
444
|
}
|
|
447
445
|
|
|
448
|
-
|
|
446
|
+
mSdk.disableBatteryOptimization();
|
|
449
447
|
promise.resolve(null);
|
|
450
448
|
}
|
|
451
449
|
|
|
@@ -456,7 +454,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
456
454
|
return;
|
|
457
455
|
}
|
|
458
456
|
|
|
459
|
-
Sentiance.getInstance(
|
|
457
|
+
Sentiance.getInstance(mReactContext).setUserActivityListener(emitter::sendUserActivityUpdate);
|
|
460
458
|
promise.resolve(null);
|
|
461
459
|
}
|
|
462
460
|
|
|
@@ -467,7 +465,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
467
465
|
return;
|
|
468
466
|
}
|
|
469
467
|
|
|
470
|
-
UserActivity activity = Sentiance.getInstance(
|
|
468
|
+
UserActivity activity = Sentiance.getInstance(mReactContext).getUserActivity();
|
|
471
469
|
promise.resolve(SentianceConverter.convertUserActivity(activity));
|
|
472
470
|
}
|
|
473
471
|
|
|
@@ -479,11 +477,11 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
479
477
|
}
|
|
480
478
|
|
|
481
479
|
Notification notification = SentianceUtils.createNotificationFromManifestData(
|
|
482
|
-
new WeakReference<>(
|
|
480
|
+
new WeakReference<>(mReactContext.getApplicationContext()),
|
|
483
481
|
title,
|
|
484
482
|
message);
|
|
485
483
|
if (notification != null) {
|
|
486
|
-
Sentiance.getInstance(
|
|
484
|
+
Sentiance.getInstance(mReactContext)
|
|
487
485
|
.updateSdkNotification(notification);
|
|
488
486
|
}
|
|
489
487
|
|
|
@@ -497,7 +495,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
497
495
|
return;
|
|
498
496
|
}
|
|
499
497
|
|
|
500
|
-
Sentiance.getInstance(
|
|
498
|
+
Sentiance.getInstance(mReactContext).setAppSessionDataCollectionEnabled(enabled);
|
|
501
499
|
promise.resolve(null);
|
|
502
500
|
}
|
|
503
501
|
|
|
@@ -508,7 +506,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
508
506
|
return;
|
|
509
507
|
}
|
|
510
508
|
|
|
511
|
-
promise.resolve(Sentiance.getInstance(
|
|
509
|
+
promise.resolve(Sentiance.getInstance(mReactContext).isAppSessionDataCollectionEnabled());
|
|
512
510
|
}
|
|
513
511
|
|
|
514
512
|
@ReactMethod
|
|
@@ -518,7 +516,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
518
516
|
return;
|
|
519
517
|
}
|
|
520
518
|
|
|
521
|
-
Sentiance.getInstance(
|
|
519
|
+
Sentiance.getInstance(mReactContext).setSdkStatusUpdateListener(sentianceHelper.getOnSdkStatusUpdateListener());
|
|
522
520
|
promise.resolve(null);
|
|
523
521
|
}
|
|
524
522
|
|
|
@@ -529,7 +527,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
529
527
|
return;
|
|
530
528
|
}
|
|
531
529
|
|
|
532
|
-
Sentiance.getInstance(
|
|
530
|
+
Sentiance.getInstance(mReactContext)
|
|
533
531
|
.setTripTimeoutListener(emitter::sendOnTripTimedOutEvent);
|
|
534
532
|
promise.resolve(null);
|
|
535
533
|
}
|
|
@@ -545,7 +543,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
545
543
|
for (Object rawType : rawTypes) {
|
|
546
544
|
dataTypes.add(TransmittableDataType.valueOf((String) rawType));
|
|
547
545
|
}
|
|
548
|
-
|
|
546
|
+
mSdk.setTransmittableDataTypes(dataTypes);
|
|
549
547
|
promise.resolve(null);
|
|
550
548
|
}
|
|
551
549
|
|
|
@@ -556,7 +554,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
556
554
|
}
|
|
557
555
|
|
|
558
556
|
WritableArray args = Arguments.createArray();
|
|
559
|
-
Set<TransmittableDataType> transmittableDataTypes =
|
|
557
|
+
Set<TransmittableDataType> transmittableDataTypes = mSdk.getTransmittableDataTypes();
|
|
560
558
|
for (TransmittableDataType type : transmittableDataTypes) {
|
|
561
559
|
args.pushString(type.name());
|
|
562
560
|
}
|
package/android/src/main/java/com/sentiance/react/bridge/core/base/AbstractSentianceModule.java
CHANGED
|
@@ -7,27 +7,27 @@ import androidx.annotation.NonNull;
|
|
|
7
7
|
import com.facebook.react.bridge.Promise;
|
|
8
8
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
9
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
10
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
11
10
|
import com.sentiance.react.bridge.core.common.SentianceSubscriptionsManager;
|
|
12
11
|
import com.sentiance.sdk.InitState;
|
|
13
12
|
import com.sentiance.sdk.Sentiance;
|
|
14
13
|
|
|
15
14
|
public abstract class AbstractSentianceModule extends ReactContextBaseJavaModule {
|
|
16
15
|
|
|
17
|
-
protected final ReactApplicationContext
|
|
18
|
-
protected final Sentiance
|
|
19
|
-
protected final SentianceSubscriptionsManager
|
|
16
|
+
protected final ReactApplicationContext mReactContext;
|
|
17
|
+
protected final Sentiance mSdk;
|
|
18
|
+
protected final SentianceSubscriptionsManager mSubscriptionsManager;
|
|
20
19
|
|
|
21
|
-
public AbstractSentianceModule(ReactApplicationContext reactApplicationContext
|
|
20
|
+
public AbstractSentianceModule(ReactApplicationContext reactApplicationContext,
|
|
21
|
+
Sentiance sentiance, SentianceSubscriptionsManager subscriptionsManager) {
|
|
22
22
|
super(reactApplicationContext);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
mReactContext = reactApplicationContext;
|
|
24
|
+
mSdk = sentiance;
|
|
25
|
+
mSubscriptionsManager = subscriptionsManager;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
@Override
|
|
29
29
|
public void initialize() {
|
|
30
|
-
addSupportedEventSubscriptions(
|
|
30
|
+
addSupportedEventSubscriptions(mSubscriptionsManager);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
protected boolean rejectIfNotInitialized(Promise promise) {
|
|
@@ -39,7 +39,7 @@ public abstract class AbstractSentianceModule extends ReactContextBaseJavaModule
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
private boolean isSdkInitialized() {
|
|
42
|
-
return
|
|
42
|
+
return mSdk.getInitState() == InitState.INITIALIZED;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
protected void addSupportedEventSubscriptions(SentianceSubscriptionsManager subscriptionsManager) {
|
|
@@ -47,11 +47,11 @@ public abstract class AbstractSentianceModule extends ReactContextBaseJavaModule
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
protected <T> void addSubscription(@NonNull String eventType, int subscriptionId, @NonNull T eventEmitterLogic) {
|
|
50
|
-
|
|
50
|
+
mSubscriptionsManager.addSubscription(eventType, subscriptionId, eventEmitterLogic);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
protected <T> void removeSubscription(int subscriptionId, @NonNull String eventType) {
|
|
54
|
-
|
|
54
|
+
mSubscriptionsManager.removeSubscription(subscriptionId, eventType);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
protected abstract void removeNativeListener(String eventName, int subscriptionId, Promise promise);
|
|
@@ -52,5 +52,7 @@ typedef NS_ENUM(NSInteger, UIBackgroundRefreshStatus);
|
|
|
52
52
|
- (NSDictionary *)convertDrivingInsights:(SENTDrivingInsights *)drivingInsights;
|
|
53
53
|
- (NSArray *)convertHarshDrivingEvents:(NSArray<SENTHarshDrivingEvent*> *)harshDrivingEvents;
|
|
54
54
|
- (NSArray *)convertPhoneUsageEvents:(NSArray<SENTPhoneUsageEvent*> *)phoneUsageEvents;
|
|
55
|
+
- (NSArray *)convertCallWhileMovingEvents:(NSArray<SENTCallWhileMovingEvent*> *)callWhileMovingEvents;
|
|
56
|
+
- (NSArray *)convertSpeedingEvents:(NSArray<SENTSpeedingEvent*> *)speedingEvents;
|
|
55
57
|
|
|
56
58
|
@end
|
|
@@ -223,12 +223,21 @@
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
- (NSDictionary*)convertWaypoint:(SENTWaypoint*)waypoint {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
226
|
+
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
|
227
|
+
dict[@"latitude"] = @(waypoint.latitude);
|
|
228
|
+
dict[@"longitude"] = @(waypoint.longitude);
|
|
229
|
+
dict[@"accuracy"] = @(waypoint.accuracyInMeters);
|
|
230
|
+
dict[@"timestamp"] = @(waypoint.timestamp * 1000);
|
|
231
|
+
|
|
232
|
+
if (waypoint.isSpeedSet) {
|
|
233
|
+
dict[@"speedInMps"] = @(waypoint.speedInMps);
|
|
234
|
+
}
|
|
235
|
+
if (waypoint.isSpeedLimitSet) {
|
|
236
|
+
dict[@"speedLimitInMps"] = @(waypoint.speedLimitInMps);
|
|
237
|
+
}
|
|
238
|
+
dict[@"hasUnlimitedSpeedLimit"] = @(waypoint.isSpeedLimitUnlimited);
|
|
239
|
+
|
|
240
|
+
return dict;
|
|
232
241
|
}
|
|
233
242
|
|
|
234
243
|
- (NSArray<NSDictionary *> *)convertWaypointArray:(NSArray<SENTWaypoint *> *)waypoints {
|
|
@@ -1140,6 +1149,21 @@
|
|
|
1140
1149
|
safetyScoresDict[@"focusScore"] = focusScore;
|
|
1141
1150
|
}
|
|
1142
1151
|
|
|
1152
|
+
NSNumber* callWhileMovingScore = drivingInsights.safetyScores.callWhileMovingScore;
|
|
1153
|
+
if (callWhileMovingScore != nil) {
|
|
1154
|
+
safetyScoresDict[@"callWhileMovingScore"] = callWhileMovingScore;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
NSNumber* legalScore = drivingInsights.safetyScores.legalScore;
|
|
1158
|
+
if (legalScore != nil) {
|
|
1159
|
+
safetyScoresDict[@"legalScore"] = legalScore;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
NSNumber* overallScore = drivingInsights.safetyScores.overallScore;
|
|
1163
|
+
if (overallScore != nil) {
|
|
1164
|
+
safetyScoresDict[@"overallScore"] = overallScore;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1143
1167
|
dict[@"safetyScores"] = safetyScoresDict;
|
|
1144
1168
|
|
|
1145
1169
|
return dict;
|
|
@@ -1171,6 +1195,39 @@
|
|
|
1171
1195
|
return [self convertDrivingEvent:phoneUsageEvent];
|
|
1172
1196
|
}
|
|
1173
1197
|
|
|
1198
|
+
- (NSArray<NSDictionary<NSString *, NSNumber *> *> *)convertCallWhileMovingEvents:(NSArray<SENTCallWhileMovingEvent*> *)callWhileMovingEvents {
|
|
1199
|
+
NSMutableArray <NSDictionary<NSString *, NSNumber *> *> *array = [[NSMutableArray alloc] init];
|
|
1200
|
+
for (SENTCallWhileMovingEvent *event in callWhileMovingEvents) {
|
|
1201
|
+
[array addObject:[self convertCallWhileMovingEvent:event]];
|
|
1202
|
+
}
|
|
1203
|
+
return array;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
- (NSDictionary<NSString *, NSNumber *> *)convertCallWhileMovingEvent:(SENTCallWhileMovingEvent *)callWhileMovingEvent {
|
|
1207
|
+
NSMutableDictionary<NSString *, NSNumber *> *dict = [self convertDrivingEvent:callWhileMovingEvent];
|
|
1208
|
+
if (callWhileMovingEvent.minTraveledSpeedInMps != nil) {
|
|
1209
|
+
dict[@"minTravelledSpeedInMps"] = callWhileMovingEvent.minTraveledSpeedInMps;
|
|
1210
|
+
}
|
|
1211
|
+
if (callWhileMovingEvent.maxTraveledSpeedInMps != nil) {
|
|
1212
|
+
dict[@"maxTravelledSpeedInMps"] = callWhileMovingEvent.maxTraveledSpeedInMps;
|
|
1213
|
+
}
|
|
1214
|
+
return dict;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
- (NSArray<NSDictionary<NSString *, NSNumber *> *> *)convertSpeedingEvents:(NSArray<SENTSpeedingEvent*> *)speedingEvents {
|
|
1218
|
+
NSMutableArray <NSDictionary<NSString *, NSNumber *> *> *array = [[NSMutableArray alloc] init];
|
|
1219
|
+
for (SENTSpeedingEvent *event in speedingEvents) {
|
|
1220
|
+
[array addObject:[self convertSpeedingEvent:event]];
|
|
1221
|
+
}
|
|
1222
|
+
return array;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
- (NSDictionary<NSString *, NSNumber *> *)convertSpeedingEvent:(SENTSpeedingEvent *)speedingEvent {
|
|
1226
|
+
NSMutableDictionary<NSString *, NSNumber *> *dict = [self convertDrivingEvent:speedingEvent];
|
|
1227
|
+
dict[@"waypoints"] = [self convertWaypointArray:speedingEvent.waypoints];
|
|
1228
|
+
return dict;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1174
1231
|
- (NSMutableDictionary<NSString *, NSNumber *> *)convertDrivingEvent:(SENTDrivingEvent *)drivingEvent {
|
|
1175
1232
|
NSMutableDictionary<NSString *, NSNumber *> *dict = [[NSMutableDictionary alloc] init];
|
|
1176
1233
|
dict[@"startTime"] = [drivingEvent.startDate description];
|
package/ios/RNSentianceCore.m
CHANGED
|
@@ -1062,6 +1062,22 @@ RCT_EXPORT_METHOD(getPhoneUsageEvents:(NSString*)transportId resolver:(RCTPromis
|
|
|
1062
1062
|
resolve([self convertPhoneUsageEvents:phoneUsageEvents]);
|
|
1063
1063
|
}
|
|
1064
1064
|
|
|
1065
|
+
RCT_EXPORT_METHOD(getCallWhileMovingEvents:(NSString*)transportId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
1066
|
+
{
|
|
1067
|
+
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
1068
|
+
|
|
1069
|
+
NSArray<SENTCallWhileMovingEvent *> *callWhileMovingEvents = [[Sentiance sharedInstance] getCallsWhileMovingEventsForTransportId:transportId];
|
|
1070
|
+
resolve([self convertCallWhileMovingEvents:callWhileMovingEvents]);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
RCT_EXPORT_METHOD(getSpeedingEvents:(NSString*)transportId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
1074
|
+
{
|
|
1075
|
+
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
1076
|
+
|
|
1077
|
+
NSArray<SENTSpeedingEvent *> *speedingEvents = [[Sentiance sharedInstance] getSpeedingEventsForTransportId:transportId];
|
|
1078
|
+
resolve([self convertSpeedingEvents:speedingEvents]);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1065
1081
|
RCT_EXPORT_METHOD(addNativeListener:(NSString *)eventName subscriptionId:(NSInteger)subscriptionId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
1066
1082
|
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
1067
1083
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.createEventListener = async (eventName: String, emitter: SentianceEventEmitter, callback: Function) => {
|
|
1
|
+
exports.createEventListener = async (eventName, emitter, callback) => {
|
|
4
2
|
const listener = (data) => {
|
|
5
3
|
callback(data);
|
|
6
4
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentiance-react-native/core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"description": "React Native Sentiance core library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"targetSdk": 31,
|
|
30
30
|
"compileSdk": 31,
|
|
31
31
|
"buildTools": "30.0.3",
|
|
32
|
-
"sentiance": "6.
|
|
32
|
+
"sentiance": "6.5.+"
|
|
33
33
|
},
|
|
34
34
|
"ios": {
|
|
35
|
-
"sentiance": "~> 6.
|
|
35
|
+
"sentiance": "~> 6.5.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|