@sentiance-react-native/user-context 6.0.0-beta.11 → 6.0.0-beta.14

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.
Files changed (2) hide show
  1. package/lib/user-context.js +16 -13
  2. package/package.json +2 -2
@@ -4,32 +4,35 @@ const {SentianceUserContext, SentianceCore} = NativeModules;
4
4
 
5
5
  const SDK_USER_CONTEXT_UPDATE_EVENT = "SENTIANCE_USER_CONTEXT_UPDATE_EVENT";
6
6
 
7
+ let didLocateNativeModule = true;
7
8
  var userContextModule
8
9
  if (Platform.OS === 'android') {
9
10
  if (!SentianceUserContext) {
11
+ didLocateNativeModule = false;
10
12
  const nativeModuleName = varToString({SentianceUserContext});
11
- throw `Could not locate the native ${nativeModuleName} module.
12
- 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.`);
13
15
  }
14
16
  userContextModule = SentianceUserContext
15
17
  } else {
16
18
  if (!SentianceCore) {
19
+ didLocateNativeModule = false;
17
20
  const nativeModuleName = varToString({SentianceCore});
18
- throw `Could not locate the native ${nativeModuleName} module.
19
- Make sure that your native code is properly linked, and that the module name you specified is correct.`;
21
+ console.error(`Could not locate the native ${nativeModuleName} module.
22
+ Make sure that your native code is properly linked, and that the module name you specified is correct.`);
20
23
  }
21
24
  userContextModule = SentianceCore
22
25
  }
23
26
 
24
- const SENTIANCE_EMITTER = new NativeEventEmitter(userContextModule);
27
+ if (didLocateNativeModule) {
28
+ const SENTIANCE_EMITTER = new NativeEventEmitter(userContextModule);
25
29
 
26
- const _addUserContextUpdateListener = async (onUserContextUpdated) => {
27
- await userContextModule.listenUserContextUpdates();
28
- return SENTIANCE_EMITTER.addListener(SDK_USER_CONTEXT_UPDATE_EVENT, (data) => {
29
- onUserContextUpdated(data);
30
- });
31
- };
32
-
33
- userContextModule._addUserContextUpdateListener = _addUserContextUpdateListener;
30
+ userContextModule._addUserContextUpdateListener = async (onUserContextUpdated) => {
31
+ await userContextModule.listenUserContextUpdates();
32
+ return SENTIANCE_EMITTER.addListener(SDK_USER_CONTEXT_UPDATE_EVENT, (data) => {
33
+ onUserContextUpdated(data);
34
+ });
35
+ };
36
+ }
34
37
 
35
38
  export default userContextModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentiance-react-native/user-context",
3
- "version": "6.0.0-beta.11",
3
+ "version": "6.0.0-beta.14",
4
4
  "description": "React Native Sentiance - This module provides an easy API to add user context awareness into your apps.",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "sentiance"
15
15
  ],
16
16
  "peerDependencies": {
17
- "@sentiance-react-native/core": "6.0.0-beta.11"
17
+ "@sentiance-react-native/core": "6.0.0-beta.14"
18
18
  },
19
19
  "author": "",
20
20
  "license": "",