@regantis-sdk/react-native-chat 0.1.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/README.md +157 -0
- package/RegantisReactNativeChat.podspec +17 -0
- package/android/build.gradle +24 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/technology/regantis/chat/RegantisChatNativeModule.java +244 -0
- package/android/src/main/java/technology/regantis/chat/RegantisChatPackage.java +28 -0
- package/index.d.ts +91 -0
- package/index.js +10 -0
- package/ios/RegantisChatNative.h +5 -0
- package/ios/RegantisChatNative.m +191 -0
- package/package.json +35 -0
- package/src/RegantisChat.js +539 -0
- package/src/client.js +630 -0
- package/src/defaults.js +43 -0
- package/src/native.js +56 -0
package/src/native.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { NativeModules, Platform } = require('react-native');
|
|
4
|
+
|
|
5
|
+
const native = NativeModules.RegantisChatNative || null;
|
|
6
|
+
const memory = new Map();
|
|
7
|
+
|
|
8
|
+
async function getItem(key) {
|
|
9
|
+
if (native && native.getItem) return native.getItem(String(key));
|
|
10
|
+
return memory.has(key) ? memory.get(key) : null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function setItem(key, value) {
|
|
14
|
+
if (native && native.setItem) return native.setItem(String(key), String(value));
|
|
15
|
+
memory.set(key, String(value));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function removeItem(key) {
|
|
19
|
+
if (native && native.removeItem) return native.removeItem(String(key));
|
|
20
|
+
memory.delete(key);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function getAppInfo() {
|
|
24
|
+
if (native && native.getAppInfo) return native.getAppInfo();
|
|
25
|
+
return { appId: '', appVersion: '', platform: Platform.OS };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function pickAttachment(kind) {
|
|
29
|
+
if (!native || !native.pickAttachment) {
|
|
30
|
+
throw new Error('NATIVE_PICKER_UNAVAILABLE');
|
|
31
|
+
}
|
|
32
|
+
return native.pickAttachment(kind === 'image' ? 'image' : 'file');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function captureScreenshot() {
|
|
36
|
+
if (!native || !native.captureScreenshot) {
|
|
37
|
+
throw new Error('NATIVE_SCREENSHOT_UNAVAILABLE');
|
|
38
|
+
}
|
|
39
|
+
return native.captureScreenshot();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function playIncomingSound() {
|
|
43
|
+
if (native && native.playIncomingSound) {
|
|
44
|
+
native.playIncomingSound();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
getItem,
|
|
50
|
+
setItem,
|
|
51
|
+
removeItem,
|
|
52
|
+
getAppInfo,
|
|
53
|
+
pickAttachment,
|
|
54
|
+
captureScreenshot,
|
|
55
|
+
playIncomingSound,
|
|
56
|
+
};
|