@sentiance-react-native/core 6.0.2 → 6.1.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/android/src/main/java/com/sentiance/react/bridge/core/SentianceModule.java +37 -0
- package/ios/RNSentianceCore+Converter.h +3 -0
- package/ios/RNSentianceCore+Converter.m +75 -11
- package/ios/RNSentianceCore.h +3 -0
- package/ios/RNSentianceCore.m +41 -3
- package/lib/index.d.ts +55 -27
- package/lib/index.js +28 -4
- package/package.json +3 -3
|
@@ -16,10 +16,13 @@ import android.util.Log;
|
|
|
16
16
|
import androidx.annotation.NonNull;
|
|
17
17
|
import androidx.annotation.Nullable;
|
|
18
18
|
|
|
19
|
+
import com.facebook.react.bridge.Arguments;
|
|
19
20
|
import com.facebook.react.bridge.Promise;
|
|
20
21
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
21
22
|
import com.facebook.react.bridge.ReactMethod;
|
|
23
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
22
24
|
import com.facebook.react.bridge.ReadableMap;
|
|
25
|
+
import com.facebook.react.bridge.WritableArray;
|
|
23
26
|
import com.sentiance.react.bridge.core.base.AbstractSentianceModule;
|
|
24
27
|
import com.sentiance.react.bridge.core.utils.SentianceUtils;
|
|
25
28
|
import com.sentiance.react.bridge.core.utils.UserCreationCompletionHandler;
|
|
@@ -28,6 +31,7 @@ import com.sentiance.sdk.SdkStatus;
|
|
|
28
31
|
import com.sentiance.sdk.Sentiance;
|
|
29
32
|
import com.sentiance.sdk.SubmitDetectionsError;
|
|
30
33
|
import com.sentiance.sdk.Token;
|
|
34
|
+
import com.sentiance.sdk.TransmittableDataType;
|
|
31
35
|
import com.sentiance.sdk.UserAccessTokenError;
|
|
32
36
|
import com.sentiance.sdk.detectionupdates.UserActivity;
|
|
33
37
|
import com.sentiance.sdk.reset.ResetError;
|
|
@@ -38,8 +42,12 @@ import com.sentiance.sdk.trip.TripTimeoutListener;
|
|
|
38
42
|
import com.sentiance.sdk.trip.TripType;
|
|
39
43
|
|
|
40
44
|
import java.lang.ref.WeakReference;
|
|
45
|
+
import java.util.ArrayList;
|
|
41
46
|
import java.util.HashMap;
|
|
47
|
+
import java.util.HashSet;
|
|
48
|
+
import java.util.List;
|
|
42
49
|
import java.util.Map;
|
|
50
|
+
import java.util.Set;
|
|
43
51
|
|
|
44
52
|
public class SentianceModule extends AbstractSentianceModule {
|
|
45
53
|
|
|
@@ -526,6 +534,35 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
526
534
|
promise.resolve(null);
|
|
527
535
|
}
|
|
528
536
|
|
|
537
|
+
@ReactMethod
|
|
538
|
+
public void setTransmittableDataTypes(ReadableArray types, Promise promise) {
|
|
539
|
+
if (rejectIfNotInitialized(promise)) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
ArrayList<Object> rawTypes = types.toArrayList();
|
|
544
|
+
Set<TransmittableDataType> dataTypes = new HashSet<>();
|
|
545
|
+
for (Object rawType : rawTypes) {
|
|
546
|
+
dataTypes.add(TransmittableDataType.valueOf((String) rawType));
|
|
547
|
+
}
|
|
548
|
+
sdk.setTransmittableDataTypes(dataTypes);
|
|
549
|
+
promise.resolve(null);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
@ReactMethod
|
|
553
|
+
public void getTransmittableDataTypes(Promise promise) {
|
|
554
|
+
if (rejectIfNotInitialized(promise)) {
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
WritableArray args = Arguments.createArray();
|
|
559
|
+
Set<TransmittableDataType> transmittableDataTypes = sdk.getTransmittableDataTypes();
|
|
560
|
+
for (TransmittableDataType type : transmittableDataTypes) {
|
|
561
|
+
args.pushString(type.name());
|
|
562
|
+
}
|
|
563
|
+
promise.resolve(args);
|
|
564
|
+
}
|
|
565
|
+
|
|
529
566
|
@ReactMethod
|
|
530
567
|
public void addListener(String eventName) {
|
|
531
568
|
// Set up any upstream listeners or background tasks as necessary
|
|
@@ -28,6 +28,7 @@ typedef NS_ENUM(NSInteger, UIBackgroundRefreshStatus);
|
|
|
28
28
|
- (NSString*)convertUserActivityTypeToString:(SENTUserActivityType) activityType;
|
|
29
29
|
- (NSString*)convertTripTypeToString:(SENTTripType) tripType;
|
|
30
30
|
- (NSDictionary*)convertVehicleCrashEventToDict:(SENTVehicleCrashEvent*) crashEvent;
|
|
31
|
+
- (NSDictionary*)convertVehicleCrashDiagnosticToDict:(SENTVehicleCrashDiagnostic*) crashDiagnostic;
|
|
31
32
|
- (NSDictionary *)convertUserLinkingResult:(SENTUserLinkingResult *)userLinkingResult;
|
|
32
33
|
- (NSString *)stringifyUserLinkingError:(SENTUserLinkingError *)userLinkingError;
|
|
33
34
|
- (NSDictionary *)convertResetResult:(SENTResetResult *)resetResult;
|
|
@@ -46,5 +47,7 @@ typedef NS_ENUM(NSInteger, UIBackgroundRefreshStatus);
|
|
|
46
47
|
- (NSString *)stringifyDisableDetectionsError:(SENTDisableDetectionsError *)disableDetectionsError;
|
|
47
48
|
- (NSString *)stringifyUserContextError:(SENTRequestUserContextError *)userContextError;
|
|
48
49
|
- (NSString*)convertBackgroundRefreshStatus:(UIBackgroundRefreshStatus)backgroundRefreshStatus;
|
|
50
|
+
- (NSSet<NSString*> *)convertIntegerTransmittableDataTypes:(NSArray<NSNumber*>*)intDataTypes;
|
|
51
|
+
- (NSSet<NSNumber*> *)convertStringTransmittableDataTypes:(NSArray<NSString*>*)stringDataTypes;
|
|
49
52
|
|
|
50
53
|
@end
|
|
@@ -128,16 +128,22 @@
|
|
|
128
128
|
|
|
129
129
|
- (NSString*)convertTransportModeToString:(SENTTimelineTransportMode)mode {
|
|
130
130
|
switch (mode) {
|
|
131
|
+
case SENTTimelineTransportModeBicycle:
|
|
132
|
+
return @"BYCICLE";
|
|
131
133
|
case SENTTimelineTransportModeWalking:
|
|
132
134
|
return @"WALKING";
|
|
133
135
|
case SENTTimelineTransportModeRunning:
|
|
134
136
|
return @"RUNNING";
|
|
135
|
-
case
|
|
136
|
-
return @"
|
|
137
|
-
case
|
|
138
|
-
return @"
|
|
139
|
-
case
|
|
140
|
-
return @"
|
|
137
|
+
case SENTTimelineTransportModeTram:
|
|
138
|
+
return @"TRAM";
|
|
139
|
+
case SENTTimelineTransportModeTrain:
|
|
140
|
+
return @"TRAIN";
|
|
141
|
+
case SENTTimelineTransportModeCar:
|
|
142
|
+
return @"CAR";
|
|
143
|
+
case SENTTimelineTransportModeBus:
|
|
144
|
+
return @"BUS";
|
|
145
|
+
case SENTTimelineTransportModeMotorcycle:
|
|
146
|
+
return @"MOTORCYCLE";
|
|
141
147
|
case SENTTimelineTransportModeUnknown:
|
|
142
148
|
default:
|
|
143
149
|
return @"UNKNOWN";
|
|
@@ -684,6 +690,34 @@
|
|
|
684
690
|
return [dict copy];
|
|
685
691
|
}
|
|
686
692
|
|
|
693
|
+
- (NSString *)_vehicleCrashDiagnosticStateName:(SENTVehicleCrashDetectionState)crashDetectionState {
|
|
694
|
+
switch (crashDetectionState) {
|
|
695
|
+
case 0:
|
|
696
|
+
return @"CANDIDATE_DETECTED";
|
|
697
|
+
case 1:
|
|
698
|
+
return @"CANDIDATE_DISCARDED_WEAK_IMPACT";
|
|
699
|
+
case 2:
|
|
700
|
+
return @"CANDIDATE_DISCARDED_NON_VEHICLE_TRANSPORT_MODE";
|
|
701
|
+
case 3:
|
|
702
|
+
return @"CANDIDATE_DISCARDED_PRE_IMPACT_NOISE";
|
|
703
|
+
case 4:
|
|
704
|
+
return @"CANDIDATE_DISCARDED_LOW_SPEED_BEFORE_IMPACT";
|
|
705
|
+
case 5:
|
|
706
|
+
return @"CANDIDATE_DISCARDED_POST_IMPACT_NOISE";
|
|
707
|
+
case 6:
|
|
708
|
+
return @"CANDIDATE_DISCARDED_HIGH_SPEED_AFTER_IMPACT";
|
|
709
|
+
default:
|
|
710
|
+
return @"CANDIDATE_NOT_DETECTED";
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
- (NSDictionary*)convertVehicleCrashDiagnosticToDict:(SENTVehicleCrashDiagnostic*) crashDiagnostic {
|
|
715
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
716
|
+
dict[@"crashDetectionState"] = [self _vehicleCrashDiagnosticStateName: crashDiagnostic.crashDetectionState];
|
|
717
|
+
dict[@"crashDetectionStateDescription"] = crashDiagnostic.crashDetectionStateDescription;
|
|
718
|
+
return [dict copy];
|
|
719
|
+
}
|
|
720
|
+
|
|
687
721
|
- (NSDictionary *)convertUserCreationResult:(SENTUserCreationResult *)userCreationResult {
|
|
688
722
|
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
|
|
689
723
|
|
|
@@ -757,10 +791,10 @@
|
|
|
757
791
|
|
|
758
792
|
- (NSDictionary *)convertUserLinkingResult:(SENTUserLinkingResult *)userLinkingResult {
|
|
759
793
|
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
|
|
760
|
-
|
|
794
|
+
|
|
761
795
|
userInfo[@"userId"] = userLinkingResult.userInfo.userId;
|
|
762
796
|
userInfo[@"tokenId"] = userLinkingResult.userInfo.token.tokenId;
|
|
763
|
-
|
|
797
|
+
|
|
764
798
|
NSString *tokenExpiryDate = [[SENTDate alloc]initWithNSDate: userLinkingResult.userInfo.token.expiryDate].description;
|
|
765
799
|
userInfo[@"tokenExpiryDate"] = tokenExpiryDate;
|
|
766
800
|
userInfo[@"isTokenExpired"] = @(userLinkingResult.userInfo.token.isExpired);
|
|
@@ -880,10 +914,10 @@
|
|
|
880
914
|
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
881
915
|
|
|
882
916
|
dict[@"tokenId"] = userAccessTokenResult.token.tokenId;
|
|
883
|
-
|
|
917
|
+
|
|
884
918
|
NSString *tokenExpiryDate = [[SENTDate alloc]initWithNSDate: userAccessTokenResult.token.expiryDate].description;
|
|
885
919
|
dict[@"expiryDate"] = tokenExpiryDate;
|
|
886
|
-
|
|
920
|
+
|
|
887
921
|
return dict;
|
|
888
922
|
}
|
|
889
923
|
|
|
@@ -981,7 +1015,7 @@
|
|
|
981
1015
|
- (NSString *)stringifyUserContextError:(SENTRequestUserContextError *)userContextError {
|
|
982
1016
|
NSString *reason;
|
|
983
1017
|
NSString *details;
|
|
984
|
-
|
|
1018
|
+
|
|
985
1019
|
switch (userContextError.failureReason) {
|
|
986
1020
|
case SENTRequestUserContextFailureReasonNoUser:
|
|
987
1021
|
reason = @"NO_USER";
|
|
@@ -1010,4 +1044,34 @@
|
|
|
1010
1044
|
return @"";
|
|
1011
1045
|
}
|
|
1012
1046
|
|
|
1047
|
+
- (NSSet<NSString*> *)convertIntegerTransmittableDataTypes:(NSArray<NSNumber*>*)intDataTypes {
|
|
1048
|
+
NSMutableSet *typesSet = [[NSMutableSet alloc] init];
|
|
1049
|
+
NSDictionary *dict = @{
|
|
1050
|
+
@(SENTTransmittableDataTypeAll): @"ALL",
|
|
1051
|
+
@(SENTTransmittableDataTypeSdkInfo): @"SDK_INFO",
|
|
1052
|
+
@(SENTTransmittableDataTypeVehicleCrashInfo): @"VEHICLE_CRASH_INFO",
|
|
1053
|
+
@(SENTTransmittableDataTypeGeneralDetections): @"GENERAL_DETECTIONS"
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
for(NSNumber* intDataType in intDataTypes) {
|
|
1057
|
+
[typesSet addObject:dict[intDataType]];
|
|
1058
|
+
}
|
|
1059
|
+
return [typesSet copy];
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
- (NSSet<NSNumber*> *)convertStringTransmittableDataTypes:(NSArray<NSString*>*)stringDataTypes {
|
|
1063
|
+
NSMutableSet *typesSet = [[NSMutableSet alloc] init];
|
|
1064
|
+
NSDictionary *dict = @{
|
|
1065
|
+
@"ALL": @(SENTTransmittableDataTypeAll),
|
|
1066
|
+
@"SDK_INFO": @(SENTTransmittableDataTypeSdkInfo),
|
|
1067
|
+
@"VEHICLE_CRASH_INFO": @(SENTTransmittableDataTypeVehicleCrashInfo),
|
|
1068
|
+
@"GENERAL_DETECTIONS": @(SENTTransmittableDataTypeGeneralDetections)
|
|
1069
|
+
};
|
|
1070
|
+
|
|
1071
|
+
for(NSString * strType in stringDataTypes) {
|
|
1072
|
+
[typesSet addObject:dict[strType]];
|
|
1073
|
+
}
|
|
1074
|
+
return [typesSet copy];
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1013
1077
|
@end
|
package/ios/RNSentianceCore.h
CHANGED
|
@@ -9,6 +9,7 @@ static NSString * _Nonnull const UserActivityUpdateEvent = @"SENTIANCE_USER_ACTI
|
|
|
9
9
|
static NSString * _Nonnull const ON_DETECTIONS_ENABLED = @"SENTIANCE_ON_DETECTIONS_ENABLED_EVENT";
|
|
10
10
|
static NSString * _Nonnull const TripTimeoutEvent = @"SENTIANCE_ON_TRIP_TIMED_OUT_EVENT";
|
|
11
11
|
static NSString * _Nonnull const VehicleCrashEvent = @"SENTIANCE_VEHICLE_CRASH_EVENT";
|
|
12
|
+
static NSString * _Nonnull const VehicleCrashDiagnosticEvent = @"SENTIANCE_VEHICLE_CRASH_DIAGNOSTIC_EVENT";
|
|
12
13
|
static NSString * _Nonnull const UserContextUpdateEvent = @"SENTIANCE_USER_CONTEXT_UPDATE_EVENT";
|
|
13
14
|
|
|
14
15
|
@interface RNSentianceCore : RCTEventEmitter <RCTBridgeModule, SENTUserContextDelegate>
|
|
@@ -25,5 +26,7 @@ typedef void (^SdkStatusHandler)(SENTSDKStatus * _Nonnull status);
|
|
|
25
26
|
- (BOOL) isNativeInitializationEnabled;
|
|
26
27
|
- (void) disableSDKNativeInitialization: (RCTPromiseResolveBlock _Nullable)resolve rejecter:(RCTPromiseRejectBlock _Nullable)reject;
|
|
27
28
|
- (void) enableSDKNativeInitialization: (RCTPromiseResolveBlock _Nullable)resolve rejecter:(RCTPromiseRejectBlock _Nullable)reject;
|
|
29
|
+
- (void) setTransmittableDataTypes: (NSArray *)types;
|
|
30
|
+
- (NSArray*) getTransmittableDataTypes:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
|
|
28
31
|
|
|
29
32
|
@end
|
package/ios/RNSentianceCore.m
CHANGED
|
@@ -33,7 +33,7 @@ RCT_EXPORT_MODULE(SentianceCore)
|
|
|
33
33
|
|
|
34
34
|
- (NSArray<NSString *> *)supportedEvents
|
|
35
35
|
{
|
|
36
|
-
return @[SdkStatusUpdateEvent, TripTimeoutEvent, UserLinkEvent, UserActivityUpdateEvent, VehicleCrashEvent, UserLinkEvent, UserContextUpdateEvent];
|
|
36
|
+
return @[SdkStatusUpdateEvent, TripTimeoutEvent, UserLinkEvent, UserActivityUpdateEvent, VehicleCrashEvent, VehicleCrashDiagnosticEvent, UserLinkEvent, UserContextUpdateEvent];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// Will be called when this module's first listener is added.
|
|
@@ -566,7 +566,7 @@ RCT_EXPORT_METHOD(submitDetections:(RCTPromiseResolveBlock)resolve rejecter:(RCT
|
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
|
|
569
|
-
RCT_EXPORT_METHOD(
|
|
569
|
+
RCT_EXPORT_METHOD(submitDetectionsNewAPI:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
570
570
|
{
|
|
571
571
|
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
572
572
|
|
|
@@ -760,6 +760,25 @@ RCT_EXPORT_METHOD(listenVehicleCrashEvents:(RCTPromiseResolveBlock)resolve rejec
|
|
|
760
760
|
}
|
|
761
761
|
}
|
|
762
762
|
|
|
763
|
+
RCT_EXPORT_METHOD(listenVehicleCrashDiagnostic:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
764
|
+
{
|
|
765
|
+
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
766
|
+
|
|
767
|
+
@try {
|
|
768
|
+
__weak typeof(self) weakSelf = self;
|
|
769
|
+
|
|
770
|
+
[[Sentiance sharedInstance] setVehicleCrashDiagnosticHandler:^(SENTVehicleCrashDiagnostic *crashDiagnostic) {
|
|
771
|
+
if(weakSelf.hasListeners) {
|
|
772
|
+
NSDictionary *crashDiagnosticEventDict = [self convertVehicleCrashDiagnosticToDict:crashDiagnostic];
|
|
773
|
+
[weakSelf sendEventWithName:VehicleCrashDiagnosticEvent body:crashDiagnosticEventDict];
|
|
774
|
+
}
|
|
775
|
+
}];
|
|
776
|
+
resolve(@(YES));
|
|
777
|
+
} @catch (NSException *e) {
|
|
778
|
+
reject(e.name, e.reason, nil);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
763
782
|
RCT_EXPORT_METHOD(invokeDummyVehicleCrash:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
764
783
|
{
|
|
765
784
|
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
@@ -940,7 +959,7 @@ RCT_EXPORT_METHOD(reset:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseReje
|
|
|
940
959
|
}];
|
|
941
960
|
}
|
|
942
961
|
|
|
943
|
-
RCT_EXPORT_METHOD(
|
|
962
|
+
RCT_EXPORT_METHOD(resetNewAPI:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
944
963
|
{
|
|
945
964
|
[[Sentiance sharedInstance] resetWithCompletionHandler:^(SENTResetResult * _Nullable result, SENTResetError * _Nullable error) {
|
|
946
965
|
if (error != nil) {
|
|
@@ -972,6 +991,25 @@ RCT_EXPORT_METHOD(listenTripTimeout:(RCTPromiseResolveBlock)resolve rejecter:(RC
|
|
|
972
991
|
resolve(nil);
|
|
973
992
|
}
|
|
974
993
|
|
|
994
|
+
RCT_EXPORT_METHOD(setTransmittableDataTypes:(NSArray *)types (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
995
|
+
{
|
|
996
|
+
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
997
|
+
|
|
998
|
+
NSSet *typesSet = [NSSet setWithArray:types];
|
|
999
|
+
NSSet *convertedTypes = [self convertStringTransmittableDataTypes:types];
|
|
1000
|
+
[[Sentiance sharedInstance] setTransmittableDataTypes:convertedTypes];
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
RCT_EXPORT_METHOD(getTransmittableDataTypes:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
1004
|
+
{
|
|
1005
|
+
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
1006
|
+
|
|
1007
|
+
NSSet *types = [[Sentiance sharedInstance] transmittableDataTypes];
|
|
1008
|
+
NSSet *convertedTypes = [self convertIntegerTransmittableDataTypes:types];
|
|
1009
|
+
NSArray *array = [convertedTypes allObjects];
|
|
1010
|
+
resolve(array);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
975
1013
|
- (void)didUpdateUserContext:(SENTUserContext *)userContext
|
|
976
1014
|
forCriteriaMask:(SENTUserContextUpdateCriteria)criteriaMask {
|
|
977
1015
|
NSDictionary *dict = @{
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
declare module "sentiance-react-native
|
|
2
|
-
import {EmitterSubscription} from "react-native";
|
|
3
|
-
|
|
4
|
-
export type DetectionStatus =
|
|
1
|
+
declare module "@sentiance-react-native/core" {
|
|
2
|
+
import { EmitterSubscription } from "react-native";
|
|
3
|
+
|
|
4
|
+
export type DetectionStatus =
|
|
5
|
+
| "DISABLED"
|
|
6
|
+
| "EXPIRED"
|
|
7
|
+
| "ENABLED_BUT_BLOCKED"
|
|
8
|
+
| "ENABLED_AND_DETECTING";
|
|
5
9
|
export type LocationPermission = "ALWAYS" | "ONLY_WHILE_IN_USE" | "NEVER";
|
|
6
10
|
export type BackgroundRefreshStatus = "AVAILABLE" | "DENIED" | "RESTRICTED";
|
|
7
11
|
export type SdkInitState =
|
|
@@ -11,6 +15,7 @@ declare module "sentiance-react-native-core" {
|
|
|
11
15
|
| "RESETTING"
|
|
12
16
|
| "UNRECOGNIZED_STATE";
|
|
13
17
|
export type TripType = "TRIP_TYPE_SDK" | "TRIP_TYPE_EXTERNAL";
|
|
18
|
+
export type TransmittableDataType = "ALL" | "SDK_INFO" | "VEHICLE_CRASH_INFO" | "GENERAL_DETECTIONS";
|
|
14
19
|
|
|
15
20
|
export enum TransportMode {
|
|
16
21
|
UNKNOWN = 1,
|
|
@@ -27,26 +32,26 @@ declare module "sentiance-react-native-core" {
|
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
export interface UserInfo {
|
|
30
|
-
userId: string
|
|
31
|
-
tokenId: string
|
|
32
|
-
tokenExpiryDate: string
|
|
33
|
-
isTokenExpired: boolean
|
|
35
|
+
userId: string;
|
|
36
|
+
tokenId: string;
|
|
37
|
+
tokenExpiryDate: string;
|
|
38
|
+
isTokenExpired: boolean;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
export interface UserLinkingResult {
|
|
37
|
-
userInfo: UserInfo
|
|
42
|
+
userInfo: UserInfo;
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
export interface CreateUserResult {
|
|
41
|
-
userInfo: UserInfo
|
|
46
|
+
userInfo: UserInfo;
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
export interface UserCreationOptions {
|
|
45
|
-
appId: string
|
|
46
|
-
appSecret: string
|
|
47
|
-
authCode: string
|
|
48
|
-
platformUrl: string
|
|
49
|
-
linker: (installId: string) => boolean
|
|
50
|
+
appId: string;
|
|
51
|
+
appSecret: string;
|
|
52
|
+
authCode: string;
|
|
53
|
+
platformUrl: string;
|
|
54
|
+
linker: (installId: string) => boolean;
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
export interface Location {
|
|
@@ -62,11 +67,19 @@ declare module "sentiance-react-native-core" {
|
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
export interface TripInfo {
|
|
65
|
-
type:
|
|
70
|
+
type:
|
|
71
|
+
| "TRIP_TYPE_SDK"
|
|
72
|
+
| "TRIP_TYPE_EXTERNAL"
|
|
73
|
+
| "TRIP_TYPE_UNRECOGNIZED"
|
|
74
|
+
| "ANY";
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
export interface UserActivity {
|
|
69
|
-
type:
|
|
78
|
+
type:
|
|
79
|
+
| "USER_ACTIVITY_TYPE_TRIP"
|
|
80
|
+
| "USER_ACTIVITY_TYPE_STATIONARY"
|
|
81
|
+
| "USER_ACTIVITY_TYPE_UNKNOWN"
|
|
82
|
+
| "USER_ACTIVITY_TYPE_UNRECOGNIZED";
|
|
70
83
|
tripInfo?: TripInfo;
|
|
71
84
|
stationaryInfo?: StationaryInfo;
|
|
72
85
|
}
|
|
@@ -81,7 +94,7 @@ declare module "sentiance-react-native-core" {
|
|
|
81
94
|
}
|
|
82
95
|
|
|
83
96
|
export interface ResetResult {
|
|
84
|
-
initState: string
|
|
97
|
+
initState: string;
|
|
85
98
|
}
|
|
86
99
|
|
|
87
100
|
export interface SdkStatus {
|
|
@@ -112,13 +125,13 @@ declare module "sentiance-react-native-core" {
|
|
|
112
125
|
}
|
|
113
126
|
|
|
114
127
|
export interface EnableDetectionsResult {
|
|
115
|
-
sdkStatus: SdkStatus
|
|
116
|
-
detectionStatus: DetectionStatus
|
|
128
|
+
sdkStatus: SdkStatus;
|
|
129
|
+
detectionStatus: DetectionStatus;
|
|
117
130
|
}
|
|
118
131
|
|
|
119
132
|
export interface DisableDetectionsResult {
|
|
120
|
-
sdkStatus: SdkStatus
|
|
121
|
-
detectionStatus: DetectionStatus
|
|
133
|
+
sdkStatus: SdkStatus;
|
|
134
|
+
detectionStatus: DetectionStatus;
|
|
122
135
|
}
|
|
123
136
|
|
|
124
137
|
export interface SentianceCore {
|
|
@@ -128,7 +141,9 @@ declare module "sentiance-react-native-core" {
|
|
|
128
141
|
|
|
129
142
|
enableDetections(): Promise<EnableDetectionsResult>;
|
|
130
143
|
|
|
131
|
-
enableDetectionsWithExpiryDate(
|
|
144
|
+
enableDetectionsWithExpiryDate(
|
|
145
|
+
expiryEpochTimeMs: number | null
|
|
146
|
+
): Promise<EnableDetectionsResult>;
|
|
132
147
|
|
|
133
148
|
disableDetections(): Promise<DisableDetectionsResult>;
|
|
134
149
|
|
|
@@ -154,7 +169,10 @@ declare module "sentiance-react-native-core" {
|
|
|
154
169
|
|
|
155
170
|
listenTripTimeout(): Promise<void>;
|
|
156
171
|
|
|
157
|
-
startTrip(
|
|
172
|
+
startTrip(
|
|
173
|
+
metadata: MetadataObject | null,
|
|
174
|
+
hint: TransportMode
|
|
175
|
+
): Promise<void>;
|
|
158
176
|
|
|
159
177
|
stopTrip(): Promise<void>;
|
|
160
178
|
|
|
@@ -194,11 +212,21 @@ declare module "sentiance-react-native-core" {
|
|
|
194
212
|
|
|
195
213
|
linkUserWithAuthCode(authCode: string): Promise<UserLinkingResult>;
|
|
196
214
|
|
|
197
|
-
addSdkStatusUpdateListener(
|
|
215
|
+
addSdkStatusUpdateListener(
|
|
216
|
+
onSdkStatusUpdated: (sdkStatus: SdkStatus) => void
|
|
217
|
+
): Promise<EmitterSubscription>;
|
|
218
|
+
|
|
219
|
+
addTripTimeoutListener(
|
|
220
|
+
onTripTimedOut: () => void
|
|
221
|
+
): Promise<EmitterSubscription>;
|
|
222
|
+
|
|
223
|
+
addSdkUserActivityUpdateListener(
|
|
224
|
+
onUserActivityUpdated: (userActivity: UserActivity) => void
|
|
225
|
+
): Promise<EmitterSubscription>;
|
|
198
226
|
|
|
199
|
-
|
|
227
|
+
setTransmittableDataTypes(types: Array<TransmittableDataType>): Promise<void>;
|
|
200
228
|
|
|
201
|
-
|
|
229
|
+
getTransmittableDataTypes(): Promise<Array<TransmittableDataType>>;
|
|
202
230
|
}
|
|
203
231
|
|
|
204
232
|
const SentianceCore: SentianceCore;
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const core = require('./core');
|
|
2
2
|
const {Platform} = require('react-native');
|
|
3
|
+
const VALID_TRANSMITTABLE_DATA_TYPES = ["ALL", "SDK_INFO", "VEHICLE_CRASH_INFO", "GENERAL_DETECTIONS"];
|
|
3
4
|
|
|
4
5
|
const enableDetections = () => core.enableDetections();
|
|
5
6
|
const enableDetectionsWithExpiryDate = (expiryTime) => core.enableDetectionsWithExpiryDate(expiryTime);
|
|
@@ -39,10 +40,10 @@ var submitDetections
|
|
|
39
40
|
var reset
|
|
40
41
|
|
|
41
42
|
if (Platform.OS === 'ios') {
|
|
42
|
-
startTrip = (metadata, hint) => core.
|
|
43
|
-
stopTrip = () => core.
|
|
44
|
-
submitDetections = () => core.
|
|
45
|
-
reset = () => core.
|
|
43
|
+
startTrip = (metadata, hint) => core.startTripNewAPI(metadata, hint);
|
|
44
|
+
stopTrip = () => core.stopTripNewAPI();
|
|
45
|
+
submitDetections = () => core.submitDetectionsNewAPI();
|
|
46
|
+
reset = () => core.resetNewAPI();
|
|
46
47
|
} else {
|
|
47
48
|
startTrip = (metadata, hint) => core.startTrip(metadata, hint);
|
|
48
49
|
stopTrip = () => core.stopTrip();
|
|
@@ -158,6 +159,27 @@ const addSdkStatusUpdateListener = core._addSdkStatusUpdateListener;
|
|
|
158
159
|
const addSdkUserActivityUpdateListener = core._addSdkUserActivityUpdateListener;
|
|
159
160
|
const addTripTimeoutListener = core._addTripTimeoutListener;
|
|
160
161
|
|
|
162
|
+
const setTransmittableDataTypes = async (types: Array<String>) => {
|
|
163
|
+
if (!_areValidTransmittableDataTypes(types)) {
|
|
164
|
+
const invalidPayloadDataTypes = _extractInvalidPayloadDataTypes(types);
|
|
165
|
+
return Promise.reject(
|
|
166
|
+
"setTransmittableDataTypes was called with the following invalid data types: " + invalidPayloadDataTypes);
|
|
167
|
+
}
|
|
168
|
+
return core.setTransmittableDataTypes(types);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const _areValidTransmittableDataTypes = (types: Array<String>) => {
|
|
172
|
+
return types.every((type) => {
|
|
173
|
+
return VALID_TRANSMITTABLE_DATA_TYPES.includes(type);
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const _extractInvalidPayloadDataTypes = (types: Array<String>) => {
|
|
178
|
+
return types.filter(type => !VALID_TRANSMITTABLE_DATA_TYPES.includes(type));
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const getTransmittableDataTypes = () => core.getTransmittableDataTypes();
|
|
182
|
+
|
|
161
183
|
const transportModes = {};
|
|
162
184
|
(function (transportModes) {
|
|
163
185
|
transportModes[transportModes["UNKNOWN"] = 1] = "UNKNOWN";
|
|
@@ -213,6 +235,8 @@ module.exports = {
|
|
|
213
235
|
addSdkUserActivityUpdateListener,
|
|
214
236
|
addTripTimeoutListener,
|
|
215
237
|
listenTripTimeout,
|
|
238
|
+
setTransmittableDataTypes,
|
|
239
|
+
getTransmittableDataTypes,
|
|
216
240
|
transportModes,
|
|
217
241
|
NO_OP_LINKER
|
|
218
242
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentiance-react-native/core",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.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.1.+"
|
|
33
33
|
},
|
|
34
34
|
"ios": {
|
|
35
|
-
"sentiance": "~> 6.
|
|
35
|
+
"sentiance": "~> 6.1.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|