@sentiance-react-native/core 6.10.0-rc.5 → 6.10.1
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/ios/RNSentianceCore+Converter.h +3 -0
- package/ios/RNSentianceCore+Converter.m +160 -52
- package/ios/RNSentianceCore.h +0 -1
- package/ios/RNSentianceCore.m +34 -0
- package/ios/RNSentianceErrorCodes.h +1 -0
- package/ios/RNSentianceErrorCodes.m +1 -0
- package/package.json +3 -3
package/RNSentianceCore.podspec
CHANGED
|
@@ -58,5 +58,8 @@ typedef NS_ENUM(NSInteger, UIBackgroundRefreshStatus);
|
|
|
58
58
|
- (NSError *)convertSmartGeofencesRefreshError:(SENTSmartGeofencesRefreshError *)refreshError;
|
|
59
59
|
- (NSString *)stringifySmartGeofencesDetectionMode:(SENTSmartGeofenceDetectionMode)detectionMode;
|
|
60
60
|
- (NSDictionary*)convertSmartGeofenceEvent:(SENTSmartGeofenceEvent*)event;
|
|
61
|
+
- (SENTSafetyScoreRequestParameters*)convertToSafetyScoreRequestParameters:(NSDictionary*)params;
|
|
62
|
+
- (NSNumber * _Nullable)occupantRoleFeedbackFromString:(NSString * _Nonnull)stringValue;
|
|
63
|
+
- (NSString *_Nonnull)convertSENTOccupantRoleFeedbackResultToString:(SENTOccupantRoleFeedbackResult)feedbackResult;
|
|
61
64
|
|
|
62
65
|
@end
|
|
@@ -34,6 +34,38 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
34
34
|
|
|
35
35
|
@implementation RNSentianceCore (Converter)
|
|
36
36
|
|
|
37
|
+
- (NSNumber * _Nullable)occupantRoleFeedbackFromString:(NSString *)stringValue {
|
|
38
|
+
if ([stringValue isEqualToString:@"DRIVER"]) {
|
|
39
|
+
return @(SENTOccupantRoleFeedback_Driver);
|
|
40
|
+
}
|
|
41
|
+
else if ([stringValue isEqualToString:@"PASSENGER"]) {
|
|
42
|
+
return @(SENTOccupantRoleFeedback_Passenger);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return nil;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
- (NSString *_Nonnull)convertSENTOccupantRoleFeedbackResultToString:(SENTOccupantRoleFeedbackResult)feedbackResult {
|
|
50
|
+
switch (feedbackResult) {
|
|
51
|
+
case SENTOccupantRoleFeedbackResult_Accepted:
|
|
52
|
+
return @"ACCEPTED";
|
|
53
|
+
case SENTOccupantRoleFeedbackResult_TransportTypeNotSupported:
|
|
54
|
+
return @"TRANSPORT_TYPE_NOT_SUPPORTED";
|
|
55
|
+
case SENTOccupantRoleFeedbackResult_TransportNotFound:
|
|
56
|
+
return @"TRANSPORT_NOT_FOUND";
|
|
57
|
+
case SENTOccupantRoleFeedbackResult_FeedbackAlreadyProvided:
|
|
58
|
+
return @"FEEDBACK_ALREADY_PROVIDED";
|
|
59
|
+
case SENTOccupantRoleFeedbackResult_TransportNotYetComplete:
|
|
60
|
+
return @"TRANSPORT_TYPE_NOT_SUPPORTED";
|
|
61
|
+
case SENTOccupantRoleFeedbackResult_UnexpectedError:
|
|
62
|
+
return @"UNEXPECTED_ERROR";
|
|
63
|
+
default:
|
|
64
|
+
return @"UNEXPECTED_ERROR";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
37
69
|
- (NSString*)convertTimelineEventTypeToString:(SENTTimelineEventType)type {
|
|
38
70
|
switch (type) {
|
|
39
71
|
case SENTTimelineEventTypeStationary:
|
|
@@ -61,14 +93,14 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
61
93
|
dict[@"timestamp"] = @((long) ([location.timestamp timeIntervalSince1970] * 1000));
|
|
62
94
|
dict[@"latitude"] = @(location.coordinate.latitude);
|
|
63
95
|
dict[@"longitude"] = @(location.coordinate.longitude);
|
|
64
|
-
|
|
96
|
+
|
|
65
97
|
if (location.horizontalAccuracy >= 0) {
|
|
66
98
|
dict[@"accuracy"] = @(location.horizontalAccuracy);
|
|
67
99
|
}
|
|
68
100
|
if (location.verticalAccuracy > 0) {
|
|
69
101
|
dict[@"altitude"] = @(location.altitude);
|
|
70
102
|
}
|
|
71
|
-
|
|
103
|
+
|
|
72
104
|
return dict;
|
|
73
105
|
}
|
|
74
106
|
|
|
@@ -172,14 +204,14 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
172
204
|
|
|
173
205
|
- (NSDictionary*)convertVenue:(SENTVenue*)venue {
|
|
174
206
|
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
|
175
|
-
|
|
207
|
+
|
|
176
208
|
if (venue.location != nil) {
|
|
177
209
|
dict[@"location"] = [self convertGeolocation:venue.location];
|
|
178
210
|
}
|
|
179
|
-
|
|
211
|
+
|
|
180
212
|
dict[@"significance"] = [self convertVenueSignificance:venue.significance];
|
|
181
213
|
dict[@"type"] = [self convertVenueType:venue.type];
|
|
182
|
-
|
|
214
|
+
|
|
183
215
|
return dict;
|
|
184
216
|
}
|
|
185
217
|
|
|
@@ -187,14 +219,14 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
187
219
|
if (event.location != nil) {
|
|
188
220
|
dict[@"location"] = [self convertGeolocation:event.location];
|
|
189
221
|
}
|
|
190
|
-
|
|
222
|
+
|
|
191
223
|
dict[@"venue"] = [self convertVenue:event.venue];
|
|
192
224
|
}
|
|
193
225
|
|
|
194
226
|
- (NSString*)convertTransportModeToString:(SENTTimelineTransportMode)mode {
|
|
195
227
|
switch (mode) {
|
|
196
228
|
case SENTTimelineTransportModeBicycle:
|
|
197
|
-
return @"
|
|
229
|
+
return @"BICYCLE";
|
|
198
230
|
case SENTTimelineTransportModeWalking:
|
|
199
231
|
return @"WALKING";
|
|
200
232
|
case SENTTimelineTransportModeRunning:
|
|
@@ -215,19 +247,47 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
215
247
|
}
|
|
216
248
|
}
|
|
217
249
|
|
|
250
|
+
- (SENTTimelineTransportMode)transportModeFromString:(NSString*)value {
|
|
251
|
+
if ([value isEqualToString:@"WALKING"]) return SENTTimelineTransportModeWalking;
|
|
252
|
+
if ([value isEqualToString:@"RUNNING"]) return SENTTimelineTransportModeRunning;
|
|
253
|
+
if ([value isEqualToString:@"BICYCLE"]) return SENTTimelineTransportModeBicycle;
|
|
254
|
+
if ([value isEqualToString:@"TRAM"]) return SENTTimelineTransportModeTram;
|
|
255
|
+
if ([value isEqualToString:@"TRAIN"]) return SENTTimelineTransportModeTrain;
|
|
256
|
+
if ([value isEqualToString:@"CAR"]) return SENTTimelineTransportModeCar;
|
|
257
|
+
if ([value isEqualToString:@"BUS"]) return SENTTimelineTransportModeBus;
|
|
258
|
+
if ([value isEqualToString:@"MOTORCYCLE"]) return SENTTimelineTransportModeMotorcycle;
|
|
259
|
+
|
|
260
|
+
return SENTTimelineTransportModeUnknown;
|
|
261
|
+
}
|
|
262
|
+
|
|
218
263
|
- (void)addTransportEventInfoToDict:(NSMutableDictionary*)dict event:(SENTTransportEvent*)event {
|
|
219
264
|
dict[@"transportMode"] = [self convertTransportModeToString:event.transportMode];
|
|
220
265
|
dict[@"waypoints"] = [self convertWaypointArray:event.waypoints];
|
|
221
|
-
|
|
266
|
+
dict[@"occupantRole"] = [self convertOccupantRole:event.occupantRole];
|
|
267
|
+
|
|
268
|
+
|
|
222
269
|
if (event.distanceInMeters != nil) {
|
|
223
270
|
dict[@"distance"] = event.distanceInMeters;
|
|
224
271
|
}
|
|
225
|
-
|
|
272
|
+
|
|
226
273
|
if (event.tags != nil) {
|
|
227
274
|
dict[@"transportTags"] = event.tags;
|
|
228
275
|
}
|
|
229
276
|
}
|
|
230
277
|
|
|
278
|
+
- (NSString*)convertOccupantRole:(SENTOccupantRole)occupantRole {
|
|
279
|
+
switch (occupantRole) {
|
|
280
|
+
case SENTOccupantRole_Driver:
|
|
281
|
+
return @"DRIVER";
|
|
282
|
+
case SENTOccupantRole_Passenger:
|
|
283
|
+
return @"PASSENGER";
|
|
284
|
+
case SENTOccupantRole_Unavailable:
|
|
285
|
+
return @"UNAVAILABLE";
|
|
286
|
+
default:
|
|
287
|
+
return @"UNAVAILABLE";
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
231
291
|
- (NSDictionary*)convertWaypoint:(SENTWaypoint*)waypoint {
|
|
232
292
|
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
|
233
293
|
dict[@"latitude"] = @(waypoint.latitude);
|
|
@@ -243,6 +303,7 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
243
303
|
}
|
|
244
304
|
dict[@"isSpeedLimitInfoSet"] = @(waypoint.isSpeedLimitInfoSet);
|
|
245
305
|
dict[@"hasUnlimitedSpeedLimit"] = @(waypoint.isSpeedLimitUnlimited);
|
|
306
|
+
dict[@"isSynthetic"] = @(waypoint.isSynthetic);
|
|
246
307
|
|
|
247
308
|
return dict;
|
|
248
309
|
}
|
|
@@ -596,9 +657,9 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
596
657
|
|
|
597
658
|
if(userActivity.stationaryInfo.location) {
|
|
598
659
|
NSDictionary *location = @{
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
660
|
+
@"latitude": @(userActivity.stationaryInfo.location.coordinate.latitude),
|
|
661
|
+
@"longitude": @(userActivity.stationaryInfo.location.coordinate.longitude)
|
|
662
|
+
};
|
|
602
663
|
[stationaryInfoDict setObject:location forKey:@"location"];
|
|
603
664
|
}
|
|
604
665
|
|
|
@@ -618,24 +679,24 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
618
679
|
}
|
|
619
680
|
|
|
620
681
|
NSDictionary *dict = @{
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
682
|
+
@"startStatus":[self convertStartStatusToString:status.startStatus],
|
|
683
|
+
@"detectionStatus":[self convertDetectionStatusToString:status.detectionStatus],
|
|
684
|
+
@"canDetect":@(status.canDetect),
|
|
685
|
+
@"isRemoteEnabled":@(status.isRemoteEnabled),
|
|
686
|
+
@"locationPermission":[self convertLocationPermissionToString:status.locationPermission],
|
|
687
|
+
@"isPreciseLocationAuthorizationGranted":@(status.isPreciseLocationAuthorizationGranted),
|
|
688
|
+
@"isLocationAvailable":@(status.isLocationAvailable),
|
|
689
|
+
@"isAccelPresent":@(status.isAccelPresent),
|
|
690
|
+
@"isGyroPresent":@(status.isGyroPresent),
|
|
691
|
+
@"isGpsPresent":@(status.isGpsPresent),
|
|
692
|
+
@"wifiQuotaStatus":[self convertQuotaStatusToString:status.wifiQuotaStatus],
|
|
693
|
+
@"mobileQuotaStatus":[self convertQuotaStatusToString:status.mobileQuotaStatus],
|
|
694
|
+
@"diskQuotaStatus":[self convertQuotaStatusToString:status.diskQuotaStatus],
|
|
695
|
+
@"userExists":@(status.userExists),
|
|
696
|
+
@"isBatterySavingEnabled":@(status.isDeviceLowPowerModeEnabled),
|
|
697
|
+
@"isActivityRecognitionPermGranted":@(status.isMotionActivityPermissionGranted),
|
|
698
|
+
@"backgroundRefreshStatus":[self convertBackgroundRefreshStatus:status.backgroundRefreshStatus]
|
|
699
|
+
};
|
|
639
700
|
|
|
640
701
|
return dict;
|
|
641
702
|
}
|
|
@@ -739,9 +800,9 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
739
800
|
|
|
740
801
|
if(crashEvent.location != nil) {
|
|
741
802
|
NSDictionary *location = @{
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
803
|
+
@"latitude": @(crashEvent.location.coordinate.latitude),
|
|
804
|
+
@"longitude": @(crashEvent.location.coordinate.longitude)
|
|
805
|
+
};
|
|
745
806
|
dict[@"location"] = location;
|
|
746
807
|
}
|
|
747
808
|
|
|
@@ -760,7 +821,7 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
760
821
|
}
|
|
761
822
|
|
|
762
823
|
- (NSString *)_vehicleCrashDiagnosticStateName:(SENTVehicleCrashDetectionState)crashDetectionState {
|
|
763
|
-
|
|
824
|
+
switch (crashDetectionState) {
|
|
764
825
|
case 0:
|
|
765
826
|
return @"CANDIDATE_DETECTED";
|
|
766
827
|
case 1:
|
|
@@ -1116,14 +1177,14 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
1116
1177
|
- (NSSet<NSString*> *)convertIntegerTransmittableDataTypes:(NSArray<NSNumber*>*)intDataTypes {
|
|
1117
1178
|
NSMutableSet *typesSet = [[NSMutableSet alloc] init];
|
|
1118
1179
|
NSDictionary *dict = @{
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1180
|
+
@(SENTTransmittableDataTypeAll): @"ALL",
|
|
1181
|
+
@(SENTTransmittableDataTypeSdkInfo): @"SDK_INFO",
|
|
1182
|
+
@(SENTTransmittableDataTypeVehicleCrashInfo): @"VEHICLE_CRASH_INFO",
|
|
1183
|
+
@(SENTTransmittableDataTypeGeneralDetections): @"GENERAL_DETECTIONS"
|
|
1123
1184
|
};
|
|
1124
1185
|
|
|
1125
1186
|
for(NSNumber* intDataType in intDataTypes) {
|
|
1126
|
-
|
|
1187
|
+
[typesSet addObject:dict[intDataType]];
|
|
1127
1188
|
}
|
|
1128
1189
|
return [typesSet copy];
|
|
1129
1190
|
}
|
|
@@ -1131,14 +1192,14 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
1131
1192
|
- (NSSet<NSNumber*> *)convertStringTransmittableDataTypes:(NSArray<NSString*>*)stringDataTypes {
|
|
1132
1193
|
NSMutableSet *typesSet = [[NSMutableSet alloc] init];
|
|
1133
1194
|
NSDictionary *dict = @{
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1195
|
+
@"ALL": @(SENTTransmittableDataTypeAll),
|
|
1196
|
+
@"SDK_INFO": @(SENTTransmittableDataTypeSdkInfo),
|
|
1197
|
+
@"VEHICLE_CRASH_INFO": @(SENTTransmittableDataTypeVehicleCrashInfo),
|
|
1198
|
+
@"GENERAL_DETECTIONS": @(SENTTransmittableDataTypeGeneralDetections)
|
|
1138
1199
|
};
|
|
1139
1200
|
|
|
1140
1201
|
for(NSString * strType in stringDataTypes) {
|
|
1141
|
-
|
|
1202
|
+
[typesSet addObject:dict[strType]];
|
|
1142
1203
|
}
|
|
1143
1204
|
return [typesSet copy];
|
|
1144
1205
|
}
|
|
@@ -1236,9 +1297,7 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
1236
1297
|
}
|
|
1237
1298
|
|
|
1238
1299
|
- (NSDictionary<NSString *, id> *)convertSpeedingEvent:(SENTSpeedingEvent *)speedingEvent {
|
|
1239
|
-
|
|
1240
|
-
dict[@"waypoints"] = [self convertWaypointArray:speedingEvent.waypoints];
|
|
1241
|
-
return dict;
|
|
1300
|
+
return [self convertDrivingEvent:speedingEvent];
|
|
1242
1301
|
}
|
|
1243
1302
|
|
|
1244
1303
|
- (NSMutableDictionary<NSString *, id> *)convertDrivingEvent:(SENTDrivingEvent *)drivingEvent {
|
|
@@ -1247,6 +1306,7 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
1247
1306
|
dict[@"startTimeEpoch"] = @((long) (drivingEvent.startDate.timeIntervalSince1970 * 1000));
|
|
1248
1307
|
dict[@"endTime"] = [drivingEvent.endDate description];
|
|
1249
1308
|
dict[@"endTimeEpoch"] = @((long) (drivingEvent.endDate.timeIntervalSince1970 * 1000));
|
|
1309
|
+
dict[@"waypoints"] = [self convertWaypointArray:drivingEvent.waypoints];
|
|
1250
1310
|
return dict;
|
|
1251
1311
|
}
|
|
1252
1312
|
|
|
@@ -1288,7 +1348,7 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
1288
1348
|
|
|
1289
1349
|
NSError *error = [NSError errorWithDomain:SmartGeofencesErrorDomain
|
|
1290
1350
|
code:0
|
|
1291
|
-
|
|
1351
|
+
userInfo:errorInfo];
|
|
1292
1352
|
|
|
1293
1353
|
return error;
|
|
1294
1354
|
}
|
|
@@ -1349,15 +1409,63 @@ static NSString * const SmartGeofencesErrorDomain = @"com.sentiance.SmartGeofenc
|
|
|
1349
1409
|
return dict;
|
|
1350
1410
|
}
|
|
1351
1411
|
|
|
1352
|
-
- (NSString *)stringifyHarshEventType:(
|
|
1412
|
+
- (NSString *)stringifyHarshEventType:(SENTHarshDrivingEventType)type {
|
|
1353
1413
|
switch (type) {
|
|
1354
|
-
case
|
|
1414
|
+
case SENTHarshDrivingEventTypeAcceleration:
|
|
1355
1415
|
return @"ACCELERATION";
|
|
1356
|
-
case
|
|
1416
|
+
case SENTHarshDrivingEventTypeBraking:
|
|
1357
1417
|
return @"BRAKING";
|
|
1358
|
-
case
|
|
1418
|
+
case SENTHarshDrivingEventTypeTurn:
|
|
1359
1419
|
return @"TURN";
|
|
1360
1420
|
}
|
|
1361
1421
|
}
|
|
1362
1422
|
|
|
1423
|
+
- (SENTSafetyScoreRequestParameters*)convertToSafetyScoreRequestParameters:(NSDictionary<NSString *, id>*)params {
|
|
1424
|
+
NSNumber *period = params[@"period"];
|
|
1425
|
+
NSArray<NSString*> *transportModes = params[@"transportModes"];
|
|
1426
|
+
NSArray<NSString*> *occupantRoles = params[@"occupantRoles"];
|
|
1427
|
+
|
|
1428
|
+
return [[SENTSafetyScoreRequestParameters alloc] initWithPeriod:[self intToPeriod:period]
|
|
1429
|
+
transportModes:[self arrayToTransportModes:transportModes]
|
|
1430
|
+
occupantRoles:[self arrayToOccupantRoles:occupantRoles]];
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
- (SENTSafetyScoreRequestPeriodObjc*)intToPeriod:(NSNumber*)value {
|
|
1434
|
+
switch (value.intValue) {
|
|
1435
|
+
case 7:
|
|
1436
|
+
return SENTSafetyScoreRequestPeriodObjc.last7days;
|
|
1437
|
+
case 14:
|
|
1438
|
+
return SENTSafetyScoreRequestPeriodObjc.last14days;
|
|
1439
|
+
case 30:
|
|
1440
|
+
return SENTSafetyScoreRequestPeriodObjc.last30days;
|
|
1441
|
+
default:
|
|
1442
|
+
// this should not happen, as input validation already happens on the JS side
|
|
1443
|
+
@throw [NSException exceptionWithName:@"InvalidPeriodException"
|
|
1444
|
+
reason:[NSString stringWithFormat:@"Invalid period value: %@", value]
|
|
1445
|
+
userInfo:nil];
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
- (SENTSafetyScoreRequestTransportOptionModeObjc*)arrayToTransportModes:(NSArray<NSString*>*)transportModeValues {
|
|
1450
|
+
NSMutableArray<NSNumber*> *array = [[NSMutableArray alloc] init];
|
|
1451
|
+
for (NSString* transportMode in transportModeValues) {
|
|
1452
|
+
[array addObject:@([self transportModeFromString:transportMode])];
|
|
1453
|
+
}
|
|
1454
|
+
return [SENTSafetyScoreRequestTransportOptionModeObjc timelineTransportModes:array];
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
- (SENTSafetyScoreRequestOccupantRoleOptionObjc*)arrayToOccupantRoles:(NSArray<NSString*>*)occupantRoleValues {
|
|
1458
|
+
NSMutableArray<NSNumber*> *array = [[NSMutableArray alloc] init];
|
|
1459
|
+
for (NSString* occupantRole in occupantRoleValues) {
|
|
1460
|
+
[array addObject:@([self occupantRoleFromString:occupantRole])];
|
|
1461
|
+
}
|
|
1462
|
+
return [SENTSafetyScoreRequestOccupantRoleOptionObjc occupantRoles:array];
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
- (SENTOccupantRole)occupantRoleFromString:(NSString*)value {
|
|
1466
|
+
if ([value isEqualToString:@"DRIVER"]) return SENTOccupantRole_Driver;
|
|
1467
|
+
if ([value isEqualToString:@"PASSENGER"]) return SENTOccupantRole_Passenger;
|
|
1468
|
+
return SENTOccupantRole_Unavailable;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1363
1471
|
@end
|
package/ios/RNSentianceCore.h
CHANGED
|
@@ -32,5 +32,4 @@ typedef void (^SdkStatusHandler)(SENTSDKStatus * _Nonnull status);
|
|
|
32
32
|
- (void) enableSDKNativeInitialization: (RCTPromiseResolveBlock _Nullable)resolve rejecter:(RCTPromiseRejectBlock _Nullable)reject;
|
|
33
33
|
- (void) setTransmittableDataTypes: (NSArray *)types;
|
|
34
34
|
- (NSArray*) getTransmittableDataTypes:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
|
|
35
|
-
|
|
36
35
|
@end
|
package/ios/RNSentianceCore.m
CHANGED
|
@@ -1098,6 +1098,14 @@ RCT_EXPORT_METHOD(getSpeedingEvents:(NSString*)transportId resolver:(RCTPromiseR
|
|
|
1098
1098
|
resolve([self convertSpeedingEvents:speedingEvents]);
|
|
1099
1099
|
}
|
|
1100
1100
|
|
|
1101
|
+
RCT_EXPORT_METHOD(getAverageOverallSafetyScore:(NSDictionary *)params resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
1102
|
+
{
|
|
1103
|
+
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
1104
|
+
|
|
1105
|
+
SENTSafetyScoreRequestParameters* requestParams = [self convertToSafetyScoreRequestParameters:params];
|
|
1106
|
+
resolve([[Sentiance sharedInstance] objc_averageOverallSafetyScoreWithParams:requestParams]);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1101
1109
|
RCT_EXPORT_METHOD(addNativeListener:(NSString *)eventName subscriptionId:(NSInteger)subscriptionId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
1102
1110
|
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
1103
1111
|
|
|
@@ -1217,6 +1225,32 @@ RCT_EXPORT_METHOD(setTransportTags:(NSDictionary *)tags
|
|
|
1217
1225
|
}
|
|
1218
1226
|
}
|
|
1219
1227
|
|
|
1228
|
+
RCT_EXPORT_METHOD(submitOccupantRoleFeedback:(NSString *)transportId
|
|
1229
|
+
occupantFeedbackRole:(NSString *)occupantFeedbackRoleString
|
|
1230
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
1231
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
1232
|
+
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
1233
|
+
|
|
1234
|
+
NSNumber *feedbackValue = [self occupantRoleFeedbackFromString:occupantFeedbackRoleString];
|
|
1235
|
+
if (!feedbackValue) {
|
|
1236
|
+
// This should never happen, as JS validates input before calling native code.
|
|
1237
|
+
reject(@"E_SDK_INVALID_FEEDBACK_TYPE", @"Invalid occupant role provided.", nil);
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
SENTOccupantRoleFeedback occupantRoleFeedback = feedbackValue.integerValue;
|
|
1242
|
+
id<SENTFeedback> feedback = [[Sentiance sharedInstance] feedback];
|
|
1243
|
+
|
|
1244
|
+
if (!feedback) {
|
|
1245
|
+
reject(ESDKFeedbackNotAvailableError, @"Feedback service is not available.", nil);
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
SENTOccupantRoleFeedbackResult result = [feedback submitOccupantRoleFeedbackWithTransportId:transportId feedbackRole:occupantRoleFeedback];
|
|
1250
|
+
|
|
1251
|
+
resolve([self convertSENTOccupantRoleFeedbackResultToString:result]);
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1220
1254
|
- (void)didUpdateUserContext:(SENTUserContext *)userContext
|
|
1221
1255
|
forCriteriaMask:(SENTUserContextUpdateCriteria)criteriaMask {
|
|
1222
1256
|
NSDictionary *dict = @{
|
|
@@ -22,3 +22,4 @@ NSString * const ESDKResetError = @"E_SDK_RESET_ERROR";
|
|
|
22
22
|
NSString * const ESDKRequestUserContextError = @"E_SDK_REQUEST_USER_CONTEXT_ERROR";
|
|
23
23
|
NSString * const ESDKSmartGeofencesRefreshError = @"E_SDK_SMART_GEOFENCES_REFRESH_ERROR";
|
|
24
24
|
NSString * const ESDKTransportTaggingError = @"E_TRANSPORT_TAG_ERROR";
|
|
25
|
+
NSString * const ESDKFeedbackNotAvailableError = @"E_SDK_FEEDBACK_NOT_AVAILABLE";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentiance-react-native/core",
|
|
3
|
-
"version": "6.10.
|
|
3
|
+
"version": "6.10.1",
|
|
4
4
|
"description": "The Sentiance Core library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"targetSdk": 34,
|
|
30
30
|
"compileSdk": 34,
|
|
31
31
|
"buildTools": "34.0.0",
|
|
32
|
-
"sentiance": "6.10
|
|
32
|
+
"sentiance": "6.10.+"
|
|
33
33
|
},
|
|
34
34
|
"ios": {
|
|
35
|
-
"sentiance": "6.10.0
|
|
35
|
+
"sentiance": "~> 6.10.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|