@sentiance-react-native/core 6.6.0-rc1 → 6.6.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 +3 -1
- package/android/build.gradle +4 -0
- package/android/src/main/java/com/sentiance/react/bridge/core/SentianceConverter.java +46 -26
- package/android/src/main/java/com/sentiance/react/bridge/core/SentianceEmitter.java +6 -8
- package/android/src/main/java/com/sentiance/react/bridge/core/SentianceHelper.java +13 -14
- package/android/src/main/java/com/sentiance/react/bridge/core/SentianceModule.java +25 -23
- package/android/src/main/java/com/sentiance/react/bridge/core/common/SentianceSubscriptionsManager.java +4 -4
- package/android/src/main/java/com/sentiance/react/bridge/core/{base → common/base}/AbstractSentianceEmitter.java +1 -1
- package/android/src/main/java/com/sentiance/react/bridge/core/{base → common/base}/AbstractSentianceModule.java +2 -12
- package/android/src/main/java/com/sentiance/react/bridge/core/{utils → common/util}/ErrorCodes.java +1 -1
- package/android/src/main/java/com/sentiance/react/bridge/core/{utils → common/util}/SingleParamRunnable.java +1 -1
- package/android/src/main/java/com/sentiance/react/bridge/core/utils/UserCreationCompletionHandler.java +5 -3
- package/ios/RNSentianceCore+Converter.h +1 -0
- package/ios/RNSentianceCore+Converter.m +5 -3
- package/ios/RNSentianceCore.h +2 -1
- package/ios/RNSentianceCore.m +54 -1
- package/package.json +6 -6
- package/android/src/main/java/com/sentiance/react/bridge/core/common/SentianceCommonConverter.java +0 -24
package/RNSentianceCore.podspec
CHANGED
|
@@ -5,7 +5,7 @@ sentiance_sdk_env_var_version = ENV["SENTIANCE_RN_IOS_SDK_VERSION"]
|
|
|
5
5
|
|
|
6
6
|
Pod::Spec.new do |s|
|
|
7
7
|
s.name = "RNSentianceCore"
|
|
8
|
-
s.version = "6.6.0
|
|
8
|
+
s.version = "6.6.0"
|
|
9
9
|
s.summary = "RNSentianceCore"
|
|
10
10
|
s.description = <<-DESC
|
|
11
11
|
RNSentianceCore
|
|
@@ -26,4 +26,6 @@ Pod::Spec.new do |s|
|
|
|
26
26
|
s.dependency "SENTSDK", sentiance_sdk_package_version
|
|
27
27
|
else
|
|
28
28
|
s.dependency "SENTSDK", sentiance_sdk_env_var_version
|
|
29
|
+
end
|
|
30
|
+
|
|
29
31
|
end
|
package/android/build.gradle
CHANGED
|
@@ -19,6 +19,10 @@ def sentianceSdkVersion = getSentianceSdkVersion()
|
|
|
19
19
|
dependencies {
|
|
20
20
|
implementation(platform("com.sentiance:sdk-bom:${sentianceSdkVersion}"))
|
|
21
21
|
api("com.sentiance:sdk") { transitive = true }
|
|
22
|
+
|
|
23
|
+
if (findProject(':test-common')) {
|
|
24
|
+
testImplementation project(':test-common')
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
applyReactNativeDependency()
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
package com.sentiance.react.bridge.core;
|
|
2
2
|
|
|
3
|
-
import static com.sentiance.react.bridge.core.common.SentianceCommonConverter.convertLocation;
|
|
4
|
-
|
|
5
3
|
import android.location.Location;
|
|
6
4
|
|
|
7
5
|
import com.facebook.react.bridge.Arguments;
|
|
@@ -40,11 +38,18 @@ import java.util.Map;
|
|
|
40
38
|
|
|
41
39
|
public class SentianceConverter {
|
|
42
40
|
|
|
43
|
-
public static
|
|
41
|
+
public static final String JS_KEY_ALTITUDE = "altitude";
|
|
42
|
+
public static final String JS_KEY_PROVIDER = "provider";
|
|
43
|
+
public static final String JS_KEY_TIMESTAMP = "timestamp";
|
|
44
|
+
public static final String JS_KEY_LATITUDE = "latitude";
|
|
45
|
+
public static final String JS_KEY_LONGITUDE = "longitude";
|
|
46
|
+
public static final String JS_KEY_ACCURACY = "accuracy";
|
|
47
|
+
|
|
48
|
+
public WritableMap createEmptyResult() {
|
|
44
49
|
return Arguments.createMap();
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
public
|
|
52
|
+
public Map<String, String> convertReadableMapToMap(ReadableMap inputMap) {
|
|
48
53
|
Map<String, String> map = new HashMap<>();
|
|
49
54
|
ReadableMapKeySetIterator iterator = inputMap.keySetIterator();
|
|
50
55
|
while (iterator.hasNextKey()) {
|
|
@@ -58,7 +63,7 @@ public class SentianceConverter {
|
|
|
58
63
|
return map;
|
|
59
64
|
}
|
|
60
65
|
|
|
61
|
-
public
|
|
66
|
+
public TripType toTripType(final String type) {
|
|
62
67
|
if (type.equals("sdk") || type.equals("TRIP_TYPE_SDK")) {
|
|
63
68
|
return TripType.SDK_TRIP;
|
|
64
69
|
} else if (type.equals("external") || type.equals("TRIP_TYPE_EXTERNAL")) {
|
|
@@ -68,7 +73,7 @@ public class SentianceConverter {
|
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
75
|
|
|
71
|
-
public
|
|
76
|
+
public TransportMode toTransportMode(int t) {
|
|
72
77
|
switch (t) {
|
|
73
78
|
case 2:
|
|
74
79
|
return TransportMode.CAR;
|
|
@@ -95,7 +100,7 @@ public class SentianceConverter {
|
|
|
95
100
|
}
|
|
96
101
|
}
|
|
97
102
|
|
|
98
|
-
public
|
|
103
|
+
public String convertInitState(InitState initState) {
|
|
99
104
|
switch (initState) {
|
|
100
105
|
case NOT_INITIALIZED:
|
|
101
106
|
return "NOT_INITIALIZED";
|
|
@@ -110,7 +115,7 @@ public class SentianceConverter {
|
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
|
|
113
|
-
public
|
|
118
|
+
public WritableMap convertToken(Token token) {
|
|
114
119
|
WritableMap map = Arguments.createMap();
|
|
115
120
|
try {
|
|
116
121
|
map.putString("tokenId", token.getTokenId());
|
|
@@ -121,7 +126,7 @@ public class SentianceConverter {
|
|
|
121
126
|
return map;
|
|
122
127
|
}
|
|
123
128
|
|
|
124
|
-
public
|
|
129
|
+
public WritableMap convertUserCreationResult(UserCreationResult result) {
|
|
125
130
|
UserInfo userInfo = result.getUserInfo();
|
|
126
131
|
Token token = userInfo.getToken();
|
|
127
132
|
|
|
@@ -136,7 +141,7 @@ public class SentianceConverter {
|
|
|
136
141
|
return userCreationResult;
|
|
137
142
|
}
|
|
138
143
|
|
|
139
|
-
public
|
|
144
|
+
public WritableMap convertUserLinkingResult(UserLinkingResult result) {
|
|
140
145
|
UserInfo userInfo = result.getUserInfo();
|
|
141
146
|
Token token = userInfo.getToken();
|
|
142
147
|
|
|
@@ -151,14 +156,14 @@ public class SentianceConverter {
|
|
|
151
156
|
return userLinkingResult;
|
|
152
157
|
}
|
|
153
158
|
|
|
154
|
-
public
|
|
159
|
+
public WritableMap convertInstallId(String installId) {
|
|
155
160
|
WritableMap map = Arguments.createMap();
|
|
156
161
|
map.putString("installId", installId);
|
|
157
162
|
|
|
158
163
|
return map;
|
|
159
164
|
}
|
|
160
165
|
|
|
161
|
-
public
|
|
166
|
+
public WritableMap convertSdkStatus(SdkStatus status) {
|
|
162
167
|
WritableMap map = Arguments.createMap();
|
|
163
168
|
map.putString("startStatus", status.startStatus.name());
|
|
164
169
|
map.putString("detectionStatus", status.detectionStatus.name());
|
|
@@ -186,7 +191,7 @@ public class SentianceConverter {
|
|
|
186
191
|
return map;
|
|
187
192
|
}
|
|
188
193
|
|
|
189
|
-
public
|
|
194
|
+
public WritableMap convertUserActivity(UserActivity activity) {
|
|
190
195
|
WritableMap map = Arguments.createMap();
|
|
191
196
|
map.putString("type", convertUserActivityType(activity.getActivityType()));
|
|
192
197
|
|
|
@@ -209,7 +214,7 @@ public class SentianceConverter {
|
|
|
209
214
|
return map;
|
|
210
215
|
}
|
|
211
216
|
|
|
212
|
-
public
|
|
217
|
+
public String convertTripType(TripType tripType) {
|
|
213
218
|
switch (tripType) {
|
|
214
219
|
case ANY:
|
|
215
220
|
return "ANY";
|
|
@@ -222,7 +227,7 @@ public class SentianceConverter {
|
|
|
222
227
|
}
|
|
223
228
|
}
|
|
224
229
|
|
|
225
|
-
public
|
|
230
|
+
public String convertUserActivityType(UserActivityType activityType) {
|
|
226
231
|
switch (activityType) {
|
|
227
232
|
case TRIP:
|
|
228
233
|
return "USER_ACTIVITY_TYPE_TRIP";
|
|
@@ -235,23 +240,23 @@ public class SentianceConverter {
|
|
|
235
240
|
}
|
|
236
241
|
}
|
|
237
242
|
|
|
238
|
-
public
|
|
243
|
+
public WritableMap convertEnableDetectionsResult(EnableDetectionsResult enableDetectionsResult) {
|
|
239
244
|
return convertDetectionsResult(enableDetectionsResult.getSdkStatus(),
|
|
240
245
|
enableDetectionsResult.getDetectionStatus());
|
|
241
246
|
}
|
|
242
247
|
|
|
243
|
-
public
|
|
248
|
+
public WritableMap convertDisableDetectionsResult(DisableDetectionsResult disableDetectionsResult) {
|
|
244
249
|
return convertDetectionsResult(disableDetectionsResult.getSdkStatus(),
|
|
245
250
|
disableDetectionsResult.getDetectionStatus());
|
|
246
251
|
}
|
|
247
252
|
|
|
248
|
-
public
|
|
253
|
+
public WritableMap convertResetResult(ResetResult resetResult) {
|
|
249
254
|
WritableMap result = Arguments.createMap();
|
|
250
255
|
result.putString("initState", resetResult.getInitState().name());
|
|
251
256
|
return result;
|
|
252
257
|
}
|
|
253
258
|
|
|
254
|
-
private
|
|
259
|
+
private WritableMap convertDetectionsResult(SdkStatus sdkStatus, DetectionStatus detectionStatus) {
|
|
255
260
|
WritableMap result = Arguments.createMap();
|
|
256
261
|
WritableMap sdkStatusMap = convertSdkStatus(sdkStatus);
|
|
257
262
|
|
|
@@ -261,7 +266,22 @@ public class SentianceConverter {
|
|
|
261
266
|
return result;
|
|
262
267
|
}
|
|
263
268
|
|
|
264
|
-
public
|
|
269
|
+
public WritableMap convertLocation(Location location) {
|
|
270
|
+
WritableMap locationMap = Arguments.createMap();
|
|
271
|
+
locationMap.putDouble(JS_KEY_TIMESTAMP, location.getTime());
|
|
272
|
+
locationMap.putDouble(JS_KEY_LATITUDE, location.getLatitude());
|
|
273
|
+
locationMap.putDouble(JS_KEY_LONGITUDE, location.getLongitude());
|
|
274
|
+
if (location.hasAccuracy()) {
|
|
275
|
+
locationMap.putDouble(JS_KEY_ACCURACY, location.getAccuracy());
|
|
276
|
+
}
|
|
277
|
+
if (location.hasAltitude()) {
|
|
278
|
+
locationMap.putDouble(JS_KEY_ALTITUDE, location.getAltitude());
|
|
279
|
+
}
|
|
280
|
+
locationMap.putString(JS_KEY_PROVIDER, location.getProvider());
|
|
281
|
+
return locationMap;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
public String stringifyEnableDetectionsError(EnableDetectionsError error) {
|
|
265
285
|
EnableDetectionsFailureReason reason = error.getReason();
|
|
266
286
|
String details = "";
|
|
267
287
|
switch (reason) {
|
|
@@ -278,19 +298,19 @@ public class SentianceConverter {
|
|
|
278
298
|
return String.format("Reason: %s - %s", reason.name(), details);
|
|
279
299
|
}
|
|
280
300
|
|
|
281
|
-
public
|
|
301
|
+
public String stringifyUserLinkingError(UserLinkingError error) {
|
|
282
302
|
return String.format("Reason: %s - %s", error.getReason().name(), error.getDetails());
|
|
283
303
|
}
|
|
284
304
|
|
|
285
|
-
public
|
|
305
|
+
public String stringifyUserCreationError(UserCreationError error) {
|
|
286
306
|
return String.format("Reason: %s - %s", error.getReason().name(), error.getDetails());
|
|
287
307
|
}
|
|
288
308
|
|
|
289
|
-
public
|
|
309
|
+
public String stringifyResetError(ResetError error) {
|
|
290
310
|
return String.format("%s - caused by: %s", error.getReason().name(), error.getException());
|
|
291
311
|
}
|
|
292
312
|
|
|
293
|
-
public
|
|
313
|
+
public String stringifyStartTripError(StartTripError error) {
|
|
294
314
|
StartTripFailureReason reason = error.getReason();
|
|
295
315
|
String details = "";
|
|
296
316
|
switch (reason) {
|
|
@@ -313,7 +333,7 @@ public class SentianceConverter {
|
|
|
313
333
|
return String.format("Reason: %s - %s", reason.name(), details);
|
|
314
334
|
}
|
|
315
335
|
|
|
316
|
-
public
|
|
336
|
+
public String stringifyStopTripError(StopTripError error) {
|
|
317
337
|
StopTripFailureReason reason = error.getReason();
|
|
318
338
|
String details = "";
|
|
319
339
|
if (reason == StopTripFailureReason.NO_ONGOING_TRIP) {
|
|
@@ -322,7 +342,7 @@ public class SentianceConverter {
|
|
|
322
342
|
return String.format("Reason: %s - %s", reason.name(), details);
|
|
323
343
|
}
|
|
324
344
|
|
|
325
|
-
public
|
|
345
|
+
public String stringifyUserAccessTokenError(UserAccessTokenError error) {
|
|
326
346
|
UserAccessTokenFailureReason reason = error.getReason();
|
|
327
347
|
String details = "";
|
|
328
348
|
switch (reason) {
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
package com.sentiance.react.bridge.core;
|
|
2
2
|
|
|
3
|
-
import static com.sentiance.react.bridge.core.SentianceConverter.convertInstallId;
|
|
4
|
-
import static com.sentiance.react.bridge.core.SentianceConverter.convertSdkStatus;
|
|
5
|
-
import static com.sentiance.react.bridge.core.SentianceConverter.convertUserActivity;
|
|
6
|
-
|
|
7
3
|
import android.content.Context;
|
|
8
4
|
|
|
9
5
|
import com.facebook.react.bridge.Arguments;
|
|
10
|
-
import com.sentiance.react.bridge.core.base.AbstractSentianceEmitter;
|
|
6
|
+
import com.sentiance.react.bridge.core.common.base.AbstractSentianceEmitter;
|
|
11
7
|
import com.sentiance.sdk.SdkStatus;
|
|
12
8
|
import com.sentiance.sdk.detectionupdates.UserActivity;
|
|
13
9
|
|
|
@@ -16,21 +12,23 @@ public class SentianceEmitter extends AbstractSentianceEmitter {
|
|
|
16
12
|
private static final String STATUS_UPDATE = "SENTIANCE_STATUS_UPDATE_EVENT";
|
|
17
13
|
private static final String USER_ACTIVITY_UPDATE = "SENTIANCE_USER_ACTIVITY_UPDATE_EVENT";
|
|
18
14
|
private static final String ON_TRIP_TIMED_OUT = "SENTIANCE_ON_TRIP_TIMED_OUT_EVENT";
|
|
15
|
+
private final SentianceConverter converter;
|
|
19
16
|
|
|
20
17
|
public SentianceEmitter(Context context) {
|
|
21
18
|
super(context);
|
|
19
|
+
converter = new SentianceConverter();
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
void sendUserLinkEvent(String installId) {
|
|
25
|
-
sendEvent(USER_LINK, convertInstallId(installId));
|
|
23
|
+
sendEvent(USER_LINK, converter.convertInstallId(installId));
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
public void sendStatusUpdateEvent(SdkStatus status) {
|
|
29
|
-
sendEvent(STATUS_UPDATE, convertSdkStatus(status));
|
|
27
|
+
sendEvent(STATUS_UPDATE, converter.convertSdkStatus(status));
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
void sendUserActivityUpdate(UserActivity userActivity) {
|
|
33
|
-
sendEvent(USER_ACTIVITY_UPDATE, convertUserActivity(userActivity));
|
|
31
|
+
sendEvent(USER_ACTIVITY_UPDATE, converter.convertUserActivity(userActivity));
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
void sendOnTripTimedOutEvent() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
package com.sentiance.react.bridge.core;
|
|
2
2
|
|
|
3
|
-
import static com.sentiance.react.bridge.core.
|
|
4
|
-
import static com.sentiance.react.bridge.core.
|
|
5
|
-
import static com.sentiance.react.bridge.core.
|
|
6
|
-
import static com.sentiance.react.bridge.core.
|
|
3
|
+
import static com.sentiance.react.bridge.core.common.util.ErrorCodes.E_SDK_DISABLE_DETECTIONS_ERROR;
|
|
4
|
+
import static com.sentiance.react.bridge.core.common.util.ErrorCodes.E_SDK_ENABLE_DETECTIONS_ERROR;
|
|
5
|
+
import static com.sentiance.react.bridge.core.common.util.ErrorCodes.E_SDK_USER_LINK_AUTH_CODE_ERROR;
|
|
6
|
+
import static com.sentiance.react.bridge.core.common.util.ErrorCodes.E_SDK_USER_LINK_ERROR;
|
|
7
7
|
|
|
8
8
|
import android.app.Notification;
|
|
9
9
|
import android.content.Context;
|
|
@@ -38,20 +38,19 @@ public class SentianceHelper {
|
|
|
38
38
|
private final SentianceEmitter emitter;
|
|
39
39
|
private final WeakReference<Context> weakContext;
|
|
40
40
|
private final UserLinker userLinker;
|
|
41
|
-
|
|
42
41
|
private final OnSdkStatusUpdateHandler onSdkStatusUpdateHandler = this::onSdkStatusUpdated;
|
|
43
|
-
|
|
44
42
|
private final SdkStatusUpdateListener onSdkStatusUpdateListener = this::onSdkStatusUpdated;
|
|
43
|
+
private final SentianceConverter converter;
|
|
45
44
|
|
|
46
45
|
SdkStatusUpdateListener getOnSdkStatusUpdateListener() {
|
|
47
46
|
return onSdkStatusUpdateListener;
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
|
|
51
49
|
protected SentianceHelper(Context context) {
|
|
52
50
|
emitter = new SentianceEmitter(context);
|
|
53
51
|
weakContext = new WeakReference<>(context);
|
|
54
52
|
userLinker = new UserLinker(emitter);
|
|
53
|
+
converter = new SentianceConverter();
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
public static SentianceHelper getInstance(Context context) {
|
|
@@ -143,13 +142,13 @@ public class SentianceHelper {
|
|
|
143
142
|
if (pendingOperation.isSuccessful()) {
|
|
144
143
|
EnableDetectionsResult result = pendingOperation.getResult();
|
|
145
144
|
if (promise != null) {
|
|
146
|
-
promise.resolve(
|
|
145
|
+
promise.resolve(converter.convertEnableDetectionsResult(result));
|
|
147
146
|
}
|
|
148
147
|
} else {
|
|
149
148
|
EnableDetectionsError error = pendingOperation.getError();
|
|
150
149
|
if (promise != null) {
|
|
151
150
|
promise.reject(E_SDK_ENABLE_DETECTIONS_ERROR,
|
|
152
|
-
|
|
151
|
+
converter.stringifyEnableDetectionsError(error));
|
|
153
152
|
}
|
|
154
153
|
}
|
|
155
154
|
});
|
|
@@ -161,7 +160,7 @@ public class SentianceHelper {
|
|
|
161
160
|
.addOnCompleteListener(pendingOperation -> {
|
|
162
161
|
if (pendingOperation.isSuccessful()) {
|
|
163
162
|
DisableDetectionsResult result = pendingOperation.getResult();
|
|
164
|
-
promise.resolve(
|
|
163
|
+
promise.resolve(converter.convertDisableDetectionsResult(result));
|
|
165
164
|
} else {
|
|
166
165
|
promise.reject(E_SDK_DISABLE_DETECTIONS_ERROR, "");
|
|
167
166
|
}
|
|
@@ -173,11 +172,11 @@ public class SentianceHelper {
|
|
|
173
172
|
sentiance.linkUser(userLinker)
|
|
174
173
|
.addOnCompleteListener(pendingOperation -> {
|
|
175
174
|
if (pendingOperation.isSuccessful()) {
|
|
176
|
-
promise.resolve(
|
|
175
|
+
promise.resolve(converter.convertUserLinkingResult(pendingOperation.getResult()));
|
|
177
176
|
} else {
|
|
178
177
|
UserLinkingError error = pendingOperation.getError();
|
|
179
178
|
promise.reject(E_SDK_USER_LINK_ERROR,
|
|
180
|
-
|
|
179
|
+
converter.stringifyUserLinkingError(error));
|
|
181
180
|
}
|
|
182
181
|
});
|
|
183
182
|
}
|
|
@@ -187,11 +186,11 @@ public class SentianceHelper {
|
|
|
187
186
|
sentiance.linkUser(authCode)
|
|
188
187
|
.addOnCompleteListener(pendingOperation -> {
|
|
189
188
|
if (pendingOperation.isSuccessful()) {
|
|
190
|
-
promise.resolve(
|
|
189
|
+
promise.resolve(converter.convertUserLinkingResult(pendingOperation.getResult()));
|
|
191
190
|
} else {
|
|
192
191
|
UserLinkingError error = pendingOperation.getError();
|
|
193
192
|
promise.reject(E_SDK_USER_LINK_AUTH_CODE_ERROR,
|
|
194
|
-
|
|
193
|
+
converter.stringifyUserLinkingError(error));
|
|
195
194
|
}
|
|
196
195
|
});
|
|
197
196
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
package com.sentiance.react.bridge.core;
|
|
2
2
|
|
|
3
|
-
import static com.sentiance.react.bridge.core.
|
|
4
|
-
import static com.sentiance.react.bridge.core.
|
|
5
|
-
import static com.sentiance.react.bridge.core.
|
|
6
|
-
import static com.sentiance.react.bridge.core.
|
|
7
|
-
import static com.sentiance.react.bridge.core.
|
|
8
|
-
import static com.sentiance.react.bridge.core.
|
|
3
|
+
import static com.sentiance.react.bridge.core.common.util.ErrorCodes.E_SDK_GET_TOKEN_ERROR;
|
|
4
|
+
import static com.sentiance.react.bridge.core.common.util.ErrorCodes.E_SDK_MISSING_PARAMS;
|
|
5
|
+
import static com.sentiance.react.bridge.core.common.util.ErrorCodes.E_SDK_RESET_ERROR;
|
|
6
|
+
import static com.sentiance.react.bridge.core.common.util.ErrorCodes.E_SDK_START_TRIP_ERROR;
|
|
7
|
+
import static com.sentiance.react.bridge.core.common.util.ErrorCodes.E_SDK_STOP_TRIP_ERROR;
|
|
8
|
+
import static com.sentiance.react.bridge.core.common.util.ErrorCodes.E_SDK_SUBMIT_DETECTIONS_ERROR;
|
|
9
9
|
|
|
10
10
|
import android.annotation.SuppressLint;
|
|
11
11
|
import android.app.Notification;
|
|
@@ -22,8 +22,8 @@ import com.facebook.react.bridge.ReactMethod;
|
|
|
22
22
|
import com.facebook.react.bridge.ReadableArray;
|
|
23
23
|
import com.facebook.react.bridge.ReadableMap;
|
|
24
24
|
import com.facebook.react.bridge.WritableArray;
|
|
25
|
-
import com.sentiance.react.bridge.core.base.AbstractSentianceModule;
|
|
26
25
|
import com.sentiance.react.bridge.core.common.SentianceSubscriptionsManager;
|
|
26
|
+
import com.sentiance.react.bridge.core.common.base.AbstractSentianceModule;
|
|
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;
|
|
@@ -53,11 +53,13 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
53
53
|
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
|
54
54
|
private final SentianceHelper sentianceHelper;
|
|
55
55
|
private final SentianceEmitter emitter;
|
|
56
|
+
private final SentianceConverter converter;
|
|
56
57
|
|
|
57
58
|
public SentianceModule(ReactApplicationContext reactContext) {
|
|
58
59
|
super(reactContext, Sentiance.getInstance(reactContext), new SentianceSubscriptionsManager());
|
|
59
60
|
sentianceHelper = SentianceHelper.getInstance(reactContext);
|
|
60
61
|
emitter = new SentianceEmitter(reactContext);
|
|
62
|
+
converter = new SentianceConverter();
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
@NonNull
|
|
@@ -166,10 +168,10 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
166
168
|
mSdk.reset()
|
|
167
169
|
.addOnCompleteListener(pendingOperation -> {
|
|
168
170
|
if (pendingOperation.isSuccessful()) {
|
|
169
|
-
promise.resolve(
|
|
171
|
+
promise.resolve(converter.convertResetResult(pendingOperation.getResult()));
|
|
170
172
|
} else {
|
|
171
173
|
ResetError error = pendingOperation.getError();
|
|
172
|
-
promise.reject(E_SDK_RESET_ERROR,
|
|
174
|
+
promise.reject(E_SDK_RESET_ERROR, converter.stringifyResetError(error));
|
|
173
175
|
}
|
|
174
176
|
});
|
|
175
177
|
}
|
|
@@ -178,7 +180,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
178
180
|
@SuppressWarnings("unused")
|
|
179
181
|
public void getInitState(final Promise promise) {
|
|
180
182
|
InitState initState = mSdk.getInitState();
|
|
181
|
-
promise.resolve(
|
|
183
|
+
promise.resolve(converter.convertInitState(initState));
|
|
182
184
|
}
|
|
183
185
|
|
|
184
186
|
@ReactMethod
|
|
@@ -194,15 +196,15 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
194
196
|
metadataMap.put(entry.getKey(), entry.getValue().toString());
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
|
-
final TransportMode transportModeHint =
|
|
199
|
+
final TransportMode transportModeHint = converter.toTransportMode(hint);
|
|
198
200
|
mSdk.startTrip(metadataMap, transportModeHint)
|
|
199
201
|
.addOnCompleteListener(pendingOperation -> {
|
|
200
202
|
if (pendingOperation.isSuccessful()) {
|
|
201
|
-
promise.resolve(
|
|
203
|
+
promise.resolve(converter.createEmptyResult());
|
|
202
204
|
} else {
|
|
203
205
|
StartTripError error = pendingOperation.getError();
|
|
204
206
|
promise.reject(E_SDK_START_TRIP_ERROR,
|
|
205
|
-
|
|
207
|
+
converter.stringifyStartTripError(error));
|
|
206
208
|
}
|
|
207
209
|
});
|
|
208
210
|
}
|
|
@@ -216,11 +218,11 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
216
218
|
mSdk.stopTrip()
|
|
217
219
|
.addOnCompleteListener(pendingOperation -> {
|
|
218
220
|
if (pendingOperation.isSuccessful()) {
|
|
219
|
-
promise.resolve(
|
|
221
|
+
promise.resolve(converter.createEmptyResult());
|
|
220
222
|
} else {
|
|
221
223
|
StopTripError error = pendingOperation.getError();
|
|
222
224
|
promise.reject(E_SDK_STOP_TRIP_ERROR,
|
|
223
|
-
|
|
225
|
+
converter.stringifyStopTripError(error));
|
|
224
226
|
}
|
|
225
227
|
});
|
|
226
228
|
}
|
|
@@ -233,7 +235,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
SdkStatus sdkStatus = mSdk.getSdkStatus();
|
|
236
|
-
promise.resolve(
|
|
238
|
+
promise.resolve(converter.convertSdkStatus(sdkStatus));
|
|
237
239
|
}
|
|
238
240
|
|
|
239
241
|
@ReactMethod
|
|
@@ -254,7 +256,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
254
256
|
promise.reject(E_SDK_MISSING_PARAMS, "TripType is required");
|
|
255
257
|
return;
|
|
256
258
|
}
|
|
257
|
-
final TripType type =
|
|
259
|
+
final TripType type = converter.toTripType(typeParam);
|
|
258
260
|
Boolean isTripOngoing = mSdk.isTripOngoing(type);
|
|
259
261
|
promise.resolve(isTripOngoing);
|
|
260
262
|
}
|
|
@@ -270,11 +272,11 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
270
272
|
.addOnCompleteListener(pendingOperation -> {
|
|
271
273
|
if (pendingOperation.isSuccessful()) {
|
|
272
274
|
Token token = pendingOperation.getResult();
|
|
273
|
-
promise.resolve(
|
|
275
|
+
promise.resolve(converter.convertToken(token));
|
|
274
276
|
} else {
|
|
275
277
|
UserAccessTokenError error = pendingOperation.getError();
|
|
276
278
|
promise.reject(E_SDK_GET_TOKEN_ERROR,
|
|
277
|
-
|
|
279
|
+
converter.stringifyUserAccessTokenError(error));
|
|
278
280
|
}
|
|
279
281
|
});
|
|
280
282
|
}
|
|
@@ -313,7 +315,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
313
315
|
return;
|
|
314
316
|
}
|
|
315
317
|
|
|
316
|
-
final Map<String, String> metadata =
|
|
318
|
+
final Map<String, String> metadata = converter.convertReadableMapToMap(inputMetadata);
|
|
317
319
|
boolean result = mSdk.addTripMetadata(metadata);
|
|
318
320
|
promise.resolve(result);
|
|
319
321
|
}
|
|
@@ -330,7 +332,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
330
332
|
return;
|
|
331
333
|
}
|
|
332
334
|
|
|
333
|
-
final Map<String, String> metadata =
|
|
335
|
+
final Map<String, String> metadata = converter.convertReadableMapToMap(inputMetadata);
|
|
334
336
|
mSdk.addUserMetadataFields(metadata);
|
|
335
337
|
promise.resolve(null);
|
|
336
338
|
}
|
|
@@ -361,7 +363,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
361
363
|
mSdk.submitDetections()
|
|
362
364
|
.addOnCompleteListener(pendingOperation -> {
|
|
363
365
|
if (pendingOperation.isSuccessful()) {
|
|
364
|
-
promise.resolve(
|
|
366
|
+
promise.resolve(converter.createEmptyResult());
|
|
365
367
|
} else {
|
|
366
368
|
SubmitDetectionsError error = pendingOperation.getError();
|
|
367
369
|
promise.reject(E_SDK_SUBMIT_DETECTIONS_ERROR, error.getReason().name());
|
|
@@ -466,7 +468,7 @@ public class SentianceModule extends AbstractSentianceModule {
|
|
|
466
468
|
}
|
|
467
469
|
|
|
468
470
|
UserActivity activity = Sentiance.getInstance(mReactContext).getUserActivity();
|
|
469
|
-
promise.resolve(
|
|
471
|
+
promise.resolve(converter.convertUserActivity(activity));
|
|
470
472
|
}
|
|
471
473
|
|
|
472
474
|
@ReactMethod
|
|
@@ -3,7 +3,7 @@ package com.sentiance.react.bridge.core.common;
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
4
|
import androidx.annotation.Nullable;
|
|
5
5
|
|
|
6
|
-
import com.sentiance.react.bridge.core.
|
|
6
|
+
import com.sentiance.react.bridge.core.common.util.SingleParamRunnable;
|
|
7
7
|
|
|
8
8
|
import java.util.ArrayList;
|
|
9
9
|
import java.util.HashMap;
|
|
@@ -23,14 +23,14 @@ public class SentianceSubscriptionsManager {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
public <T> void addSupportedSubscription(String eventType, SingleParamRunnable<T> nativeSubscribeLogic,
|
|
26
|
-
|
|
26
|
+
SingleParamRunnable<T> nativeUnsubscribeLogic, SubscriptionType subscriptionType) {
|
|
27
27
|
if (mSupportedSubscriptions.containsKey(eventType)) {
|
|
28
28
|
throw new IllegalArgumentException(String.format("A subscription definition for %s has already been added.",
|
|
29
|
-
|
|
29
|
+
eventType));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
mSupportedSubscriptions.put(eventType, new SubscriptionDefinition<>(eventType, nativeSubscribeLogic,
|
|
33
|
-
|
|
33
|
+
nativeUnsubscribeLogic, subscriptionType));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
public <T> void addSubscription(@NonNull String eventType, int subscriptionId, @NonNull T eventEmitterLogic) {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
package com.sentiance.react.bridge.core.base;
|
|
1
|
+
package com.sentiance.react.bridge.core.common.base;
|
|
2
2
|
|
|
3
|
-
import static com.sentiance.react.bridge.core.
|
|
4
|
-
|
|
5
|
-
import androidx.annotation.NonNull;
|
|
3
|
+
import static com.sentiance.react.bridge.core.common.util.ErrorCodes.E_SDK_NOT_INITIALIZED;
|
|
6
4
|
|
|
7
5
|
import com.facebook.react.bridge.Promise;
|
|
8
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
@@ -46,14 +44,6 @@ public abstract class AbstractSentianceModule extends ReactContextBaseJavaModule
|
|
|
46
44
|
|
|
47
45
|
}
|
|
48
46
|
|
|
49
|
-
protected <T> void addSubscription(@NonNull String eventType, int subscriptionId, @NonNull T eventEmitterLogic) {
|
|
50
|
-
mSubscriptionsManager.addSubscription(eventType, subscriptionId, eventEmitterLogic);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
protected <T> void removeSubscription(int subscriptionId, @NonNull String eventType) {
|
|
54
|
-
mSubscriptionsManager.removeSubscription(subscriptionId, eventType);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
47
|
protected abstract void removeNativeListener(String eventName, int subscriptionId, Promise promise);
|
|
58
48
|
|
|
59
49
|
protected abstract void addNativeListener(String eventName, int subscriptionId, Promise promise);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
package com.sentiance.react.bridge.core.utils;
|
|
2
2
|
|
|
3
|
-
import static com.sentiance.react.bridge.core.
|
|
3
|
+
import static com.sentiance.react.bridge.core.common.util.ErrorCodes.E_SDK_CREATE_USER_ERROR;
|
|
4
4
|
|
|
5
5
|
import androidx.annotation.NonNull;
|
|
6
6
|
|
|
@@ -14,18 +14,20 @@ import com.sentiance.sdk.usercreation.UserCreationResult;
|
|
|
14
14
|
public class UserCreationCompletionHandler implements OnCompleteListener<UserCreationResult, UserCreationError> {
|
|
15
15
|
|
|
16
16
|
private final Promise promise;
|
|
17
|
+
private final SentianceConverter converter;
|
|
17
18
|
|
|
18
19
|
public UserCreationCompletionHandler(Promise promise) {
|
|
19
20
|
this.promise = promise;
|
|
21
|
+
converter = new SentianceConverter();
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
@Override
|
|
23
25
|
public void onComplete(@NonNull PendingOperation<UserCreationResult, UserCreationError> pendingOperation) {
|
|
24
26
|
if (pendingOperation.isSuccessful()) {
|
|
25
|
-
promise.resolve(
|
|
27
|
+
promise.resolve(converter.convertUserCreationResult(pendingOperation.getResult()));
|
|
26
28
|
} else {
|
|
27
29
|
promise.reject(E_SDK_CREATE_USER_ERROR,
|
|
28
|
-
|
|
30
|
+
converter.stringifyUserCreationError(pendingOperation.getError()));
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
}
|
|
@@ -54,5 +54,6 @@ typedef NS_ENUM(NSInteger, UIBackgroundRefreshStatus);
|
|
|
54
54
|
- (NSArray *)convertPhoneUsageEvents:(NSArray<SENTPhoneUsageEvent*> *)phoneUsageEvents;
|
|
55
55
|
- (NSArray *)convertCallWhileMovingEvents:(NSArray<SENTCallWhileMovingEvent*> *)callWhileMovingEvents;
|
|
56
56
|
- (NSArray *)convertSpeedingEvents:(NSArray<SENTSpeedingEvent*> *)speedingEvents;
|
|
57
|
+
- (NSMutableDictionary*)convertEvent:(SENTTimelineEvent*)event;
|
|
57
58
|
|
|
58
59
|
@end
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
- (void)addStationaryEventInfoToDict:(NSMutableDictionary*)dict event:(SENTStationaryEvent*)event;
|
|
21
21
|
- (NSString*)convertTransportModeToString:(SENTTimelineTransportMode) mode;
|
|
22
22
|
- (void)addTransportEventInfoToDict:(NSMutableDictionary*)dict event:(SENTTransportEvent*)event;
|
|
23
|
-
- (NSMutableDictionary*)convertEvent:(SENTTimelineEvent*)event;
|
|
24
23
|
- (nullable NSString*)convertSegmentCategoryToString:(SENTSegmentCategory)category;
|
|
25
24
|
- (nullable NSString*)convertSegmentSubcategoryToString:(SENTSegmentSubcategory)subcategory;
|
|
26
25
|
- (nullable NSString*)convertSegmentTypeToString:(SENTSegmentType)type;
|
|
@@ -235,6 +234,7 @@
|
|
|
235
234
|
if (waypoint.isSpeedLimitInfoSet) {
|
|
236
235
|
dict[@"speedLimitInMps"] = @(waypoint.speedLimitInMps);
|
|
237
236
|
}
|
|
237
|
+
dict[@"isSpeedLimitInfoSet"] = @(waypoint.isSpeedLimitInfoSet);
|
|
238
238
|
dict[@"hasUnlimitedSpeedLimit"] = @(waypoint.isSpeedLimitUnlimited);
|
|
239
239
|
|
|
240
240
|
return dict;
|
|
@@ -269,6 +269,8 @@
|
|
|
269
269
|
eventDict[@"id"] = [event eventId];
|
|
270
270
|
eventDict[@"startTime"] = [event.startDate description];
|
|
271
271
|
eventDict[@"startTimeEpoch"] = @((long) (event.startDate.timeIntervalSince1970 * 1000));
|
|
272
|
+
eventDict[@"lastUpdateTime"] = [event.lastUpdateDate description];
|
|
273
|
+
eventDict[@"lastUpdateTimeEpoch"] = @((long) (event.lastUpdateDate.timeIntervalSince1970 * 1000));
|
|
272
274
|
if (event.endDate != nil) {
|
|
273
275
|
eventDict[@"endTime"] = [event.endDate description];
|
|
274
276
|
eventDict[@"endTimeEpoch"] = @((long) (event.endDate.timeIntervalSince1970 * 1000));
|
|
@@ -1223,13 +1225,13 @@
|
|
|
1223
1225
|
}
|
|
1224
1226
|
|
|
1225
1227
|
- (NSDictionary<NSString *, NSNumber *> *)convertSpeedingEvent:(SENTSpeedingEvent *)speedingEvent {
|
|
1226
|
-
NSMutableDictionary
|
|
1228
|
+
NSMutableDictionary *dict = [self convertDrivingEvent:speedingEvent];
|
|
1227
1229
|
dict[@"waypoints"] = [self convertWaypointArray:speedingEvent.waypoints];
|
|
1228
1230
|
return dict;
|
|
1229
1231
|
}
|
|
1230
1232
|
|
|
1231
1233
|
- (NSMutableDictionary<NSString *, NSNumber *> *)convertDrivingEvent:(SENTDrivingEvent *)drivingEvent {
|
|
1232
|
-
NSMutableDictionary
|
|
1234
|
+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
|
1233
1235
|
dict[@"startTime"] = [drivingEvent.startDate description];
|
|
1234
1236
|
dict[@"startTimeEpoch"] = @((long) (drivingEvent.startDate.timeIntervalSince1970 * 1000));
|
|
1235
1237
|
dict[@"endTime"] = [drivingEvent.endDate description];
|
package/ios/RNSentianceCore.h
CHANGED
|
@@ -13,8 +13,9 @@ static NSString * _Nonnull const VehicleCrashEvent = @"SENTIANCE_VEHICLE_CRASH_E
|
|
|
13
13
|
static NSString * _Nonnull const VehicleCrashDiagnosticEvent = @"SENTIANCE_VEHICLE_CRASH_DIAGNOSTIC_EVENT";
|
|
14
14
|
static NSString * _Nonnull const UserContextUpdateEvent = @"SENTIANCE_USER_CONTEXT_UPDATE_EVENT";
|
|
15
15
|
static NSString * _Nonnull const DrivingInsightsReadyEvent = @"SENTIANCE_DRIVING_INSIGHTS_READY_EVENT";
|
|
16
|
+
static NSString * _Nonnull const TimelineUpdateEvent = @"SENTIANCE_TIMELINE_UPDATE_EVENT";
|
|
16
17
|
|
|
17
|
-
@interface RNSentianceCore : RCTEventEmitter <RCTBridgeModule, SENTUserContextDelegate, SENTDrivingInsightsReadyDelegate>
|
|
18
|
+
@interface RNSentianceCore : RCTEventEmitter <RCTBridgeModule, SENTUserContextDelegate, SENTDrivingInsightsReadyDelegate, SENTEventTimelineDelegate>
|
|
18
19
|
typedef void (^SdkStatusHandler)(SENTSDKStatus * _Nonnull status);
|
|
19
20
|
- (SENTUserLinker _Nonnull ) getUserLinker;
|
|
20
21
|
- (SdkStatusHandler _Nonnull) getSdkStatusUpdateHandler;
|
package/ios/RNSentianceCore.m
CHANGED
|
@@ -35,7 +35,7 @@ RCT_EXPORT_MODULE(SentianceCore)
|
|
|
35
35
|
|
|
36
36
|
- (NSArray<NSString *> *)supportedEvents
|
|
37
37
|
{
|
|
38
|
-
return @[SdkStatusUpdateEvent, TripTimeoutEvent, UserLinkEvent, UserActivityUpdateEvent, VehicleCrashEvent, VehicleCrashDiagnosticEvent, UserLinkEvent, UserContextUpdateEvent, DrivingInsightsReadyEvent];
|
|
38
|
+
return @[SdkStatusUpdateEvent, TripTimeoutEvent, UserLinkEvent, UserActivityUpdateEvent, VehicleCrashEvent, VehicleCrashDiagnosticEvent, UserLinkEvent, UserContextUpdateEvent, DrivingInsightsReadyEvent, TimelineUpdateEvent];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// Will be called when this module's first listener is added.
|
|
@@ -58,6 +58,10 @@ RCT_EXPORT_MODULE(SentianceCore)
|
|
|
58
58
|
[self sendEventWithName:DrivingInsightsReadyEvent body:[self convertDrivingInsights:insights]];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
- (void)onEventTimelineUpdateWithEvent:(SENTTimelineEvent * _Nonnull)event {
|
|
62
|
+
[self sendEventWithName:TimelineUpdateEvent body:[self convertEvent:event]];
|
|
63
|
+
}
|
|
64
|
+
|
|
61
65
|
- (instancetype)init
|
|
62
66
|
{
|
|
63
67
|
self = [super init];
|
|
@@ -70,6 +74,12 @@ RCT_EXPORT_MODULE(SentianceCore)
|
|
|
70
74
|
[[Sentiance sharedInstance] setDrivingInsightsReadyDelegate:nil];
|
|
71
75
|
} subscriptionType:SENTSubscriptionTypeSingle];
|
|
72
76
|
|
|
77
|
+
[_subscriptionsManager addSupportedSubscriptionForEventType:TimelineUpdateEvent nativeSubscribeLogic:^{
|
|
78
|
+
[[Sentiance sharedInstance] setEventTimelineDelegate:weakSelf];
|
|
79
|
+
} nativeUnsubscribeLogic:^{
|
|
80
|
+
[[Sentiance sharedInstance] setEventTimelineDelegate:nil];
|
|
81
|
+
} subscriptionType:SENTSubscriptionTypeSingle];
|
|
82
|
+
|
|
73
83
|
return self;
|
|
74
84
|
}
|
|
75
85
|
|
|
@@ -1094,6 +1104,49 @@ RCT_EXPORT_METHOD(removeNativeListener:(NSString *)eventName subscriptionId:(NSI
|
|
|
1094
1104
|
resolve(nil);
|
|
1095
1105
|
}
|
|
1096
1106
|
|
|
1107
|
+
RCT_EXPORT_METHOD(getTimelineEvent:(NSString *)eventId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
1108
|
+
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
1109
|
+
|
|
1110
|
+
SENTTimelineEvent* event = [[Sentiance sharedInstance] getTimelineEventWithEventId:eventId];
|
|
1111
|
+
if (event == nil) {
|
|
1112
|
+
resolve(nil);
|
|
1113
|
+
} else {
|
|
1114
|
+
resolve([self convertEvent:event]);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
RCT_EXPORT_METHOD(getTimelineUpdates:(nonnull NSNumber *)afterEpochTimeMs resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
1119
|
+
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
1120
|
+
|
|
1121
|
+
NSTimeInterval interval = afterEpochTimeMs.longValue / 1000.0;
|
|
1122
|
+
NSDate* date = [NSDate dateWithTimeIntervalSince1970:interval];
|
|
1123
|
+
NSArray<SENTTimelineEvent *>* events = [[Sentiance sharedInstance] getTimelineUpdatesAfter:date];
|
|
1124
|
+
|
|
1125
|
+
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
1126
|
+
for (SENTTimelineEvent* event in events) {
|
|
1127
|
+
[array addObject:[self convertEvent:event]];
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
resolve(array);
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
RCT_EXPORT_METHOD(getTimelineEvents:(nonnull NSNumber *)fromEpochTimeMs toEpochTimeMs:(nonnull NSNumber *)toEpochTimeMs resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
1134
|
+
REJECT_IF_SDK_NOT_INITIALIZED(reject);
|
|
1135
|
+
|
|
1136
|
+
NSTimeInterval fromInterval = fromEpochTimeMs.longValue / 1000.0;
|
|
1137
|
+
NSDate* fromDate = [NSDate dateWithTimeIntervalSince1970:fromInterval];
|
|
1138
|
+
NSTimeInterval toInterval = toEpochTimeMs.longValue / 1000.0;
|
|
1139
|
+
NSDate* toDate = [NSDate dateWithTimeIntervalSince1970:toInterval];
|
|
1140
|
+
NSArray<SENTTimelineEvent *>* events = [[Sentiance sharedInstance] getTimelineEventsFrom:fromDate to:toDate];
|
|
1141
|
+
|
|
1142
|
+
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
1143
|
+
for (SENTTimelineEvent* event in events) {
|
|
1144
|
+
[array addObject:[self convertEvent:event]];
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
resolve(array);
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1097
1150
|
- (void)didUpdateUserContext:(SENTUserContext *)userContext
|
|
1098
1151
|
forCriteriaMask:(SENTUserContextUpdateCriteria)criteriaMask {
|
|
1099
1152
|
NSDictionary *dict = @{
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentiance-react-native/core",
|
|
3
|
-
"version": "6.6.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "6.6.0",
|
|
4
|
+
"description": "The Sentiance Core library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"test": "
|
|
8
|
+
"test": "jest --verbose",
|
|
9
9
|
"lint": "npx eslint lib/index.d.ts"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"author": "",
|
|
20
20
|
"license": "",
|
|
21
|
-
"homepage": "https://github.com/sentiance/react-native-sentiance/
|
|
21
|
+
"homepage": "https://github.com/sentiance/react-native-sentiance/tree/main/packages/core",
|
|
22
22
|
"repository": "github:sentiance/react-native-sentiance",
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"targetSdk": 31,
|
|
30
30
|
"compileSdk": 31,
|
|
31
31
|
"buildTools": "30.0.3",
|
|
32
|
-
"sentiance": "6.6
|
|
32
|
+
"sentiance": "6.6.+"
|
|
33
33
|
},
|
|
34
34
|
"ios": {
|
|
35
|
-
"sentiance": "6.6.0
|
|
35
|
+
"sentiance": "~> 6.6.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
package/android/src/main/java/com/sentiance/react/bridge/core/common/SentianceCommonConverter.java
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
package com.sentiance.react.bridge.core.common;
|
|
2
|
-
|
|
3
|
-
import android.location.Location;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.bridge.Arguments;
|
|
6
|
-
import com.facebook.react.bridge.WritableMap;
|
|
7
|
-
|
|
8
|
-
public class SentianceCommonConverter {
|
|
9
|
-
|
|
10
|
-
public static WritableMap convertLocation(Location location) {
|
|
11
|
-
WritableMap locationMap = Arguments.createMap();
|
|
12
|
-
locationMap.putDouble("timestamp", location.getTime());
|
|
13
|
-
locationMap.putDouble("latitude", location.getLatitude());
|
|
14
|
-
locationMap.putDouble("longitude", location.getLongitude());
|
|
15
|
-
if (location.hasAccuracy()) {
|
|
16
|
-
locationMap.putDouble("accuracy", location.getAccuracy());
|
|
17
|
-
}
|
|
18
|
-
if (location.hasAltitude()) {
|
|
19
|
-
locationMap.putDouble("altitude", location.getAltitude());
|
|
20
|
-
}
|
|
21
|
-
locationMap.putString("provider", location.getProvider());
|
|
22
|
-
return locationMap;
|
|
23
|
-
}
|
|
24
|
-
}
|