@sentiance-react-native/core 6.0.0-beta.12 → 6.0.0-beta.15

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/lib/core.js CHANGED
@@ -7,50 +7,52 @@ const SDK_USER_LINK_EVENT = "SENTIANCE_USER_LINK_EVENT";
7
7
  const SDK_USER_ACTIVITY_UPDATE_EVENT = "SENTIANCE_USER_ACTIVITY_UPDATE_EVENT";
8
8
  const SDK_ON_TRIP_TIMED_OUT_EVENT = "SENTIANCE_ON_TRIP_TIMED_OUT_EVENT";
9
9
 
10
+ let coreModule = {};
10
11
  if (!SentianceCore) {
11
12
  const nativeModuleName = varToString({SentianceCore});
12
- throw `Could not locate the native ${nativeModuleName} module.
13
- Make sure that your native code is properly linked, and that the module name you specified is correct.`;
13
+ console.error(`Could not locate the native ${nativeModuleName} module.
14
+ Make sure that your native code is properly linked, and that the module name you specified is correct.`);
15
+ } else {
16
+ const SENTIANCE_EMITTER = new NativeEventEmitter(SentianceCore);
17
+
18
+ const _addSdkStatusUpdateListener = async (onSdkStatusUpdated) => {
19
+ await SentianceCore.listenSdkStatusUpdates();
20
+ return SENTIANCE_EMITTER.addListener(SDK_STATUS_UPDATE_EVENT, (sdkStatus) => {
21
+ onSdkStatusUpdated(sdkStatus);
22
+ });
23
+ };
24
+
25
+ const _addUserLinkListener = async (linker) => {
26
+ const subscription = SENTIANCE_EMITTER.addListener(SDK_USER_LINK_EVENT, async (data) => {
27
+ const {installId} = data;
28
+ const linkingResult = await linker(installId);
29
+ if (typeof linkingResult != "boolean") {
30
+ console.error('Expected linker result of type boolean, got: ' + typeof linkingResult);
31
+ SentianceCore.userLinkCallback(false);
32
+ } else {
33
+ SentianceCore.userLinkCallback(linkingResult);
34
+ }
35
+ subscription.remove();
36
+ });
37
+ };
38
+
39
+ const _addSdkUserActivityUpdateListener = async (onUserActivityUpdated) => {
40
+ await SentianceCore.listenUserActivityUpdates();
41
+ return SENTIANCE_EMITTER.addListener(SDK_USER_ACTIVITY_UPDATE_EVENT, (data) => {
42
+ onUserActivityUpdated(data);
43
+ });
44
+ };
45
+
46
+ const _addTripTimeoutListener = async (onTripTimedOut) => {
47
+ await SentianceCore.listenTripTimeout();
48
+ return SENTIANCE_EMITTER.addListener(SDK_ON_TRIP_TIMED_OUT_EVENT, onTripTimedOut);
49
+ };
50
+
51
+ SentianceCore._addSdkStatusUpdateListener = _addSdkStatusUpdateListener;
52
+ SentianceCore._addUserLinkListener = _addUserLinkListener;
53
+ SentianceCore._addSdkUserActivityUpdateListener = _addSdkUserActivityUpdateListener;
54
+ SentianceCore._addTripTimeoutListener = _addTripTimeoutListener;
55
+ coreModule = SentianceCore;
14
56
  }
15
57
 
16
- const SENTIANCE_EMITTER = new NativeEventEmitter(SentianceCore);
17
-
18
- const _addSdkStatusUpdateListener = async (onSdkStatusUpdated) => {
19
- await SentianceCore.listenSdkStatusUpdates();
20
- return SENTIANCE_EMITTER.addListener(SDK_STATUS_UPDATE_EVENT, (sdkStatus) => {
21
- onSdkStatusUpdated(sdkStatus);
22
- });
23
- };
24
-
25
- const _addUserLinkListener = async (linker) => {
26
- const subscription = SENTIANCE_EMITTER.addListener(SDK_USER_LINK_EVENT, async (data) => {
27
- const {installId} = data;
28
- const linkingResult = await linker(installId);
29
- if (typeof linkingResult != "boolean") {
30
- console.error('Expected linker result of type boolean, got: ' + typeof linkingResult);
31
- SentianceCore.userLinkCallback(false);
32
- } else {
33
- SentianceCore.userLinkCallback(linkingResult);
34
- }
35
- subscription.remove();
36
- });
37
- };
38
-
39
- const _addSdkUserActivityUpdateListener = async (onUserActivityUpdated) => {
40
- await SentianceCore.listenUserActivityUpdates();
41
- return SENTIANCE_EMITTER.addListener(SDK_USER_ACTIVITY_UPDATE_EVENT, (data) => {
42
- onUserActivityUpdated(data);
43
- });
44
- };
45
-
46
- const _addTripTimeoutListener = async (onTripTimedOut) => {
47
- await SentianceCore.listenTripTimeout();
48
- return SENTIANCE_EMITTER.addListener(SDK_ON_TRIP_TIMED_OUT_EVENT, onTripTimedOut);
49
- };
50
-
51
- SentianceCore._addSdkStatusUpdateListener = _addSdkStatusUpdateListener;
52
- SentianceCore._addUserLinkListener = _addUserLinkListener;
53
- SentianceCore._addSdkUserActivityUpdateListener = _addSdkUserActivityUpdateListener;
54
- SentianceCore._addTripTimeoutListener = _addTripTimeoutListener;
55
-
56
- export default SentianceCore;
58
+ export default coreModule;
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  declare module "sentiance-react-native-core" {
2
2
  import {EmitterSubscription} from "react-native";
3
3
 
4
+ export type DetectionStatus = "DISABLED" | "EXPIRED" | "ENABLED_BUT_BLOCKED" | "ENABLED_AND_DETECTING";
4
5
  export type LocationPermission = "ALWAYS" | "ONLY_WHILE_IN_USE" | "NEVER";
5
6
  export type SdkInitState =
6
7
  "NOT_INITIALIZED"
@@ -84,6 +85,7 @@ declare module "sentiance-react-native-core" {
84
85
 
85
86
  export interface SdkStatus {
86
87
  startStatus: string;
88
+ detectionStatus: DetectionStatus;
87
89
  canDetect: boolean;
88
90
  isRemoteEnabled: boolean;
89
91
  isAccelPresent: boolean;
@@ -109,7 +111,7 @@ declare module "sentiance-react-native-core" {
109
111
 
110
112
  export interface EnableDisableDetectionsResult {
111
113
  sdkStatus: SdkStatus,
112
- detectionStatus: string
114
+ detectionStatus: DetectionStatus
113
115
  }
114
116
 
115
117
  export interface SentianceCore {
package/lib/index.js CHANGED
@@ -43,8 +43,7 @@ if (Platform.OS === 'ios') {
43
43
  stopTrip = () => core.stopTripNewApi();
44
44
  submitDetections = () => core.submitDetectionsNewApi();
45
45
  reset = () => core.resetNewApi();
46
- }
47
- else {
46
+ } else {
48
47
  startTrip = (metadata, hint) => core.startTrip(metadata, hint);
49
48
  stopTrip = () => core.stopTrip();
50
49
  submitDetections = () => core.submitDetections();
@@ -81,7 +80,7 @@ const linkUser = async (linker) => {
81
80
  * }
82
81
  *
83
82
  * createUser(userCreationOptions);
84
- *
83
+ *
85
84
  * Or unlinked user with appId / appSecret (Not recommended)
86
85
  *
87
86
  * const userCreationOptions = {
@@ -118,7 +117,7 @@ const linkUser = async (linker) => {
118
117
  * }
119
118
  *
120
119
  * createUser(userCreationOptions);
121
- *
120
+ *
122
121
  * Or unlinked user with appId / appSecret (Not recommended)
123
122
  *
124
123
  * const userCreationOptions = {
@@ -143,16 +142,14 @@ const createUser = async (userCreationOptions) => {
143
142
 
144
143
  if (authCode) {
145
144
  return core.createLinkedUserWithAuthCode(authCode, platformUrl);
146
- }
147
- else if (linker) {
145
+ } else if (linker) {
148
146
  if (linker === NO_OP_LINKER) {
149
147
  return core.createUnlinkedUser(appId, appSecret, platformUrl);
150
148
  } else {
151
149
  await core._addUserLinkListener(linker);
152
150
  return core.createLinkedUser(appId, appSecret, platformUrl);
153
151
  }
154
- }
155
- else {
152
+ } else {
156
153
  return Promise.reject('Invalid userCreationOptions passed, no authcode or linker specified.');
157
154
  }
158
155
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentiance-react-native/core",
3
- "version": "6.0.0-beta.12",
3
+ "version": "6.0.0-beta.15",
4
4
  "description": "React Native Sentiance core library",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",