connect-x-reactnative-livechat-sdk 0.2.0 → 1.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 CHANGED
@@ -1,34 +1,132 @@
1
- # connect-x-reactnative-livechat-sdk
1
+ # ConnectX Live Chat SDK
2
2
 
3
- for Live Chat
3
+ An SDK for easily integrating the ConnectX Live Chat system into your React Native application.
4
4
 
5
- ## Installation
5
+ ## ✨ Features
6
6
 
7
- ```sh
7
+ * Displays a chat window as a modal over the main screen.
8
+ * Supports sending text messages, images, and document.
9
+ * Displays chat history with date partitions.
10
+ * Customizable styles and colors from from [Connect-X](https://app.connect-x.tech/) by navigating to: Organization Settings → Connector → Live Chat → Style.
11
+ * Supports custom header components.
12
+ * Image preview with zoom capabilities.
13
+
14
+ ## 🔧 Installation
15
+
16
+ ```bash
8
17
  npm install connect-x-reactnative-livechat-sdk
18
+
19
+ #or
20
+
21
+ yarn add connect-x-reactnative-livechat-sdk
22
+ ```
23
+
24
+ ### Additional Peer Dependencies
25
+
26
+ This library requires some peer dependencies. You need to install these libraries in your project as well:
27
+
28
+ ```bash
29
+ npm install socket.io-client @react-native-documents/picker react-native-svg react-native-image-zoom-viewer react-native-device-info
30
+ ```
31
+
32
+ ## 🚀 Usage
33
+
34
+ ### 1. Wrap Your App with `ChatProvider`
35
+
36
+ In your main application file (e.g., `App.tsx` or `index.js`), you must import `ChatProvider` and wrap your root component with it.
37
+
38
+ ```tsx
39
+ // App.tsx
40
+ import React from 'react';
41
+ import { View, Button, StyleSheet } from 'react-native';
42
+ import { ChatProvider, LiveChat } from 'connect-x-reactnative-livechat-sdk';
43
+
44
+ const AppContent = () => {
45
+ // ... Your app content
46
+ return (
47
+ <View style={styles.container}>
48
+ <Button
49
+ title="Open Live Chat"
50
+ onPress={() => {
51
+ LiveChat.show({
52
+ token: 'YOUR_AUTH_TOKEN',
53
+ orgId: 'YOUR_ORGANIZATION_ID',
54
+ channelId: 'YOUR_CHANNEL_ID',
55
+ externalValue: 'YOUR_EXTERNAL_VALUE',
56
+ });
57
+ }}
58
+ />
59
+ </View>
60
+ );
61
+ };
62
+
63
+ const App = () => {
64
+ return (
65
+ <ChatProvider>
66
+ <AppContent />
67
+ </ChatProvider>
68
+ );
69
+ };
70
+
71
+ const styles = StyleSheet.create({
72
+ container: {
73
+ flex: 1,
74
+ justifyContent: 'center',
75
+ alignItems: 'center',
76
+ },
77
+ });
78
+
79
+ export default App;
9
80
  ```
10
81
 
11
- ## Usage
82
+ ### 2. Showing the Chat Window
12
83
 
84
+ You can call `LiveChat.show()` from anywhere in your application to open the chat window.
85
+
86
+ ```javascript
87
+ import { LiveChat } from 'connect-x-reactnative-livechat-sdk';
88
+
89
+ LiveChat.show({
90
+ token: 'YOUR_AUTH_TOKEN',
91
+ orgId: 'YOUR_ORGANIZATION_ID',
92
+ channelId: 'YOUR_CHANNEL_ID',
93
+ externalValue: 'YOUR_EXTERNAL_VALUE',
94
+ customHeader: <YourCustomHeaderComponent />, // Optional
95
+ });
96
+ ```
13
97
 
14
- ```js
15
- import { multiply } from 'connect-x-reactnative-livechat-sdk';
98
+ ### 3. Hiding the Chat Window (If Needed)
16
99
 
17
- // ...
100
+ You can programmatically call `LiveChat.hide()` to close the chat window (e.g., from a close button in a custom header).
18
101
 
19
- const result = multiply(3, 7);
102
+ ```javascript
103
+ import { LiveChat } from 'connect-x-reactnative-livechat-sdk';
104
+
105
+ LiveChat.hide();
20
106
  ```
21
107
 
108
+ ---
109
+
110
+ ## 📖 API Reference
22
111
 
23
- ## Contributing
112
+ ### `LiveChat.show(config)`
24
113
 
25
- See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
114
+ A method to open the chat window. It accepts a `config` object with the following properties:
115
+
116
+ | Prop | Type | Required | Description |
117
+ | --------------- | ----------------- | -------- | ------------------------------------------------------------------------- |
118
+ | `token` | `string` | **Yes** | Authorization token for authentication from [Connect-X](https://app.connect-x.tech/) by navigating to: Organization Settings → SDK Tracking. |
119
+ | `orgId` | `string` | **Yes** | Your organization's ID. |
120
+ | `channelId` | `string` | **Yes** | The ID of the Live Chat channel. |
121
+ | `externalValue` | `string` | **Yes** | A value to identify the customer(Should be unique), You can setup external key from [Connect-X](https://app.connect-x.tech/) by navigating to: Organization Settings → Connector → Live Chat → Drop Form → Upsert Key. |
122
+ | `customHeader` | `React.ReactNode` | No | A React Component to render as a replacement for the default chat header. |
123
+
124
+ ---
26
125
 
27
- ## License
126
+ ## 📄 License
28
127
 
29
- MIT
128
+ [![Apache License](https://img.shields.io/badge/License-Apache-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
30
129
 
31
130
  ---
32
131
 
33
- Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
34
- # connect-x-reactnative-livechat-sdk
132
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -26,17 +26,17 @@ def getExtOrIntegerDefault(name) {
26
26
  }
27
27
 
28
28
  android {
29
- namespace "com.connectxreactnativelivechatsdk"
29
+ namespace = "com.connectxreactnativelivechatsdk"
30
30
 
31
- compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
31
+ compileSdkVersion = getExtOrIntegerDefault("compileSdkVersion")
32
32
 
33
33
  defaultConfig {
34
- minSdkVersion getExtOrIntegerDefault("minSdkVersion")
35
- targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
34
+ minSdkVersion = getExtOrIntegerDefault("minSdkVersion")
35
+ targetSdkVersion = getExtOrIntegerDefault("targetSdkVersion")
36
36
  }
37
37
 
38
38
  buildFeatures {
39
- buildConfig true
39
+ buildConfig = true
40
40
  }
41
41
 
42
42
  buildTypes {
@@ -80,4 +80,4 @@ react {
80
80
  jsRootDir = file("../src/")
81
81
  libraryName = "ConnectXReactnativeLivechatSdk"
82
82
  codegenJavaPackageName = "com.connectxreactnativelivechatsdk"
83
- }
83
+ }
@@ -1,2 +1,3 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
2
3
  </manifest>