@tencent-rtc/mcp 1.0.1 → 1.0.3
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 +38 -37
- package/package.json +1 -1
- package/resource/doc/chatuikit/android/client_api_Android.md +1373 -0
- package/resource/doc/chatuikit/android/generate_UserSig.md +306 -0
- package/resource/doc/chatuikit/android/integrarte_only_tuichat_Android.md +290 -0
- package/resource/doc/chatuikit/android/integrate_tuikit_Android.md +287 -0
- package/resource/doc/chatuikit/android/quick_start_Android.md +138 -0
- package/resource/doc/chatuikit/android/show_typing_Android.md +43 -0
- package/resource/doc/chatuikit/faq/faq_sdk.md +120 -0
- package/resource/doc/chatuikit/faq/generate_UserSig.md +306 -0
- package/resource/doc/chatuikit/flutter/client_api_Flutter.md +932 -0
- package/resource/doc/chatuikit/flutter/generate_UserSig.md +306 -0
- package/resource/doc/chatuikit/flutter/integrate_only_tuichat_Flutter.md +333 -0
- package/resource/doc/chatuikit/flutter/integrate_tuikit_Flutter.md +769 -0
- package/resource/doc/chatuikit/flutter/quick_start_Flutter.md +217 -0
- package/resource/doc/chatuikit/iOS/client_api_iOS.md +1121 -0
- package/resource/doc/chatuikit/iOS/generate_UserSig.md +306 -0
- package/resource/doc/chatuikit/iOS/integrate_only_tuichat_iOS.md +748 -0
- package/resource/doc/chatuikit/iOS/integrate_tuikit_iOS.md +852 -0
- package/resource/doc/chatuikit/iOS/quick_start_iOS.md +163 -0
- package/resource/doc/chatuikit/iOS/show_typing_iOS.md +52 -0
- package/resource/doc/chatuikit/react/generate_UserSig.md +306 -0
- package/resource/doc/chatuikit/react/integrate_tuichat_only_react.md +202 -0
- package/resource/doc/chatuikit/react/integrate_tuichat_react.md +279 -0
- package/resource/doc/chatuikit/vue/generate_UserSig.md +306 -0
- package/resource/doc/chatuikit/vue/integrate_only_tuichat_Vue_web.md +124 -0
- package/resource/doc/chatuikit/vue/integrate_tuikit_Vue_web.md +552 -0
- package/resource/doc/tuicallkit/react/how_to_integrated_react_callkit.md +84 -55
- package/server.js +51 -27
- package/server.js.map +1 -1
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
This document outlines two authentication methods for Chat services, with a focus on UserSig, a security signature by Tencent Cloud to safeguard against unauthorized access. For basic cloud service usage, provide SDKAppID, UserID, and UserSig during SDK initialization or login.
|
|
2
|
+
- SDKAppID is used to identify your application.
|
|
3
|
+
|
|
4
|
+
- UserID is used to identify your user.
|
|
5
|
+
|
|
6
|
+
- UserSig is a security signature calculated based on the first two using the HMAC SHA256 encryption algorithm. As long as attackers cannot forge the UserSig, they cannot steal your cloud service traffic.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Obtaining a Key
|
|
10
|
+
1. Log in to the [Chat console](https://console.trtc.io/chat).
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
> **Note: **
|
|
14
|
+
>
|
|
15
|
+
|
|
16
|
+
> If you do not have any app, [create an app](https://intl.cloud.tencent.com/document/product/1047/45914) and then perform [step 2](https://write.woa.com/#step2).
|
|
17
|
+
>
|
|
18
|
+
|
|
19
|
+
2. Click the target app card to go to its basic configuration page.
|
|
20
|
+
|
|
21
|
+
3. In the **Basic Information** section, click **Display key** to the right of **Key**.
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
4. Click **Copy** to copy and save the key information.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
> **Note: **
|
|
29
|
+
>
|
|
30
|
+
|
|
31
|
+
> Store the key information properly to prevent disclosure.
|
|
32
|
+
>
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## Calculating UserSig on the Client
|
|
36
|
+
|
|
37
|
+
The `GenerateTestUserSig` open-source module provided in the sample code of the Chat SDK can help you quickly generate a UserSig. You only need to configure three member variables, including SDKAPPID (SDKAppID of the app), EXPIRETIME (UserSig expiration time), and SECRETKEY (key information), and then call the genTestUserSig() function to quickly obtain a UserSig.
|
|
38
|
+
|
|
39
|
+
To simplify this process, we provide the source code for computing a UserSig for the following languages and platforms. You can directly download and integrate the source code into your client.
|
|
40
|
+
<table>
|
|
41
|
+
<tr>
|
|
42
|
+
<td rowspan="1" colSpan="1" >Programing Language</td>
|
|
43
|
+
|
|
44
|
+
<td rowspan="1" colSpan="1" >Platform</td>
|
|
45
|
+
|
|
46
|
+
<td rowspan="1" colSpan="1" >GenerateTestUserSig Source Code</td>
|
|
47
|
+
</tr>
|
|
48
|
+
|
|
49
|
+
<tr>
|
|
50
|
+
<td rowspan="1" colSpan="1" >Java</td>
|
|
51
|
+
|
|
52
|
+
<td rowspan="1" colSpan="1" >Android</td>
|
|
53
|
+
|
|
54
|
+
<td rowspan="1" colSpan="1" >[GenerateTestUserSig.java](https://github.com/tencentyun/TIMSDK/blob/master/Android/Demo/app/src/main/java/com/tencent/qcloud/tim/demo/signature/GenerateTestUserSig.java)</td>
|
|
55
|
+
</tr>
|
|
56
|
+
|
|
57
|
+
<tr>
|
|
58
|
+
<td rowspan="1" colSpan="1" >Objective-C</td>
|
|
59
|
+
|
|
60
|
+
<td rowspan="1" colSpan="1" >iOS</td>
|
|
61
|
+
|
|
62
|
+
<td rowspan="1" colSpan="1" >[GenerateTestUserSig.h](https://github.com/tencentyun/TIMSDK/blob/master/iOS/Demo/TUIKitDemo/Private/GenerateTestUserSig.h)</td>
|
|
63
|
+
</tr>
|
|
64
|
+
|
|
65
|
+
<tr>
|
|
66
|
+
<td rowspan="1" colSpan="1" >Objective-C</td>
|
|
67
|
+
|
|
68
|
+
<td rowspan="1" colSpan="1" >Mac</td>
|
|
69
|
+
|
|
70
|
+
<td rowspan="1" colSpan="1" >[GenerateTestUserSig.h](https://github.com/tencentyun/TIMSDK/blob/master/Mac/Demo/TUIKitDemo/Debug/GenerateTestUserSig.h)</td>
|
|
71
|
+
</tr>
|
|
72
|
+
|
|
73
|
+
<tr>
|
|
74
|
+
<td rowspan="1" colSpan="1" >C++</td>
|
|
75
|
+
|
|
76
|
+
<td rowspan="1" colSpan="1" >Windows</td>
|
|
77
|
+
|
|
78
|
+
<td rowspan="1" colSpan="1" >[GenerateTestUserSig.h](https://github.com/tencentyun/TIMSDK/blob/master/Windows/Demo/IMApp/GenerateTestUserSig.h)</td>
|
|
79
|
+
</tr>
|
|
80
|
+
|
|
81
|
+
<tr>
|
|
82
|
+
<td rowspan="1" colSpan="1" >Javascript</td>
|
|
83
|
+
|
|
84
|
+
<td rowspan="1" colSpan="1" >Web</td>
|
|
85
|
+
|
|
86
|
+
<td rowspan="1" colSpan="1" >[GenerateTestUserSig.js](https://github.com/TencentCloud/chat-uikit-uniapp/blob/main/TUIKit/debug/GenerateTestUserSig.js)</td>
|
|
87
|
+
</tr>
|
|
88
|
+
|
|
89
|
+
<tr>
|
|
90
|
+
<td rowspan="1" colSpan="1" >Dart</td>
|
|
91
|
+
|
|
92
|
+
<td rowspan="1" colSpan="1" >Flutter</td>
|
|
93
|
+
|
|
94
|
+
<td rowspan="1" colSpan="1" >[GenerateTestUserSig.dart](https://github.com/TencentCloud/chat-demo-flutter/blob/main/lib/utils/GenerateTestUserSig.dart )</td>
|
|
95
|
+
</tr>
|
|
96
|
+
</table>
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
> **Note: **
|
|
100
|
+
>
|
|
101
|
+
|
|
102
|
+
> In this method, the `SECRETKEY` is vulnerable to decompilation and reverse engineering. Once your `SECRETKEY` is disclosed, attackers can steal your Tencent Cloud traffic. Therefore, **this method is only suitable for locally running a demo project and feature debugging**.
|
|
103
|
+
The correct way to issue a UserSig is to integrate the UserSig computing code into your server and provide app-oriented APIs. When UserSig is needed, your app will send a request to the business server to obtain a dynamic UserSig. For more information, see [How to Calculate UserSig](https://write.woa.com/#GeneratingdynamicUserSig).
|
|
104
|
+
>
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## Calculating UserSig on the Server
|
|
108
|
+
|
|
109
|
+
Generating a UserSig on the server provides maximum protection against the disclosure of the key used for calculating the UserSig. You only need to deploy the code for calculating the UserSig on your server and provide an app-oriented API. When a UserSig is needed, your app will send a request to the business server to obtain a dynamic UserSig.
|
|
110
|
+
To simplify this process, we provide the source code for calculating a UserSig for the following languages and platforms. You can directly download and integrate the source code into your server.
|
|
111
|
+
<table>
|
|
112
|
+
<tr>
|
|
113
|
+
<td rowspan="1" colSpan="1" >Programming Language</td>
|
|
114
|
+
|
|
115
|
+
<td rowspan="1" colSpan="1" >Key Function</td>
|
|
116
|
+
|
|
117
|
+
<td rowspan="1" colSpan="1" >Download URL</td>
|
|
118
|
+
</tr>
|
|
119
|
+
|
|
120
|
+
<tr>
|
|
121
|
+
<td rowspan="1" colSpan="1" >Java</td>
|
|
122
|
+
|
|
123
|
+
<td rowspan="1" colSpan="1" >HMAC-SHA256</td>
|
|
124
|
+
|
|
125
|
+
<td rowspan="1" colSpan="1" >[genSig](https://github.com/Tencent-RTC/tls-sig-api-v2-java/blob/main/src/main/java/com/tencentcloud/TLSSigAPIv2.java)</td>
|
|
126
|
+
</tr>
|
|
127
|
+
|
|
128
|
+
<tr>
|
|
129
|
+
<td rowspan="1" colSpan="1" >GO</td>
|
|
130
|
+
|
|
131
|
+
<td rowspan="1" colSpan="1" >HMAC-SHA256</td>
|
|
132
|
+
|
|
133
|
+
<td rowspan="1" colSpan="1" >[GenSig](https://github.com/Tencent-RTC/tls-sig-api-v2-golang/blob/main/tencentyun/TLSSigAPI.go)</td>
|
|
134
|
+
</tr>
|
|
135
|
+
|
|
136
|
+
<tr>
|
|
137
|
+
<td rowspan="1" colSpan="1" >PHP</td>
|
|
138
|
+
|
|
139
|
+
<td rowspan="1" colSpan="1" >HMAC-SHA256</td>
|
|
140
|
+
|
|
141
|
+
<td rowspan="1" colSpan="1" >[genSig](https://github.com/Tencent-RTC/tls-sig-api-v2-php/blob/main/src/TLSSigAPIv2.php)</td>
|
|
142
|
+
</tr>
|
|
143
|
+
|
|
144
|
+
<tr>
|
|
145
|
+
<td rowspan="1" colSpan="1" >Nodejs</td>
|
|
146
|
+
|
|
147
|
+
<td rowspan="1" colSpan="1" >HMAC-SHA256</td>
|
|
148
|
+
|
|
149
|
+
<td rowspan="1" colSpan="1" >[genSig](https://github.com/Tencent-RTC/tls-sig-api-v2-node/blob/main/TLSSigAPIv2.js)</td>
|
|
150
|
+
</tr>
|
|
151
|
+
|
|
152
|
+
<tr>
|
|
153
|
+
<td rowspan="1" colSpan="1" >Python</td>
|
|
154
|
+
|
|
155
|
+
<td rowspan="1" colSpan="1" >HMAC-SHA256</td>
|
|
156
|
+
|
|
157
|
+
<td rowspan="1" colSpan="1" >[gen_sig](https://github.com/Tencent-RTC/tls-sig-api-v2-python/blob/main/TLSSigAPIv2.py)</td>
|
|
158
|
+
</tr>
|
|
159
|
+
|
|
160
|
+
<tr>
|
|
161
|
+
<td rowspan="1" colSpan="1" >C#</td>
|
|
162
|
+
|
|
163
|
+
<td rowspan="1" colSpan="1" >HMAC-SHA256</td>
|
|
164
|
+
|
|
165
|
+
<td rowspan="1" colSpan="1" >[GenSig](https://github.com/Tencent-RTC/tls-sig-api-v2-cs/blob/main/tls-sig-api-v2-cs/TLSSigAPIv2.cs)</td>
|
|
166
|
+
</tr>
|
|
167
|
+
|
|
168
|
+
<tr>
|
|
169
|
+
<td rowspan="1" colSpan="1" >C++</td>
|
|
170
|
+
|
|
171
|
+
<td rowspan="1" colSpan="1" >HMAC-SHA256</td>
|
|
172
|
+
|
|
173
|
+
<td rowspan="1" colSpan="1" >[gen_sig](https://github.com/Tencent-RTC/tls-sig-api-v2-cpp)</td>
|
|
174
|
+
</tr>
|
|
175
|
+
</table>
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
Key fields in a UserSig calculation function include the SDKAppID, UserID, and UserSig validity period, as described in the following table.
|
|
179
|
+
|
|
180
|
+
> **Note: **
|
|
181
|
+
>
|
|
182
|
+
|
|
183
|
+
> The following table uses the field names in the Java source code as an example. The field names may be different in other languages.
|
|
184
|
+
>
|
|
185
|
+
|
|
186
|
+
<table>
|
|
187
|
+
<tr>
|
|
188
|
+
<td rowspan="1" colSpan="1" >Field Name (Example)</td>
|
|
189
|
+
|
|
190
|
+
<td rowspan="1" colSpan="1" >Description</td>
|
|
191
|
+
</tr>
|
|
192
|
+
|
|
193
|
+
<tr>
|
|
194
|
+
<td rowspan="1" colSpan="1" >sdkappid</td>
|
|
195
|
+
|
|
196
|
+
<td rowspan="1" colSpan="1" >SDKAppID of the app. You can obtain the SDKAppID on the app card in the [Chat console](https://console.trtc.io/chat).</td>
|
|
197
|
+
</tr>
|
|
198
|
+
|
|
199
|
+
<tr>
|
|
200
|
+
<td rowspan="1" colSpan="1" >userId</td>
|
|
201
|
+
|
|
202
|
+
<td rowspan="1" colSpan="1" >User ID (former name: `Identifier`).</td>
|
|
203
|
+
</tr>
|
|
204
|
+
|
|
205
|
+
<tr>
|
|
206
|
+
<td rowspan="1" colSpan="1" >expire</td>
|
|
207
|
+
|
|
208
|
+
<td rowspan="1" colSpan="1" >UserSig validity period, in seconds.</td>
|
|
209
|
+
</tr>
|
|
210
|
+
|
|
211
|
+
<tr>
|
|
212
|
+
<td rowspan="1" colSpan="1" >userbuf</td>
|
|
213
|
+
|
|
214
|
+
<td rowspan="1" colSpan="1" >This field is set to `null` by default because APIs without UserBuf are used in Chat by default.APIs with UserBuf may be required in some TRTC use cases, for example, when entering a room. For more information, see [Enabling Advanced Permission Control](https://intl.cloud.tencent.com/document/product/647/35157).</td>
|
|
215
|
+
</tr>
|
|
216
|
+
|
|
217
|
+
<tr>
|
|
218
|
+
<td rowspan="1" colSpan="1" >key</td>
|
|
219
|
+
|
|
220
|
+
<td rowspan="1" colSpan="1" >Key. You can obtain a key on the app details page in the [Chat console](https://console.trtc.io/chat). For more information, see [Obtaining a Key](https://write.woa.com/#getkey).</td>
|
|
221
|
+
</tr>
|
|
222
|
+
</table>
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
## Old Version of Algorithm
|
|
226
|
+
|
|
227
|
+
To simplify signature computing so that customers can conveniently and quickly use Tencent Cloud services, the signature algorithm of the Chat service has been upgraded from ECDSA-SHA256 to HMAC-SHA256 since July 19, 2019. This means that all SDKAppIDs created after July 19, 2019 will use the new HMAC-SHA256 algorithm.
|
|
228
|
+
|
|
229
|
+
If your SDKAppID was created before July 19, 2019, we recommend that you upgrade the signature algorithm to [HMAC-SHA256](https://write.woa.com/#GeneratingdynamicUserSig). The upgrade will not affect your business. Alternatively, you can still use the signature algorithm of an earlier version. The URLs for downloading the source code for the ECDSA-SHA256 algorithm are as follows:
|
|
230
|
+
<table>
|
|
231
|
+
<tr>
|
|
232
|
+
<td rowspan="1" colSpan="1" >Programming Language</td>
|
|
233
|
+
|
|
234
|
+
<td rowspan="1" colSpan="1" >Signature Algorithm</td>
|
|
235
|
+
|
|
236
|
+
<td rowspan="1" colSpan="1" >Download Link</td>
|
|
237
|
+
</tr>
|
|
238
|
+
|
|
239
|
+
<tr>
|
|
240
|
+
<td rowspan="1" colSpan="1" >Java</td>
|
|
241
|
+
|
|
242
|
+
<td rowspan="1" colSpan="1" >ECDSA-SHA256</td>
|
|
243
|
+
|
|
244
|
+
<td rowspan="1" colSpan="1" >[GitHub](https://github.com/tencentyun/tls-sig-api-java)</td>
|
|
245
|
+
</tr>
|
|
246
|
+
|
|
247
|
+
<tr>
|
|
248
|
+
<td rowspan="1" colSpan="1" >GO</td>
|
|
249
|
+
|
|
250
|
+
<td rowspan="1" colSpan="1" >ECDSA-SHA256</td>
|
|
251
|
+
|
|
252
|
+
<td rowspan="1" colSpan="1" >[GitHub](https://github.com/tencentyun/tls-sig-api-golang)</td>
|
|
253
|
+
</tr>
|
|
254
|
+
|
|
255
|
+
<tr>
|
|
256
|
+
<td rowspan="1" colSpan="1" >PHP</td>
|
|
257
|
+
|
|
258
|
+
<td rowspan="1" colSpan="1" >ECDSA-SHA256</td>
|
|
259
|
+
|
|
260
|
+
<td rowspan="1" colSpan="1" >[GitHub](https://github.com/tencentyun/tls-sig-api-php)</td>
|
|
261
|
+
</tr>
|
|
262
|
+
|
|
263
|
+
<tr>
|
|
264
|
+
<td rowspan="1" colSpan="1" >Nodejs</td>
|
|
265
|
+
|
|
266
|
+
<td rowspan="1" colSpan="1" >ECDSA-SHA256</td>
|
|
267
|
+
|
|
268
|
+
<td rowspan="1" colSpan="1" >[GitHub](https://github.com/tencentyun/tls-sig-api-node)</td>
|
|
269
|
+
</tr>
|
|
270
|
+
|
|
271
|
+
<tr>
|
|
272
|
+
<td rowspan="1" colSpan="1" >Python</td>
|
|
273
|
+
|
|
274
|
+
<td rowspan="1" colSpan="1" >ECDSA-SHA256</td>
|
|
275
|
+
|
|
276
|
+
<td rowspan="1" colSpan="1" >[GitHub](https://github.com/tencentyun/tls-sig-api-python)</td>
|
|
277
|
+
</tr>
|
|
278
|
+
|
|
279
|
+
<tr>
|
|
280
|
+
<td rowspan="1" colSpan="1" >C#</td>
|
|
281
|
+
|
|
282
|
+
<td rowspan="1" colSpan="1" >ECDSA-SHA256</td>
|
|
283
|
+
|
|
284
|
+
<td rowspan="1" colSpan="1" >[GitHub](https://github.com/tencentyun/tls-sig-api-cs)</td>
|
|
285
|
+
</tr>
|
|
286
|
+
|
|
287
|
+
<tr>
|
|
288
|
+
<td rowspan="1" colSpan="1" >C++</td>
|
|
289
|
+
|
|
290
|
+
<td rowspan="1" colSpan="1" >ECDSA-SHA256</td>
|
|
291
|
+
|
|
292
|
+
<td rowspan="1" colSpan="1" >[GitHub](https://github.com/tencentyun/tls-sig-api)</td>
|
|
293
|
+
</tr>
|
|
294
|
+
</table>
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
## Get UserSig from the console
|
|
298
|
+
- Log in to Tencent-RTC Console, navigate to Development Tools > [UserSig Tools](https://console.trtc.io/usersig).
|
|
299
|
+
|
|
300
|
+
- Under the UserSig Generation Tool, select the corresponding SDKAppID and UserID.
|
|
301
|
+
|
|
302
|
+
- Click the Generate button to compute the corresponding UserSig.
|
|
303
|
+
|
|
304
|
+

|
|
305
|
+
|
|
306
|
+
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
Flutter Chat UIKit is designed to provide developers with a comprehensive set of tools to create feature-rich chat applications with ease.
|
|
2
|
+
|
|
3
|
+
It is built with a modular approach, allowing you to choose the components you need while keeping your application lightweight and efficient.
|
|
4
|
+
|
|
5
|
+
Among them, the `TencentCloudChatMessage` component offers both private messaging (1V1) and group chat features. It supports a variety of operations on messages, such as sending different types of messages, long-pressing to reply or quote messages, and querying details of read receipts.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
【Mobile】
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
【Desktop & Tablet】
|
|
16
|
+
|
|
17
|
+
**Light**
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
**Dark**
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
1. **Personalized Appearance**: With built-in dark and light modes, the UIKit offers a variety of theme and appearance customization options to meet your business needs.
|
|
31
|
+
|
|
32
|
+
2. **Multi-Platform Compatibility**: The adaptable single codebase ensures compatibility across various platforms, including **mobile** devices (iOS/Android), **tablets** (iPad and Android tablets), **web** browsers, and **desktop** environments (Windows/macOS).
|
|
33
|
+
|
|
34
|
+
3. **Localization Support**: Developed with native English and other language options, including Arabic, Japanese, Korean, Simplified Chinese, and Traditional Chinese. The internationalization features ensure a localized user interface in these languages and support customization and addition of languages, with Arabic featuring support for **RTL** UI.
|
|
35
|
+
|
|
36
|
+
4. **Enhanced Performance**: The UIKit offers improved performance for message lists, optimized memory usage, and precise message positioning capabilities, catering to scenarios with a large volume of messages and navigation to older messages.
|
|
37
|
+
|
|
38
|
+
5. **Advanced Features**: The UIKit boasts numerous advanced capabilities, including continuous voice message playback, enhanced multimedia and file message experiences, and intuitive left-right swipe gestures to preview multimedia messages.
|
|
39
|
+
|
|
40
|
+
6. **Refined User Experience**: Delicate enhancements such as rich animations, haptic feedback, and a polished interface contribute to improved user experiences. New features like grid-style avatars, redesigned forwarding panels, group member selectors, and enhanced long-press message menus further enrich the experiences.
|
|
41
|
+
|
|
42
|
+
7. **Modular Design**: Components are organized into modular packages, allowing for selective imports and reducing unnecessary bloat. Each package supports built-in navigation transitions, streamlining development and integration by automatically handling transitions, such as those between conversations and messages.
|
|
43
|
+
|
|
44
|
+
8. **Developer-Friendly Approach**: A more unified and standardized design of component parameters, clearer code naming conventions, and detailed comments, combined with the flexibility to choose between global or instance-level configuration management, make development easier and more efficient.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Compatibility
|
|
48
|
+
|
|
49
|
+
Our UIKit supports **mobile**, **tablet**, and **desktop** UI designs, and is compatible with Android, iOS, macOS, Windows, and Web (will be supported in future versions).
|
|
50
|
+
|
|
51
|
+
It comes with built-in support for English, Simplified Chinese, Traditional Chinese, Japanese, Korean, and Arabic (with support for Arabic RTL interface), and both light and dark appearance modes.
|
|
52
|
+
|
|
53
|
+
## Requirements
|
|
54
|
+
- Flutter version: 3.24 or above
|
|
55
|
+
|
|
56
|
+
- Dart version: 3.0 or above
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## Quick Start
|
|
60
|
+
|
|
61
|
+
### Importing Packages
|
|
62
|
+
|
|
63
|
+
#### Base Package
|
|
64
|
+
|
|
65
|
+
To start using our UIKit, first import the base package, tencent_cloud_chat_common.
|
|
66
|
+
``` plaintext
|
|
67
|
+
flutter pub add tencent_cloud_chat
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### Modular Component Packages
|
|
71
|
+
|
|
72
|
+
Next, import the modular UI component package for message chat, tencent_cloud_chat_message:
|
|
73
|
+
``` plaintext
|
|
74
|
+
flutter pub add tencent_cloud_chat_message
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
> **Platform Integration**
|
|
79
|
+
>
|
|
80
|
+
|
|
81
|
+
> Before proceeding to the Basic Usage section, make sure to complete the integration of additional platforms following the steps outlined here, especially if you are targeting these specific platforms for deployment.
|
|
82
|
+
>
|
|
83
|
+
> - **Web / macOS: **If you plan to deploy your project on ***Web*** or ***macOS*** platforms, see [Expanding to More Platforms](https://www.tencentcloud.com/document/product/1047/45907#more).
|
|
84
|
+
> - **iOS:** Open `ios/Podfile`, and replace the final section with the following content.
|
|
85
|
+
> `post_install do |installer|`
|
|
86
|
+
> ` installer.pods_project.targets.each do |target|`
|
|
87
|
+
> ` flutter_additional_ios_build_settings(target)`
|
|
88
|
+
> ` target.build_configurations.each do |config| `
|
|
89
|
+
> ` config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64' `
|
|
90
|
+
> ` config.build_settings['ENABLE_BITCODE'] = 'NO' `
|
|
91
|
+
> ` config.build_settings["ONLY_ACTIVE_ARCH"] = "NO" `
|
|
92
|
+
> ` end`
|
|
93
|
+
> ` target.build_configurations.each do |config|`
|
|
94
|
+
> ` config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [`
|
|
95
|
+
> ` '$(inherited)',`
|
|
96
|
+
> ` 'PERMISSION_MICROPHONE=1',`
|
|
97
|
+
> ` 'PERMISSION_CAMERA=1',`
|
|
98
|
+
> ` 'PERMISSION_PHOTOS=1',`
|
|
99
|
+
> ` ]`
|
|
100
|
+
> ` end`
|
|
101
|
+
> ` end`
|
|
102
|
+
> `end`
|
|
103
|
+
> - **Android / Windows: **No additional actions required.
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
### Initializing UIKit
|
|
107
|
+
|
|
108
|
+
Before you start using each modular package UI component, there are some initial setup steps you need to follow in your project.
|
|
109
|
+
1. Prepare the necessary Chat configuration information, such as sdkappid, test userID, and userSig. For more details, see [Prerequisites](https://www.tencentcloud.com/document/product/1047/45907#.E5.89.8D.E5.BA.8F.E5.B7.A5.E4.BD.9C).
|
|
110
|
+
|
|
111
|
+
2. **Install Packages:**
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
In your Flutter project, install the main package and the optional modular packages mentioned in the Quick Start section.
|
|
115
|
+
|
|
116
|
+
3. **Global Configurations:**
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
Import `TencentCloudChatMaterialApp`: Replace your project's `MaterialApp` with `TencentCloudChatMaterialApp`. This enables automatic management and configurations of the language, theme *(with material3)*, theme mode, and other settings. It ensures that the UIKit's interface parameters are consistent with your project.
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
This step will take over the language, theme, and theme mode configurations of your project. If you do not want the automatic management of configurations for your project, you can manually import the features you need into your project according to the **following guide**.
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
#### Implementing Global Configurations for UIKit Manually
|
|
132
|
+
|
|
133
|
+
It is recommended to replace your project's `MaterialApp` with `TencentCloudChatMaterialApp`. This enables automatic management of global configurations, including localization, theme, and theme mode.
|
|
134
|
+
|
|
135
|
+
However, if you want to retain your project's `MaterialApp` due to extensive customization or the use of other packages such as `Get`, you can manually initialize the UIKit. This guide will help you complete the process.
|
|
136
|
+
|
|
137
|
+
In the global configurations, localization is required, while the theme and theme mode settings are optional. Let us get started.
|
|
138
|
+
|
|
139
|
+
##### Required Configurations
|
|
140
|
+
- *Localization*
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
First, import the localization tools into your app's entry file.
|
|
144
|
+
``` java
|
|
145
|
+
import 'package:tencent_cloud_chat_intl/localizations/tencent_cloud_chat_localizations.dart';
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Next, add the localization configurations to `MaterialApp` or another entry provided by third-party packages like `GetMaterialApp`.
|
|
149
|
+
``` plaintext
|
|
150
|
+
MaterialApp(
|
|
151
|
+
localizationsDelegates: const [
|
|
152
|
+
/// Your configurations
|
|
153
|
+
GlobalMaterialLocalizations.delegate,
|
|
154
|
+
|
|
155
|
+
/// Add this line
|
|
156
|
+
...TencentCloudChatLocalizations.localizationsDelegates, /// Add this line
|
|
157
|
+
],
|
|
158
|
+
supportedLocales: [
|
|
159
|
+
/// Your configurations
|
|
160
|
+
...S.delegate.supportedLocales,
|
|
161
|
+
|
|
162
|
+
/// Add this line
|
|
163
|
+
...TencentCloudChatLocalizations.supportedLocales,
|
|
164
|
+
],
|
|
165
|
+
/// ... Other configurations
|
|
166
|
+
)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Additionally, you can set the language region `locale` according to your business logic, such as recording the user-specified language upon app's launch, instead of following the system settings. This configuration will apply to both your project and the Chat UIKit.
|
|
170
|
+
|
|
171
|
+
For more information of customizing localization, including adding or removing languages, adding the localization entry, and modifying translation words, see [Internationalization](https://trtc.io/document/52154?platform=flutter&product=chat&menulabel=uikit).
|
|
172
|
+
|
|
173
|
+
##### Optional Configurations
|
|
174
|
+
- *Theme / Theme Mode*
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
The UIKit's theme data, defined by the `TencentCloudChatTheme` class, is globally maintained and managed through `TencentCloudChat.dataInstance.theme`.
|
|
178
|
+
``` dart
|
|
179
|
+
TencentCloudChatTheme theme = TencentCloudChat.dataInstance.theme;
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
This theme instance includes a theme model (including the theme data for both light and dark modes) and brightness (the light and dark mode status).
|
|
183
|
+
|
|
184
|
+
Furthermore, you can specify the `theme` and `darkTheme` from `MaterialApp` using the Material 3 style theme data that we provide for both light and dark modes. You can also set the `themeMode` status based on the brightness status we maintain. This ensures a consistent appearance across your application and our Chat UIKit and enhances the user experiences. (You can customize this theme style as described below.)
|
|
185
|
+
|
|
186
|
+
To achieve this, we recommend converting your entry widget (which hosts the `MaterialApp`) into a `StatefulWidget`. Add a `TencentCloudChatTheme theme` as part of its state, and listen to `Stream<TencentCloudChatTheme>? themeDataListener` to update its value and build the app based on dynamic, and customizable theme data. Here is the sample code:
|
|
187
|
+
``` dart
|
|
188
|
+
// Theme instance for the Chat UIKit
|
|
189
|
+
TencentCloudChatTheme theme = TencentCloudChat.dataInstance.theme;
|
|
190
|
+
|
|
191
|
+
// Listener for theme data changes
|
|
192
|
+
Stream<TencentCloudChatTheme>? themeDataListener = TencentCloudChat.eventBusInstance.on<TencentCloudChatTheme>();
|
|
193
|
+
|
|
194
|
+
// Callback for handling theme data changes
|
|
195
|
+
void _themeDataChangeCallback(TencentCloudChatTheme themeData) {
|
|
196
|
+
setState(() {
|
|
197
|
+
theme = themeData;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Adds a listener for theme data changes
|
|
202
|
+
void _addThemeDataChangeListener() {
|
|
203
|
+
themeDataListener?.listen(
|
|
204
|
+
_themeDataChangeCallback,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@override
|
|
209
|
+
void initState() {
|
|
210
|
+
super.initState();
|
|
211
|
+
_addThemeDataChangeListener();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// .......
|
|
215
|
+
|
|
216
|
+
return MaterialApp(
|
|
217
|
+
themeMode: theme.brightness != null ? (theme.brightness == Brightness.light ? ThemeMode.light : ThemeMode.dark) : null,
|
|
218
|
+
theme: theme.getThemeData(brightness: Brightness.light),
|
|
219
|
+
darkTheme: theme.getThemeData(brightness: Brightness.dark),
|
|
220
|
+
/// ... Other configurations
|
|
221
|
+
);
|
|
222
|
+
```
|
|
223
|
+
- To customize the theme for the Chat UIKit appearance and the global theme (if specified in `MaterialApp` as shown above), use the `TencentCloudChatCoreController.setThemeColors` method to specify the appearance colors for both light and dark modes. For specific usage instructions, see the comments in the code.
|
|
224
|
+
|
|
225
|
+
- To switch the theme mode (brightness), use `TencentCloudChatCoreController.setBrightnessMode` or `TencentCloudChatCoreController.toggleBrightnessMode`. For specific usage instructions, see the comments in the code.
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
1. **Initialization and Log-in**:
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
Call the `TencentCloudChat.controller.initUIKit` method to initialize and log in. The call instructions and reference code are as follows:
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
> **Note:**
|
|
235
|
+
>
|
|
236
|
+
|
|
237
|
+
> We highly recommend configuring the `callbacks` to efficiently handle SDK API errors and specific UIKit events that require user attention through `Dialog` or `Tooltip` in a customizable way.
|
|
238
|
+
>
|
|
239
|
+
|
|
240
|
+
``` java
|
|
241
|
+
await TencentCloudChat.controller.initUIKit(
|
|
242
|
+
config: TencentCloudChatConfig(), /// [Optional]: The global configurations that affecting the whole chat interface, including user configurations and theme configurations.
|
|
243
|
+
options: TencentCloudChatInitOptions(
|
|
244
|
+
sdkAppID: , /// [Required]: The SDKAppID of your Tencent Cloud chat application.
|
|
245
|
+
userID: , /// [Required]: The userID of the logged-in user.
|
|
246
|
+
userSig: , /// [Required]: The userSig of the logged-in user.
|
|
247
|
+
),
|
|
248
|
+
|
|
249
|
+
components: TencentCloudChatInitComponentsRelated( /// [Required]: Modular UI component settings, effective globally.
|
|
250
|
+
usedComponentsRegister: [
|
|
251
|
+
/// [Required]: List of registration functions for the components used in the chat interface.
|
|
252
|
+
/// Simply use the `register` from TencentCloudChatMessage.
|
|
253
|
+
TencentCloudChatMessageManager.register,
|
|
254
|
+
],
|
|
255
|
+
componentConfigs: TencentCloudChatComponentConfigs(
|
|
256
|
+
/// [Optional]: Provide custom configurations for each UI modular component here. These builders will be applied globally.
|
|
257
|
+
),
|
|
258
|
+
componentBuilders: TencentCloudChatComponentBuilders(
|
|
259
|
+
/// [Optional]: Provide custom UI builders for each UI modular component here. These builders will be applied globally.
|
|
260
|
+
),
|
|
261
|
+
componentEventHandlers: TencentCloudChatComponentEventHandlers(
|
|
262
|
+
/// [Optional]: Provide custom event handlers for UI component events here. These builders will be applied globally.
|
|
263
|
+
),
|
|
264
|
+
),
|
|
265
|
+
|
|
266
|
+
/// [Critical]: It is strongly recommended to incorporate the following callback listeners for effectively managing SDK events, SDK API errors and specific UIKit events that require user attention.
|
|
267
|
+
/// For detailed usage, see the Integrating UIKit Callbacks section at the end of this README document.
|
|
268
|
+
callbacks: TencentCloudChatCallbacks(
|
|
269
|
+
onTencentCloudChatSDKEvent: V2TimSDKListener(), /// [Optional]: Handles SDK events, such as onKickedOffline and onUserSigExpired.
|
|
270
|
+
onTencentCloudChatSDKFailCallback: (apiName, code, desc) {}, /// [Optional]: Handles SDK API errors.
|
|
271
|
+
onTencentCloudChatUIKitUserNotificationEvent: (TencentCloudChatComponentsEnum component, TencentCloudChatUserNotificationEvent event) {}, /// [Optional]: Handles specific UIKit events that require user attention on a global scale.across the entire application scope.
|
|
272
|
+
),
|
|
273
|
+
|
|
274
|
+
plugins: [], /// [Optional]: Used plugins, such as tencent_cloud_chat_robot. For specific usage, see the README document of each plugin.
|
|
275
|
+
);
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Initiating a Chat
|
|
279
|
+
|
|
280
|
+
Chat UIKit offers a comprehensive solution for creating a chat module for users.
|
|
281
|
+
|
|
282
|
+
By directing to the `TencentCloudChatMessage` with the specified chat user options, you can seamlessly set up a chat module for them. This caters to both one-on-one and group chats.
|
|
283
|
+
|
|
284
|
+
#### Automatically navigate to the message component.
|
|
285
|
+
|
|
286
|
+
With the built-in auto-navigation feature, initiating a chat can be easily achieved by calling the `navigateToMessage` method with `TencentCloudChatMessageOptions`, as shown below:
|
|
287
|
+
``` dart
|
|
288
|
+
final messageOptions = TencentCloudChatMessageOptions(
|
|
289
|
+
// Provide either userID or groupID to indicate the conversation for the chat.
|
|
290
|
+
userID: "", // For one-on-one chats, provide the other user's userID.
|
|
291
|
+
groupID: "", // For group chats, provide the groupID.
|
|
292
|
+
);
|
|
293
|
+
/// Use the messageOptions constructed above.
|
|
294
|
+
navigateToMessage(context: context, options: messageOptions);
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
By offering either a userID or groupID, the chat conversation can be effortlessly initiated for one-on-one or group chats.
|
|
298
|
+
|
|
299
|
+
#### Manually Navigating to the Message Component
|
|
300
|
+
|
|
301
|
+
If you need to manually handle navigation, or wrap the component within your custom pages, then you should instantiate a `TencentCloudChatMessage` component.
|
|
302
|
+
``` dart
|
|
303
|
+
final messageOptions = TencentCloudChatMessageOptions(
|
|
304
|
+
// Provide either userID or groupID to indicate the conversation for the chat.
|
|
305
|
+
userID: "", // For one-on-one chats, provide the other user's userID.
|
|
306
|
+
groupID: "", // For group chats, provide the groupID.
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
final Widget message = TencentCloudChatMessage(
|
|
310
|
+
options: messageOptions,
|
|
311
|
+
|
|
312
|
+
// ... Other parameters, such as builders, can be specified globally or passed in statically here based on your requirements. For detailed usage, see the parameter and method comments.
|
|
313
|
+
);
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
You can place this instantiated component in the `build` method of a separate page or use it directly for navigation like using `Navigator.push`.
|
|
317
|
+
|
|
318
|
+
## Advanced Usage
|
|
319
|
+
|
|
320
|
+
Once you have implemented the basic usage steps, you will have a chat message module in your project with a default user interface and business logic. However, if these defaults do not fully align with your business requirements, there are several ways to customize the module:
|
|
321
|
+
- Controller: Use the controller to manage the message widgets. This could involve sending additional messages as needed, and scrolling the message list.
|
|
322
|
+
|
|
323
|
+
- Config: Adjust basic settings using the config.
|
|
324
|
+
|
|
325
|
+
- Builders: Further customize the UI widgets with the builder. Each builder is equipped with data (essential parameters for building a custom widget), methods (business logic methods), and widgets (the default atomized widgets for each builder).
|
|
326
|
+
|
|
327
|
+
- EventHandlers: Attach listeners to `eventHandlers` to manage component-specific events. This includes `uiEventHandlers` (such as various events like `onTap`) and `lifeCycleEventHandlers` (such as events triggered after a message has been sent).
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
These advanced implementation methods are consistent across all Chat UIKit components. For a deeper understanding of these advanced features, you can see [**Advanced Usage**](https://trtc.io/document/58585?platform=flutter&product=chat&menulabel=uikit#93becf46-25ac-456b-bd4c-38db387d8149).
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
The above steps provide a quick guide to integrating the message chat component individually. If you wish to understand the complete usage of Chat UIKit or have any unresolved issues, see [**UIKit Integration Documentation**](https://trtc.io/document/58585?platform=flutter&product=chat&menulabel=uikit).
|