@sentiance-react-native/core 6.0.0-beta.19 → 6.0.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/SentianceConverter.java +62 -75
- package/android/src/main/java/com/sentiance/react/bridge/core/SentianceModule.java +10 -0
- package/ios/RNSentianceCore+Converter.h +2 -2
- package/ios/RNSentianceCore+Converter.m +22 -18
- package/ios/RNSentianceCore.m +1 -1
- package/ios/RNSentianceErrorCodes.h +2 -2
- package/ios/RNSentianceErrorCodes.m +2 -2
- package/ios/RNSentianceHelper.h +2 -2
- package/ios/RNSentianceHelper.m +2 -2
- package/lib/index.d.ts +9 -4
- package/package.json +3 -3
|
@@ -43,7 +43,7 @@ public class SentianceConverter {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
public static Map<String, String> convertReadableMapToMap(ReadableMap inputMap) {
|
|
46
|
-
Map<String, String> map = new HashMap
|
|
46
|
+
Map<String, String> map = new HashMap<>();
|
|
47
47
|
ReadableMapKeySetIterator iterator = inputMap.keySetIterator();
|
|
48
48
|
while (iterator.hasNextKey()) {
|
|
49
49
|
String key = iterator.nextKey();
|
|
@@ -120,99 +120,88 @@ public class SentianceConverter {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
public static WritableMap convertUserCreationResult(UserCreationResult result) {
|
|
123
|
-
WritableMap map = Arguments.createMap();
|
|
124
123
|
UserInfo userInfo = result.getUserInfo();
|
|
125
|
-
|
|
126
|
-
Token token = userInfo.getToken();
|
|
127
|
-
map.putString("userId", userInfo.getUserId());
|
|
128
|
-
map.putString("tokenId", token.getTokenId());
|
|
129
|
-
map.putString("tokenExpiryDate", SentianceUtils.toDateString(token.getExpiryDate()));
|
|
130
|
-
map.putBoolean("isTokenExpired", token.isExpired());
|
|
131
|
-
} catch (Exception ignored) {
|
|
132
|
-
}
|
|
124
|
+
Token token = userInfo.getToken();
|
|
133
125
|
|
|
134
|
-
|
|
126
|
+
WritableMap userInfoMap = Arguments.createMap();
|
|
127
|
+
userInfoMap.putString("userId", userInfo.getUserId());
|
|
128
|
+
userInfoMap.putString("tokenId", token.getTokenId());
|
|
129
|
+
userInfoMap.putString("tokenExpiryDate", SentianceUtils.toDateString(token.getExpiryDate()));
|
|
130
|
+
userInfoMap.putBoolean("isTokenExpired", token.isExpired());
|
|
131
|
+
|
|
132
|
+
WritableMap userCreationResult = Arguments.createMap();
|
|
133
|
+
userCreationResult.putMap("userInfo", userInfoMap);
|
|
134
|
+
return userCreationResult;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
public static WritableMap convertUserLinkingResult(UserLinkingResult result) {
|
|
138
|
-
WritableMap map = Arguments.createMap();
|
|
139
138
|
UserInfo userInfo = result.getUserInfo();
|
|
140
|
-
|
|
141
|
-
Token token = userInfo.getToken();
|
|
142
|
-
map.putString("userId", userInfo.getUserId());
|
|
143
|
-
map.putString("tokenId", token.getTokenId());
|
|
144
|
-
map.putString("tokenExpiryDate", SentianceUtils.toDateString(token.getExpiryDate()));
|
|
145
|
-
map.putBoolean("isTokenExpired", token.isExpired());
|
|
146
|
-
} catch (Exception ignored) {
|
|
147
|
-
}
|
|
139
|
+
Token token = userInfo.getToken();
|
|
148
140
|
|
|
149
|
-
|
|
141
|
+
WritableMap userInfoMap = Arguments.createMap();
|
|
142
|
+
userInfoMap.putString("userId", userInfo.getUserId());
|
|
143
|
+
userInfoMap.putString("tokenId", token.getTokenId());
|
|
144
|
+
userInfoMap.putString("tokenExpiryDate", SentianceUtils.toDateString(token.getExpiryDate()));
|
|
145
|
+
userInfoMap.putBoolean("isTokenExpired", token.isExpired());
|
|
146
|
+
|
|
147
|
+
WritableMap userLinkingResult = Arguments.createMap();
|
|
148
|
+
userLinkingResult.putMap("userInfo", userInfoMap);
|
|
149
|
+
return userLinkingResult;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
public static WritableMap convertInstallId(String installId) {
|
|
153
153
|
WritableMap map = Arguments.createMap();
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
} catch (Exception ignored) {
|
|
157
|
-
}
|
|
154
|
+
map.putString("installId", installId);
|
|
155
|
+
|
|
158
156
|
return map;
|
|
159
157
|
}
|
|
160
158
|
|
|
161
159
|
public static WritableMap convertSdkStatus(SdkStatus status) {
|
|
162
160
|
WritableMap map = Arguments.createMap();
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
map.putBoolean("userExists", status.userExists);
|
|
186
|
-
} catch (Exception ignored) {
|
|
187
|
-
}
|
|
161
|
+
map.putString("startStatus", status.startStatus.name());
|
|
162
|
+
map.putString("detectionStatus", status.detectionStatus.name());
|
|
163
|
+
map.putBoolean("canDetect", status.canDetect);
|
|
164
|
+
map.putBoolean("isRemoteEnabled", status.isRemoteEnabled);
|
|
165
|
+
map.putString("locationPermission", status.locationPermission.toString());
|
|
166
|
+
map.putBoolean("isActivityRecognitionPermGranted", status.isActivityRecognitionPermGranted);
|
|
167
|
+
map.putString("locationSetting", status.locationSetting.name());
|
|
168
|
+
map.putBoolean("isAirplaneModeEnabled", status.isAirplaneModeEnabled);
|
|
169
|
+
map.putBoolean("isLocationAvailable", status.isLocationAvailable);
|
|
170
|
+
map.putBoolean("isAccelPresent", status.isAccelPresent);
|
|
171
|
+
map.putBoolean("isGyroPresent", status.isGyroPresent);
|
|
172
|
+
map.putBoolean("isGpsPresent", status.isGpsPresent);
|
|
173
|
+
map.putBoolean("isGooglePlayServicesMissing", status.isGooglePlayServicesMissing);
|
|
174
|
+
map.putBoolean("isBatteryOptimizationEnabled", status.isBatteryOptimizationEnabled);
|
|
175
|
+
map.putBoolean("isBatterySavingEnabled", status.isBatterySavingEnabled);
|
|
176
|
+
map.putBoolean("isBackgroundProcessingRestricted", status.isBackgroundProcessingRestricted);
|
|
177
|
+
map.putBoolean("isPreciseLocationAuthorizationGranted", status.isPreciseLocationPermGranted);
|
|
178
|
+
map.putBoolean("isSchedulingExactAlarmsPermitted", status.isSchedulingExactAlarmsPermitted);
|
|
179
|
+
map.putString("wifiQuotaStatus", status.wifiQuotaStatus.toString());
|
|
180
|
+
map.putString("mobileQuotaStatus", status.mobileQuotaStatus.toString());
|
|
181
|
+
map.putString("diskQuotaStatus", status.diskQuotaStatus.toString());
|
|
182
|
+
map.putBoolean("userExists", status.userExists);
|
|
188
183
|
|
|
189
184
|
return map;
|
|
190
185
|
}
|
|
191
186
|
|
|
192
187
|
public static WritableMap convertUserActivity(UserActivity activity) {
|
|
193
188
|
WritableMap map = Arguments.createMap();
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
//Stationary Info
|
|
206
|
-
if (activity.getStationaryInfo() != null) {
|
|
207
|
-
WritableMap stationaryInfoMap = Arguments.createMap();
|
|
208
|
-
if (activity.getStationaryInfo().getLocation() != null) {
|
|
209
|
-
WritableMap locationMap = convertLocation(activity.getStationaryInfo().getLocation());
|
|
210
|
-
stationaryInfoMap.putMap("location", locationMap);
|
|
211
|
-
}
|
|
212
|
-
map.putMap("stationaryInfo", stationaryInfoMap);
|
|
213
|
-
}
|
|
189
|
+
map.putString("type", convertUserActivityType(activity.getActivityType()));
|
|
190
|
+
|
|
191
|
+
//Trip Info
|
|
192
|
+
if (activity.getTripInfo() != null) {
|
|
193
|
+
WritableMap tripInfoMap = Arguments.createMap();
|
|
194
|
+
String tripType = convertTripType(activity.getTripInfo().getTripType());
|
|
195
|
+
tripInfoMap.putString("type", tripType);
|
|
196
|
+
map.putMap("tripInfo", tripInfoMap);
|
|
197
|
+
}
|
|
214
198
|
|
|
215
|
-
|
|
199
|
+
//Stationary Info
|
|
200
|
+
if (activity.getStationaryInfo() != null) {
|
|
201
|
+
WritableMap stationaryInfoMap = Arguments.createMap();
|
|
202
|
+
WritableMap locationMap = convertLocation(activity.getStationaryInfo().getLocation());
|
|
203
|
+
stationaryInfoMap.putMap("location", locationMap);
|
|
204
|
+
map.putMap("stationaryInfo", stationaryInfoMap);
|
|
216
205
|
}
|
|
217
206
|
|
|
218
207
|
return map;
|
|
@@ -338,10 +327,8 @@ public class SentianceConverter {
|
|
|
338
327
|
public static String stringifyStopTripError(StopTripError error) {
|
|
339
328
|
StopTripFailureReason reason = error.getReason();
|
|
340
329
|
String details = "";
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
details = "There is no ongoing external trip.";
|
|
344
|
-
break;
|
|
330
|
+
if (reason == StopTripFailureReason.NO_ONGOING_TRIP) {
|
|
331
|
+
details = "There is no ongoing external trip.";
|
|
345
332
|
}
|
|
346
333
|
return String.format("Reason: %s - %s", reason.name(), details);
|
|
347
334
|
}
|
|
@@ -525,5 +525,15 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
525
525
|
.setTripTimeoutListener(emitter::sendOnTripTimedOutEvent);
|
|
526
526
|
promise.resolve(null);
|
|
527
527
|
}
|
|
528
|
+
|
|
529
|
+
@ReactMethod
|
|
530
|
+
public void addListener(String eventName) {
|
|
531
|
+
// Set up any upstream listeners or background tasks as necessary
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
@ReactMethod
|
|
535
|
+
public void removeListeners(Integer count) {
|
|
536
|
+
// Remove upstream listeners, stop unnecessary background tasks
|
|
537
|
+
}
|
|
528
538
|
}
|
|
529
539
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// RNSentianceCore+Converter.m
|
|
3
|
+
// RNSentianceCore
|
|
4
4
|
//
|
|
5
5
|
// Created by Sebouh Aguehian on 10/10/2021.
|
|
6
6
|
// Copyright © 2021 Facebook. All rights reserved.
|
|
@@ -626,13 +626,13 @@
|
|
|
626
626
|
|
|
627
627
|
- (NSString*)convertInitStateToString:(SENTSDKInitState) state {
|
|
628
628
|
switch (state) {
|
|
629
|
-
case
|
|
629
|
+
case SENTSDKInitStateNotInitialized:
|
|
630
630
|
return @"NOT_INITIALIZED";
|
|
631
|
-
case
|
|
631
|
+
case SENTSDKInitStateInProgress:
|
|
632
632
|
return @"INIT_IN_PROGRESS";
|
|
633
|
-
case
|
|
633
|
+
case SENTSDKInitStateInitialized:
|
|
634
634
|
return @"INITIALIZED";
|
|
635
|
-
case
|
|
635
|
+
case SENTSDKInitStateResetting:
|
|
636
636
|
return @"RESETTING";
|
|
637
637
|
default:
|
|
638
638
|
return @"UNRECOGNIZED_STATE";
|
|
@@ -685,16 +685,18 @@
|
|
|
685
685
|
}
|
|
686
686
|
|
|
687
687
|
- (NSDictionary *)convertUserCreationResult:(SENTUserCreationResult *)userCreationResult {
|
|
688
|
-
NSMutableDictionary *
|
|
688
|
+
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
|
|
689
689
|
|
|
690
|
-
|
|
691
|
-
|
|
690
|
+
userInfo[@"userId"] = userCreationResult.userInfo.userId;
|
|
691
|
+
userInfo[@"tokenId"] = userCreationResult.userInfo.token.tokenId;
|
|
692
692
|
|
|
693
693
|
NSString *tokenExpiryDate = [[SENTDate alloc]initWithNSDate: userCreationResult.userInfo.token.expiryDate].description;
|
|
694
|
-
|
|
695
|
-
|
|
694
|
+
userInfo[@"tokenExpiryDate"] = tokenExpiryDate;
|
|
695
|
+
userInfo[@"isTokenExpired"] = @(userCreationResult.userInfo.token.isExpired);
|
|
696
696
|
|
|
697
|
-
|
|
697
|
+
NSMutableDictionary *userCreationResultDict = [[NSMutableDictionary alloc] init];
|
|
698
|
+
userCreationResultDict[@"userInfo"] = userInfo;
|
|
699
|
+
return userCreationResultDict;
|
|
698
700
|
}
|
|
699
701
|
|
|
700
702
|
- (NSString *)stringifyUserCreationError:(SENTUserCreationError *)userCreationError {
|
|
@@ -754,16 +756,18 @@
|
|
|
754
756
|
}
|
|
755
757
|
|
|
756
758
|
- (NSDictionary *)convertUserLinkingResult:(SENTUserLinkingResult *)userLinkingResult {
|
|
757
|
-
NSMutableDictionary *
|
|
759
|
+
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
|
|
758
760
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
+
userInfo[@"userId"] = userLinkingResult.userInfo.userId;
|
|
762
|
+
userInfo[@"tokenId"] = userLinkingResult.userInfo.token.tokenId;
|
|
761
763
|
|
|
762
764
|
NSString *tokenExpiryDate = [[SENTDate alloc]initWithNSDate: userLinkingResult.userInfo.token.expiryDate].description;
|
|
763
|
-
|
|
764
|
-
|
|
765
|
+
userInfo[@"tokenExpiryDate"] = tokenExpiryDate;
|
|
766
|
+
userInfo[@"isTokenExpired"] = @(userLinkingResult.userInfo.token.isExpired);
|
|
765
767
|
|
|
766
|
-
|
|
768
|
+
NSMutableDictionary *userLinkingResultDict = [[NSMutableDictionary alloc] init];
|
|
769
|
+
userLinkingResultDict[@"userInfo"] = userInfo;
|
|
770
|
+
return userLinkingResultDict;
|
|
767
771
|
}
|
|
768
772
|
|
|
769
773
|
- (NSString *)stringifyUserLinkingError:(SENTUserLinkingError *)userLinkingError {
|
package/ios/RNSentianceCore.m
CHANGED
|
@@ -1028,7 +1028,7 @@ RCT_EXPORT_METHOD(listenTripTimeout:(RCTPromiseResolveBlock)resolve rejecter:(RC
|
|
|
1028
1028
|
}
|
|
1029
1029
|
|
|
1030
1030
|
- (BOOL)isSdkNotInitialized {
|
|
1031
|
-
return [Sentiance sharedInstance].initState !=
|
|
1031
|
+
return [Sentiance sharedInstance].initState != SENTSDKInitStateInitialized;
|
|
1032
1032
|
}
|
|
1033
1033
|
|
|
1034
1034
|
@end
|
package/ios/RNSentianceHelper.h
CHANGED
package/ios/RNSentianceHelper.m
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -111,7 +111,12 @@ declare module "sentiance-react-native-core" {
|
|
|
111
111
|
backgroundRefreshStatus: BackgroundRefreshStatus; // iOS only
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
export interface
|
|
114
|
+
export interface EnableDetectionsResult {
|
|
115
|
+
sdkStatus: SdkStatus,
|
|
116
|
+
detectionStatus: DetectionStatus
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface DisableDetectionsResult {
|
|
115
120
|
sdkStatus: SdkStatus,
|
|
116
121
|
detectionStatus: DetectionStatus
|
|
117
122
|
}
|
|
@@ -121,11 +126,11 @@ declare module "sentiance-react-native-core" {
|
|
|
121
126
|
|
|
122
127
|
userExists(): Promise<boolean>;
|
|
123
128
|
|
|
124
|
-
enableDetections(): Promise<
|
|
129
|
+
enableDetections(): Promise<EnableDetectionsResult>;
|
|
125
130
|
|
|
126
|
-
enableDetectionsWithExpiryDate(expiryEpochTimeMs: number | null): Promise<
|
|
131
|
+
enableDetectionsWithExpiryDate(expiryEpochTimeMs: number | null): Promise<EnableDetectionsResult>;
|
|
127
132
|
|
|
128
|
-
disableDetections(): Promise<
|
|
133
|
+
disableDetections(): Promise<DisableDetectionsResult>;
|
|
129
134
|
|
|
130
135
|
reset(): Promise<ResetResult>;
|
|
131
136
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentiance-react-native/core",
|
|
3
|
-
"version": "6.0.0
|
|
3
|
+
"version": "6.0.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.0.0
|
|
32
|
+
"sentiance": "6.0.0"
|
|
33
33
|
},
|
|
34
34
|
"ios": {
|
|
35
|
-
"sentiance": "6.0.0
|
|
35
|
+
"sentiance": "6.0.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|