connect-x-reactnative-livechat-sdk 0.2.0 → 1.2.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,136 @@
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 into your React Native application for Connect X ticket. You need to config Live Chat connector from [Connect-X](https://app.connect-x.tech/) by navigating to: Organization Settings → Connector → Live Chat.
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
+ #or
32
+
33
+ yarn add socket.io-client @react-native-documents/picker react-native-svg react-native-image-zoom-viewer react-native-device-info
34
+ ```
35
+
36
+ ## 🚀 Usage
37
+
38
+ ### 1. Wrap Your App with `ChatProvider`
39
+
40
+ In your main application file (e.g., `App.tsx` or `index.js`), you must import `ChatProvider` and wrap your root component with it.
41
+
42
+ ```tsx
43
+ // App.tsx
44
+ import React from 'react';
45
+ import { View, Button, StyleSheet } from 'react-native';
46
+ import { ChatProvider, LiveChat } from 'connect-x-reactnative-livechat-sdk';
47
+
48
+ const AppContent = () => {
49
+ // ... Your app content
50
+ return (
51
+ <View style={styles.container}>
52
+ <Button
53
+ title="Open Live Chat"
54
+ onPress={() => {
55
+ LiveChat.show({
56
+ token: 'YOUR_AUTH_TOKEN',
57
+ orgId: 'YOUR_ORGANIZATION_ID',
58
+ channelId: 'YOUR_CHANNEL_ID',
59
+ externalValue: 'YOUR_EXTERNAL_VALUE',
60
+ });
61
+ }}
62
+ />
63
+ </View>
64
+ );
65
+ };
66
+
67
+ const App = () => {
68
+ return (
69
+ <ChatProvider>
70
+ <AppContent />
71
+ </ChatProvider>
72
+ );
73
+ };
74
+
75
+ const styles = StyleSheet.create({
76
+ container: {
77
+ flex: 1,
78
+ justifyContent: 'center',
79
+ alignItems: 'center',
80
+ },
81
+ });
82
+
83
+ export default App;
9
84
  ```
10
85
 
11
- ## Usage
86
+ ### 2. Showing the Chat Window
87
+
88
+ You can call `LiveChat.show()` from anywhere in your application to open the chat window.
89
+
90
+ ```javascript
91
+ import { LiveChat } from 'connect-x-reactnative-livechat-sdk';
12
92
 
93
+ LiveChat.show({
94
+ token: 'YOUR_AUTH_TOKEN',
95
+ orgId: 'YOUR_ORGANIZATION_ID',
96
+ channelId: 'YOUR_CHANNEL_ID',
97
+ externalValue: 'YOUR_EXTERNAL_VALUE',
98
+ customHeader: <YourCustomHeaderComponent />, // Optional
99
+ });
100
+ ```
101
+
102
+ ### 3. Hiding the Chat Window (If Needed)
13
103
 
14
- ```js
15
- import { multiply } from 'connect-x-reactnative-livechat-sdk';
104
+ You can programmatically call `LiveChat.hide()` to close the chat window (e.g., from a close button in a custom header).
16
105
 
17
- // ...
106
+ ```javascript
107
+ import { LiveChat } from 'connect-x-reactnative-livechat-sdk';
18
108
 
19
- const result = multiply(3, 7);
109
+ LiveChat.hide();
20
110
  ```
21
111
 
112
+ ---
113
+
114
+ ## 📖 API Reference
22
115
 
23
- ## Contributing
116
+ ### `LiveChat.show(config)`
24
117
 
25
- See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
118
+ A method to open the chat window. It accepts a `config` object with the following properties:
119
+
120
+ | Prop | Type | Required | Description |
121
+ | --------------- | ----------------- | -------- | ------------------------------------------------------------------------- |
122
+ | `token` | `string` | **Yes** | Authorization token for authentication from [Connect-X](https://app.connect-x.tech/) by navigating to: Organization Settings → SDK Tracking. |
123
+ | `orgId` | `string` | **Yes** | Your organization's ID. |
124
+ | `channelId` | `string` | **Yes** | The ID of the Live Chat channel. |
125
+ | `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. |
126
+ | `customHeader` | `React.ReactNode` | No | A React Component to render as a replacement for the default chat header. |
127
+
128
+ ---
26
129
 
27
- ## License
130
+ ## 📄 License
28
131
 
29
- MIT
132
+ [![Apache License](https://img.shields.io/badge/License-Apache-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
30
133
 
31
134
  ---
32
135
 
33
- Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
34
- # connect-x-reactnative-livechat-sdk
136
+ 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>