@sentiance-react-native/user-context 6.0.0-beta.9 → 6.0.2
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/README.md
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
# Sentiance User Context module for React Native
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
npm i @sentiance-react-native/core
|
|
3
|
+
## Demo Application
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
```
|
|
5
|
+
https://github.com/sentiance/sample-apps-react-native
|
|
8
6
|
|
|
9
7
|
## Usage
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
You can import the entire contents of the package for use under a namespace of your choosing:
|
|
14
|
-
|
|
15
|
-
```javascript
|
|
16
|
-
import * as SentianceUserContext from "@sentiance-react-native/user-context";
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
or you can require specific functionality using named imports:
|
|
20
|
-
|
|
21
|
-
```javascript
|
|
22
|
-
import {
|
|
23
|
-
getUserContext,
|
|
24
|
-
listenUserContextUpdates
|
|
25
|
-
} from "@sentiance-react-native/user-context";
|
|
26
|
-
```
|
|
9
|
+
To use the user context SDK module, please visit the corresponding [API reference page.](https://docs.sentiance.com/sdk/api-reference/react-native/user-context)
|
package/android/build.gradle
CHANGED
|
@@ -15,6 +15,13 @@ if (findProject(':core')) {
|
|
|
15
15
|
throw new GradleException('Could not find the @sentiance-react-native/core package, have you installed it?')
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
android {
|
|
19
|
+
compileOptions {
|
|
20
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
21
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
18
25
|
apply from: "$coreProj.projectDir/package-json-reader.gradle"
|
|
19
26
|
apply from: "$coreProj.projectDir/sentiance-version-finder.gradle"
|
|
20
27
|
|
package/android/src/main/java/com/sentiance/react/bridge/usercontext/SentianceUserContextModule.java
CHANGED
|
@@ -71,4 +71,14 @@ public class SentianceUserContextModule extends AbstractSentianceModule {
|
|
|
71
71
|
userContextApi.addUserContextUpdateListener(mUserContextUpdateListener);
|
|
72
72
|
promise.resolve(true);
|
|
73
73
|
}
|
|
74
|
+
|
|
75
|
+
@ReactMethod
|
|
76
|
+
public void addListener(String eventName) {
|
|
77
|
+
// Set up any upstream listeners or background tasks as necessary
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@ReactMethod
|
|
81
|
+
public void removeListeners(Integer count) {
|
|
82
|
+
// Remove upstream listeners, stop unnecessary background tasks
|
|
83
|
+
}
|
|
74
84
|
}
|
package/lib/index.js
CHANGED
package/lib/user-context.js
CHANGED
|
@@ -4,32 +4,37 @@ const {SentianceUserContext, SentianceCore} = NativeModules;
|
|
|
4
4
|
|
|
5
5
|
const SDK_USER_CONTEXT_UPDATE_EVENT = "SENTIANCE_USER_CONTEXT_UPDATE_EVENT";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
let didLocateNativeModule = true;
|
|
8
|
+
let userContextModule = {};
|
|
8
9
|
if (Platform.OS === 'android') {
|
|
9
10
|
if (!SentianceUserContext) {
|
|
11
|
+
didLocateNativeModule = false;
|
|
10
12
|
const nativeModuleName = varToString({SentianceUserContext});
|
|
11
|
-
|
|
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.`);
|
|
15
|
+
} else {
|
|
16
|
+
userContextModule = SentianceUserContext
|
|
13
17
|
}
|
|
14
|
-
userContextModule = SentianceUserContext
|
|
15
18
|
} else {
|
|
16
19
|
if (!SentianceCore) {
|
|
20
|
+
didLocateNativeModule = false;
|
|
17
21
|
const nativeModuleName = varToString({SentianceCore});
|
|
18
|
-
|
|
19
|
-
Make sure that your native code is properly linked, and that the module name you specified is correct
|
|
22
|
+
console.error(`Could not locate the native ${nativeModuleName} module.
|
|
23
|
+
Make sure that your native code is properly linked, and that the module name you specified is correct.`);
|
|
24
|
+
} else {
|
|
25
|
+
userContextModule = SentianceCore
|
|
20
26
|
}
|
|
21
|
-
userContextModule = SentianceCore
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
if (didLocateNativeModule) {
|
|
30
|
+
const SENTIANCE_EMITTER = new NativeEventEmitter(userContextModule);
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
userContextModule._addUserContextUpdateListener = _addUserContextUpdateListener;
|
|
32
|
+
userContextModule._addUserContextUpdateListener = async (onUserContextUpdated) => {
|
|
33
|
+
await userContextModule.listenUserContextUpdates();
|
|
34
|
+
return SENTIANCE_EMITTER.addListener(SDK_USER_CONTEXT_UPDATE_EVENT, (data) => {
|
|
35
|
+
onUserContextUpdated(data);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
module.exports = userContextModule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentiance-react-native/user-context",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
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.
|
|
17
|
+
"@sentiance-react-native/core": "6.0.2"
|
|
18
18
|
},
|
|
19
19
|
"author": "",
|
|
20
20
|
"license": "",
|