@tencent-rtc/mcp 1.7.3 → 1.7.4
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/CHANGELOG.md +13 -0
- package/README.md +13 -13
- package/knowledge/path-meta.js +23 -1
- package/package.json +1 -1
- package/resource/index/manifest.json +1 -1
- package/resource/knowledge/callkit/best-practice/android/video-chat-dating.md +497 -0
- package/resource/knowledge/callkit/best-practice/flutter/android-keep-call-alive-background.md +79 -0
- package/resource/knowledge/callkit/best-practice/flutter/background-incoming-call-no-notification.md +99 -0
- package/resource/knowledge/callkit/best-practice/flutter/ios-keep-call-alive-background.md +93 -0
- package/resource/knowledge/callkit/best-practice/flutter/ios-startup-crash-version-voip.md +68 -0
- package/resource/knowledge/callkit/core-sdk/miniprogram/call-engine.md +386 -0
- package/resource/knowledge/callkit/core-sdk/miniprogram/call-event.md +315 -0
- package/resource/knowledge/callkit/faq/uniapp-miniprogram.md +204 -0
- package/resource/knowledge/callkit/preset/harmonyos/api.md +362 -0
- package/resource/knowledge/callkit/preset/harmonyos/integration.md +318 -0
- package/resource/knowledge/callkit/preset/miniprogram/api-uniapp.md +430 -0
- package/resource/knowledge/callkit/preset/miniprogram/api.md +293 -0
- package/resource/knowledge/callkit/preset/miniprogram/integration.md +294 -0
- package/resource/knowledge/callkit/preset/miniprogram/uniapp-integration.md +224 -0
- package/resource/knowledge/callkit/preset/uni-app/api.md +339 -0
- package/resource/knowledge/callkit/preset/uni-app/integration.md +243 -0
- package/resource/knowledge/chat/preset/react/h5/integration.md +964 -0
- package/resource/knowledge/chat/preset/vue/h5/integration.md +717 -0
- package/resource/knowledge/rtcengine/web/plugin/23-advanced-support-detection.md +6 -6
- package/resource/knowledge/rtcengine/web/plugin/31-advanced-plugins-overview.md +8 -6
- package/resource/knowledge/rtcengine/web/plugin/42-advanced-realtime-transcriber.md +30 -10
- package/server.js +1 -1
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
TUICallEvent API is the event interface for the audio/video calling component.
|
|
2
|
+
|
|
3
|
+
> **Note:**
|
|
4
|
+
> - To provide better audio/video communication capabilities, the original [tuicall-engine-wx](https://www.npmjs.com/package/tuicall-engine-wx) package has been officially deprecated. Developers are advised to migrate to the new [@trtc/call-engine-lite-wx](https://www.npmjs.com/package/@trtc/call-engine-lite-wx) package.
|
|
5
|
+
> - The new package includes optimized API adjustments. Some legacy interfaces are no longer compatible, and cleaner, more stable new interfaces are provided.
|
|
6
|
+
|
|
7
|
+
## TUICallEvent Overview
|
|
8
|
+
|
|
9
|
+
| Event Name | Description |
|
|
10
|
+
|---------|---------|
|
|
11
|
+
| [ON_CALL_RECEIVED](#ON_CALL_RECEIVED) | Call request received event. |
|
|
12
|
+
| [USER_ACCEPT](#USER_ACCEPT) | User accepted the call. **Deprecated in v4.x.x.** |
|
|
13
|
+
| [USER_ENTER](#USER_ENTER) | User entered the call. |
|
|
14
|
+
| [USER_LEAVE](#USER_LEAVE) | User left the call. |
|
|
15
|
+
| [USER_UPDATE](#USER_UPDATE) | User updated. |
|
|
16
|
+
| [REJECT](#REJECT) | User rejected the call. |
|
|
17
|
+
| [NO_RESP](#NO_RESP) | User did not respond. |
|
|
18
|
+
| [LINE_BUSY](#LINE_BUSY) | User is busy. |
|
|
19
|
+
| [ON_CALL_NOT_CONNECTED](#ON_CALL_CANCELED) | Call was not established. All participants will receive this event. |
|
|
20
|
+
| [ON_CALL_BEGIN](#ON_CALL_BEGIN) | Call connected event. |
|
|
21
|
+
| [ON_CALL_END](#CALL_END) | Call ended. |
|
|
22
|
+
| [KICKED_OUT](#KICKED_OUT) | Kicked offline. |
|
|
23
|
+
| [ERROR](#ERROR) | Error information. |
|
|
24
|
+
| [ON_USER_NETWORK_QUALITY_CHANGED](#ON_USER_NETWORK_QUALITY_CHANGED) | Network quality event for all users. |
|
|
25
|
+
| [USER_VIDEO_AVAILABLE](#USER_VIDEO_AVAILABLE) | Event indicating whether a user has a video stream. |
|
|
26
|
+
| [USER_AUDIO_AVAILABLE](#USER_AUDIO_AVAILABLE) | Event indicating whether a user has an audio stream. |
|
|
27
|
+
|
|
28
|
+
## TUICallEvent Details
|
|
29
|
+
``` javascript
|
|
30
|
+
import TUICallEngine, { TUICallEvent } from '@trtc/call-engine-lite-wx';
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### ON_CALL_RECEIVED
|
|
34
|
+
|
|
35
|
+
A new incoming call request event. The callee receives this event. You can listen to it to decide whether to show the call answer UI.
|
|
36
|
+
``` javascript
|
|
37
|
+
let handleOnCallReceived = function(event) {
|
|
38
|
+
console.log(event)
|
|
39
|
+
};
|
|
40
|
+
tuiCallEngine.on(TUICallEvent.ON_CALL_RECEIVED, handleOnCallReceived, this);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Parameters:**
|
|
44
|
+
|
|
45
|
+
| Parameter | Type | Description |
|
|
46
|
+
|---------|---------|---------|
|
|
47
|
+
| sponsor | String | The inviter. |
|
|
48
|
+
| userIDList | Array\<String\> | Other users also being invited. |
|
|
49
|
+
| isFromGroup | Boolean | Whether this is a group call. |
|
|
50
|
+
| inviteData | Object | Call data. |
|
|
51
|
+
| inviteID | String | Invitation ID, identifies a single invitation. |
|
|
52
|
+
| userData | String | Extension field: extra information in the invitation signaling. |
|
|
53
|
+
| callId | String | Unique ID of this call. |
|
|
54
|
+
| roomID | Number | Audio/video room ID for this call. |
|
|
55
|
+
| callMediaType | Number | Call media type: video call or voice call. |
|
|
56
|
+
| callRole | String | Role, enum: caller or callee. |
|
|
57
|
+
|
|
58
|
+
### USER_ACCEPT
|
|
59
|
+
|
|
60
|
+
> **Note:**
|
|
61
|
+
> **This event is deprecated in v4.x.x.**
|
|
62
|
+
>
|
|
63
|
+
|
|
64
|
+
When a user accepts the call, other users receive this event.
|
|
65
|
+
``` javascript
|
|
66
|
+
let handleUserAccept = function(event) {
|
|
67
|
+
console.log('User accepted the call')
|
|
68
|
+
}
|
|
69
|
+
tuiCallEngine.on(TUICallEvent.USER_ACCEPT, this.handleUserAccept, this);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Parameters:**
|
|
73
|
+
|
|
74
|
+
| Parameter | Type | Description |
|
|
75
|
+
|---------|---------|---------|
|
|
76
|
+
| userID | String | The user ID who accepted. |
|
|
77
|
+
| userList | Array | Information about users who have not yet accepted **(will be deprecated)**. |
|
|
78
|
+
|
|
79
|
+
### USER_ENTER
|
|
80
|
+
|
|
81
|
+
When a user agrees to enter the call, other users receive this event.
|
|
82
|
+
``` javascript
|
|
83
|
+
let handleUserEnter = function(event) {
|
|
84
|
+
console.log('User entered the call')
|
|
85
|
+
}
|
|
86
|
+
tuiCallEngine.on(TUICallEvent.USER_ENTER, this.handleUserEnter, this);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Parameters:**
|
|
90
|
+
|
|
91
|
+
| Parameter | Type | Description |
|
|
92
|
+
|---------|---------|---------|
|
|
93
|
+
| userID | String | The user ID who entered the room. |
|
|
94
|
+
| playerList | Array | Stream information of users in the room. |
|
|
95
|
+
|
|
96
|
+
### USER_LEAVE
|
|
97
|
+
|
|
98
|
+
When a user leaves the call, other users in the call receive this event.
|
|
99
|
+
``` javascript
|
|
100
|
+
let handleUserLeave = function(event) {
|
|
101
|
+
console.log('User left the call')
|
|
102
|
+
}
|
|
103
|
+
tuiCallEngine.on(TUICallEvent.USER_LEAVE, this.handleUserLeave, this);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Parameters:**
|
|
107
|
+
|
|
108
|
+
| Parameter | Type | Description |
|
|
109
|
+
|---------|---------|---------|
|
|
110
|
+
| userID | String | The user ID who left the room. |
|
|
111
|
+
| playerList | Array | Stream information of users in the room. |
|
|
112
|
+
|
|
113
|
+
### USER_UPDATE
|
|
114
|
+
|
|
115
|
+
User updated.
|
|
116
|
+
``` javascript
|
|
117
|
+
let handleUserUpdate = function(event) {
|
|
118
|
+
console.log('User updated')
|
|
119
|
+
}
|
|
120
|
+
tuiCallEngine.on(TUICallEvent.USER_UPDATE, this.handleUserUpdate, this)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Parameters:**
|
|
124
|
+
|
|
125
|
+
| Parameter | Type | Description |
|
|
126
|
+
|---------|---------|---------|
|
|
127
|
+
| pusher | String | Updated local push stream information. |
|
|
128
|
+
| playerList | Array | Updated remote users' stream information. |
|
|
129
|
+
|
|
130
|
+
### REJECT
|
|
131
|
+
|
|
132
|
+
Call rejected event. In a 1v1 call, only the caller receives the reject event. In a group call, all invitees can receive this event.
|
|
133
|
+
``` javascript
|
|
134
|
+
let handleInviteeReject = function(event) {
|
|
135
|
+
console.log('User rejected the call')
|
|
136
|
+
}
|
|
137
|
+
tuiCallEngine.on(TUICallEvent.REJECT, this.handleInviteeReject, this);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Parameters:**
|
|
141
|
+
|
|
142
|
+
| Parameter | Type | Description |
|
|
143
|
+
|---------|---------|---------|
|
|
144
|
+
| userID | String | The user ID who rejected the call. |
|
|
145
|
+
| invitee | String | The user ID who rejected the call **(will be deprecated)**. |
|
|
146
|
+
| inviteID | String | Invitation ID, identifies a single invitation. |
|
|
147
|
+
| reason | String | "reject" indicates rejection. |
|
|
148
|
+
|
|
149
|
+
### NO_RESP
|
|
150
|
+
|
|
151
|
+
Invited user did not respond.
|
|
152
|
+
- In a C2C call, only the initiator receives the no-response callback. For example, if A invites B and C, and B doesn't respond, A receives this callback but C does not.
|
|
153
|
+
|
|
154
|
+
- In an IM group call, all invitees can receive this callback. For example, if A invites B and C, and B doesn't respond, both A and C receive this callback.
|
|
155
|
+
|
|
156
|
+
``` javascript
|
|
157
|
+
let handleNoResponse = function(event) {
|
|
158
|
+
console.log('User did not respond')
|
|
159
|
+
}
|
|
160
|
+
tuiCallEngine.on(TUICallEvent.NO_RESP, this.handleNoResponse, this);
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Parameters:**
|
|
164
|
+
|
|
165
|
+
| Parameter | Type | Description |
|
|
166
|
+
|---------|---------|---------|
|
|
167
|
+
| groupID | String | Group ID, unique identifier. |
|
|
168
|
+
| sponsor | String | The initiator's user ID. |
|
|
169
|
+
| userIDList | Array\<String\> | List of users who timed out without responding. |
|
|
170
|
+
| inviteID | String | Invitation ID, identifies a single invitation. |
|
|
171
|
+
|
|
172
|
+
### LINE_BUSY
|
|
173
|
+
|
|
174
|
+
User is busy.
|
|
175
|
+
``` javascript
|
|
176
|
+
let handleLineBusy = function(event) {
|
|
177
|
+
console.log('User is busy')
|
|
178
|
+
}
|
|
179
|
+
tuiCallEngine.on(TUICallEvent.LINE_BUSY, this.handleLineBusy, this);
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Parameters:**
|
|
183
|
+
|
|
184
|
+
| Parameter | Type | Description |
|
|
185
|
+
|---------|---------|---------|
|
|
186
|
+
| userID | String | The busy user's ID. |
|
|
187
|
+
| inviteID | String | Invitation ID, identifies a single invitation. |
|
|
188
|
+
| reason | String | "line busy" indicates the user is busy. |
|
|
189
|
+
|
|
190
|
+
### ON_CALL_NOT_CONNECTED
|
|
191
|
+
|
|
192
|
+
**This event is thrown when the call is not established.**
|
|
193
|
+
``` javascript
|
|
194
|
+
let handleOnCallCanceled = function(event) {
|
|
195
|
+
console.log(event.userID);
|
|
196
|
+
};
|
|
197
|
+
tuiCallEngine.on(TUICallEvent.ON_CALL_CANCELED, handleOnCallCanceled, this);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Parameters:**
|
|
201
|
+
| Parameter | Type | Description |
|
|
202
|
+
| --- | --- | --- |
|
|
203
|
+
| userID | String | The user ID associated with the call cancellation. |
|
|
204
|
+
| callId | String | Unique ID of this call. |
|
|
205
|
+
| roomID | Number | Audio/video room ID for this call. |
|
|
206
|
+
| callMediaType | Number | Call media type: video call or voice call. |
|
|
207
|
+
| callRole | String | Role, enum: caller or callee. |
|
|
208
|
+
| reason | Number | Reason the call was not established:<br>- 0 - Unknown.<br>- 1 - Hung up.<br>- 2 - Rejected.<br>- 3 - No response.<br>- 4 - Offline.<br>- 5 - Busy.<br>- 6 - Call cancelled.<br>- 7 - Accepted on another device.<br>- 8 - Rejected on another device.<br>- 9 - Ended by server. |
|
|
209
|
+
|
|
210
|
+
### ON_CALL_BEGIN
|
|
211
|
+
|
|
212
|
+
Indicates the call has been connected. Both the caller and callee can receive this event. You can listen to this event to start cloud recording, content moderation, etc.
|
|
213
|
+
``` javascript
|
|
214
|
+
let handleOnCallBegin = function(event) {
|
|
215
|
+
console.log(event)
|
|
216
|
+
};
|
|
217
|
+
tuiCallEngine.on(TUICallEvent.ON_CALL_BEGIN, handleOnCallBegin, this);
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Parameters:**
|
|
221
|
+
|
|
222
|
+
| Parameter | Type | Description |
|
|
223
|
+
|---------|---------|---------|
|
|
224
|
+
| callId | String | Unique ID of this call. |
|
|
225
|
+
| roomID | Number | Audio/video room ID for this call. |
|
|
226
|
+
| callMediaType | Number | Call media type: video call or voice call. |
|
|
227
|
+
| callRole | String | Role: caller or callee. |
|
|
228
|
+
|
|
229
|
+
### ON_CALL_END
|
|
230
|
+
|
|
231
|
+
Indicates the call has ended. Both the caller and callee can receive this event. You can listen to this event to display call duration, call type, or to stop cloud recording.
|
|
232
|
+
``` javascript
|
|
233
|
+
let handleCallingEnd = function(event) {
|
|
234
|
+
console.log('Call ended')
|
|
235
|
+
}
|
|
236
|
+
tuiCallEngine.on(TUICallEvent.ON_CALL_END, this.handleCallingEnd, this);
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Parameters:**
|
|
240
|
+
|
|
241
|
+
| Parameter | Type | Description |
|
|
242
|
+
|---------|---------|---------|
|
|
243
|
+
| roomID | Number | Audio/video room ID for this call. Currently only numeric room IDs are supported; string room IDs will be supported in future versions. |
|
|
244
|
+
| callMediaType | Number | Call media type: video call or voice call. |
|
|
245
|
+
| callRole | String | Role, enum: caller ('inviter'), callee ('invitee'), unknown (''). |
|
|
246
|
+
| totalTime | Number | Duration of this call in seconds. |
|
|
247
|
+
| userID | String | The userID that caused the call to end. |
|
|
248
|
+
| callId | String | Unique ID of this call. |
|
|
249
|
+
|
|
250
|
+
### KICKED_OUT
|
|
251
|
+
|
|
252
|
+
Kicked offline.
|
|
253
|
+
``` javascript
|
|
254
|
+
let handleKickedOut = function(event) {
|
|
255
|
+
console.log('Kicked offline')
|
|
256
|
+
}
|
|
257
|
+
tuiCallEngine.on(TUICallEvent.KICKED_OUT, this.handleKickedOut, this);
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### ERROR
|
|
261
|
+
|
|
262
|
+
Listen for SDK error information.
|
|
263
|
+
``` javascript
|
|
264
|
+
let handleError = function(event) {
|
|
265
|
+
console.log('Error information')
|
|
266
|
+
}
|
|
267
|
+
tuiCallEngine.on(TUICallEvent.ERROR, this.handleError, this);
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### ON_USER_NETWORK_QUALITY_CHANGED
|
|
271
|
+
|
|
272
|
+
Network quality event for all users.
|
|
273
|
+
``` javascript
|
|
274
|
+
let handleOnUserNetworkQualityChange = function(event) {
|
|
275
|
+
console.log(event.networkQualityList);
|
|
276
|
+
};
|
|
277
|
+
tuiCallEngine.on(TUICallEvent.ON_USER_NETWORK_QUALITY_CHANGED, this.handleOnUserNetworkQualityChange, this);
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Parameters:**
|
|
281
|
+
| Parameter | Type | Description |
|
|
282
|
+
| --- | --- | --- |
|
|
283
|
+
| networkQualityList | Array\<Object\> | Network status. You can get the current network quality for each user by userID. Example: `networkQualityList: [{ userId: quality }]`.<br>**Network quality levels:**<br>- quality = 0: Network status unknown.<br>- quality = 1: Excellent network.<br>- quality = 2: Good network.<br>- quality = 3: Average network.<br>- quality = 4: Poor network.<br>- quality = 5: Very poor network.<br>- quality = 6: Network disconnected. |
|
|
284
|
+
|
|
285
|
+
### USER_VIDEO_AVAILABLE
|
|
286
|
+
|
|
287
|
+
During a video call, when a user enables/disables their camera, other users in the call receive this event. For example: A and B are in a video call, when A enables/disables their camera, B receives this event.
|
|
288
|
+
``` javascript
|
|
289
|
+
let handleUserVideoChange = function(event) {
|
|
290
|
+
console.log(event.userID, event.isVideoAvailable);
|
|
291
|
+
};
|
|
292
|
+
tuiCallEngine.on(TUICallEvent.USER_VIDEO_AVAILABLE, handleUserVideoChange);
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Parameters:**
|
|
296
|
+
| Parameter | Type | Description |
|
|
297
|
+
| --- | --- | --- |
|
|
298
|
+
| userID | String | The user ID who enabled/disabled their camera. |
|
|
299
|
+
| isVideoAvailable | Boolean | - true: user enabled camera.<br>- false: user disabled camera. |
|
|
300
|
+
|
|
301
|
+
### USER_AUDIO_AVAILABLE
|
|
302
|
+
|
|
303
|
+
During an audio/video call, when a user enables/disables their microphone, other users in the call receive this event. For example: A and B are in a call, when A enables/disables their microphone, B receives this event.
|
|
304
|
+
``` javascript
|
|
305
|
+
let handleUserAudioChange = function(event) {
|
|
306
|
+
console.log(event.userID, event.isAudioAvailable);
|
|
307
|
+
};
|
|
308
|
+
tuiCallEngine.on(TUICallEvent.USER_AUDIO_AVAILABLE, handleUserAudioChange);
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
**Parameters:**
|
|
312
|
+
| Parameter | Type | Description |
|
|
313
|
+
| --- | --- | --- |
|
|
314
|
+
| userID | String | The user ID who enabled/disabled their microphone. |
|
|
315
|
+
| isAudioAvailable | Boolean | - true: user enabled microphone.<br>- false: user disabled microphone. |
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
## How to switch the logged-in userId?
|
|
2
|
+
|
|
3
|
+
First call `destroyed` to clean up the instance and log out, then call `init` to reinitialize and log in.
|
|
4
|
+
|
|
5
|
+
## Common issues and solutions for Vue2 and Vue3 mini program package size
|
|
6
|
+
|
|
7
|
+
### Is code compression enabled?
|
|
8
|
+
|
|
9
|
+
Using the [TUICallKit-Vue2 demo](https://github.com/tencentyun/TUICallKit/tree/main/uni-app/TUICallKit-Miniprogram/TUICallKit-Vue2) as an example, the following comparison shows the effect of checking **Compress code at runtime** (**851KB -> 454KB, reduced by 50%**):
|
|
10
|
+
|
|
11
|
+
Steps: In HBuilder, go to **Run** > **Run to Mini Program Simulator** > check **Compress code at runtime**.
|
|
12
|
+
|
|
13
|
+
[≤ v1.4.4]
|
|
14
|
+
|
|
15
|
+
### How to prevent dependency packages from being bundled into the main package's `common/vendor.js`?
|
|
16
|
+
|
|
17
|
+
When using **Build npm** in **WeChat DevTools**, we want HBuilder to avoid bundling dependencies from `node_modules` into the main package's `common/vendor.js` (**this causes duplicate dependencies and increases the main package size**).
|
|
18
|
+
|
|
19
|
+
[Vue2]
|
|
20
|
+
|
|
21
|
+
It is recommended to configure this via `vue.config.js`.
|
|
22
|
+
- The optional `vue.config.js` config file should be placed in the project root directory.
|
|
23
|
+
|
|
24
|
+
- `vue.config.js` is typically used to configure `webpack` and other build options. When HBuilder uses Vue2 to develop mini programs, `vue.config.js` is automatically loaded during build and packaging.
|
|
25
|
+
|
|
26
|
+
Using the [TUICallKit-Vue2 demo](https://github.com/tencentyun/TUICallKit/tree/main/uni-app/TUICallKit-Miniprogram/TUICallKit-Vue2) as an example, the following comparison shows the effect of excluding dependencies from the main package's `common/vendor.js` (**805KB -> 256KB, reduced by 68%**):
|
|
27
|
+
|
|
28
|
+
Steps:
|
|
29
|
+
1. Import package dependencies in pages using `require`:
|
|
30
|
+
|
|
31
|
+
``` javascript
|
|
32
|
+
// Page imports MUST use require, NOT import
|
|
33
|
+
const TIM = require('tim-wx-sdk');
|
|
34
|
+
```
|
|
35
|
+
2. Configure `vue.config.js` as follows:
|
|
36
|
+
|
|
37
|
+
``` javascript
|
|
38
|
+
// vue.config.js configuration
|
|
39
|
+
module.exports = {
|
|
40
|
+
configureWebpack: {
|
|
41
|
+
externals: {
|
|
42
|
+
'tim-wx-sdk': 'commonjs tim-wx-sdk', // ~550KB
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
> **Note:**
|
|
49
|
+
> **Page dependency imports MUST use require, NOT import!**
|
|
50
|
+
>
|
|
51
|
+
> Reason: When using `import`, HBuilder compiles the import statements during mini program packaging, which prevents using `tim-wx-sdk` from `node_modules`. The `require` approach is not compiled.
|
|
52
|
+
>
|
|
53
|
+
|
|
54
|
+
### How to build npm?
|
|
55
|
+
1. Based on communication with uni-app technical staff, HBuilder currently does not support a **Build npm** feature like **WeChat DevTools**. They have no plans to support it.
|
|
56
|
+
|
|
57
|
+
To use **WeChat DevTools > Tools > Build npm**, you must create `package.json` and run `npm install` in the **WeChat DevTools terminal** first. Only then can you **Build npm**:
|
|
58
|
+
|
|
59
|
+
``` bash
|
|
60
|
+
npm init -y && npm install xx
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### How to use `copy-webpack-plugin` to improve efficiency?
|
|
64
|
+
|
|
65
|
+
In section [3. How to build npm](#e999cfb9-07ef-4a7c-b32c-acf55caaac6b) above, you need to create `package.json` in the WeChat DevTools terminal and install dependencies. Using `copy-webpack-plugin` can reduce this step and improve efficiency.
|
|
66
|
+
|
|
67
|
+
Using the [TUICallKit-Vue2 demo](https://github.com/tencentyun/TUICallKit/tree/main/uni-app/TUICallKit-Miniprogram/TUICallKit-Vue2) as an example:
|
|
68
|
+
|
|
69
|
+
Steps:
|
|
70
|
+
1. Install `copy-webpack-plugin`:
|
|
71
|
+
|
|
72
|
+
> **Note:**
|
|
73
|
+
>
|
|
74
|
+
> **The latest version of copy-webpack-plugin is not compatible. v5.0.0 is recommended (lock the version)**
|
|
75
|
+
>
|
|
76
|
+
|
|
77
|
+
``` javascript
|
|
78
|
+
npm install -D copy-webpack-plugin@5.0.0
|
|
79
|
+
```
|
|
80
|
+
2. Use the `copy-webpack-plugin` plugin in `vue.config.js`:
|
|
81
|
+
|
|
82
|
+
``` javascript
|
|
83
|
+
// vue.config.js configuration
|
|
84
|
+
const path = require('path');
|
|
85
|
+
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
86
|
+
module.exports = {
|
|
87
|
+
configureWebpack: {
|
|
88
|
+
plugins: [
|
|
89
|
+
new CopyWebpackPlugin([
|
|
90
|
+
{
|
|
91
|
+
from: path.join(__dirname, '/node_modules/@tencentcloud/call-uikit-wechat'),
|
|
92
|
+
to: path.join(__dirname, '/unpackage/dist/dev/mp-weixin/node_modules/@tencentcloud/call-uikit-wechat')
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
from: path.join(__dirname, '/node_modules/trtc-wx-sdk'),
|
|
96
|
+
to: path.join(__dirname, '/unpackage/dist/dev/mp-weixin/node_modules/trtc-wx-sdk')
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
from: path.join(__dirname, '/node_modules/tim-wx-sdk'),
|
|
100
|
+
to: path.join(__dirname, '/unpackage/dist/dev/mp-weixin/node_modules/tim-wx-sdk')
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
from: path.join(__dirname, '/node_modules/tsignaling-wx'),
|
|
104
|
+
to: path.join(__dirname, '/unpackage/dist/dev/mp-weixin/node_modules/tsignaling-wx')
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
from: path.join(__dirname, '/node_modules/tuicall-engine-wx'),
|
|
108
|
+
to: path.join(__dirname, '/unpackage/dist/dev/mp-weixin/node_modules/tuicall-engine-wx')
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
from: path.join(__dirname, '/package.json'),
|
|
112
|
+
to: path.join(__dirname, '/unpackage/dist/dev/mp-weixin/package.json')
|
|
113
|
+
}
|
|
114
|
+
])
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
[Vue3]
|
|
121
|
+
|
|
122
|
+
No `vite.config.js` configuration is needed. Just use `require` to import:
|
|
123
|
+
``` javascript
|
|
124
|
+
// Page imports MUST use require, NOT import
|
|
125
|
+
const TIM = require('tim-wx-sdk');
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
For reference: [TUICallKit-Vue3 demo](https://github.com/tencentyun/TUICallKit/tree/main/uni-app/TUICallKit-Miniprogram/TUICallKit-Vue3).
|
|
129
|
+
|
|
130
|
+
### How to build npm?
|
|
131
|
+
1. Based on communication with uni-app technical staff, HBuilder currently does not support a **Build npm** feature like **WeChat DevTools**. They have no plans to support it.
|
|
132
|
+
|
|
133
|
+
To use **WeChat DevTools > Tools > Build npm**, you must create `package.json` and run `npm install` in the **WeChat DevTools terminal** first:
|
|
134
|
+
|
|
135
|
+
``` javascript
|
|
136
|
+
npm init -y && npm install tuicall-engine-wx@1.5.6
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Vue2 uni-app packaged WeChat mini program — no ringtone sound?
|
|
140
|
+
|
|
141
|
+
This is because in Vue2, uni-app packaging encodes ringtone files as base64, which is not supported by the ringtone playback API.
|
|
142
|
+
|
|
143
|
+
Follow these steps to resolve:
|
|
144
|
+
- Step 1: In your project's `TUICallKit` source code, modify the ringtone import method.
|
|
145
|
+
|
|
146
|
+
``` javascript
|
|
147
|
+
// Replace ringtone file import with the following code
|
|
148
|
+
import CALLER_BELL from '../assets/phone_dialing.mp3';
|
|
149
|
+
import CALLEE_BELL from '../assets/phone_ringing.mp3';
|
|
150
|
+
console.debug(CALLEE_BELL, CALLER_BELL);
|
|
151
|
+
let DEFAULT_CALLER_BELL_FILEPATH = '/assets/phone_dialing.mp3';
|
|
152
|
+
let DEFAULT_CALLEE_BELL_FILEPATH = '/assets/phone_ringing.mp3';
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
- Step 2: Modify the `vue.config.js` file in your project.
|
|
156
|
+
|
|
157
|
+
``` javascript
|
|
158
|
+
// Inside chainWebpack(config)
|
|
159
|
+
config.module
|
|
160
|
+
.rule('mp3')
|
|
161
|
+
.test(/\.mp3$/)
|
|
162
|
+
.use('file-loader')
|
|
163
|
+
.loader('file-loader')
|
|
164
|
+
.options({
|
|
165
|
+
esModule: false,
|
|
166
|
+
name: 'assets/[name].[ext]'
|
|
167
|
+
})
|
|
168
|
+
.end();
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## What are SDKAppID and SecretKey?
|
|
172
|
+
- **SDKAppID**: The IM application ID, used for business isolation. Different SDKAppIDs cannot communicate with each other.
|
|
173
|
+
|
|
174
|
+
- **SecretKey**: The IM application secret key. Must be used together with SDKAppID to generate the authentication ticket UserSig for legitimate use of IM services.
|
|
175
|
+
|
|
176
|
+
## What is UserSig and how to generate it?
|
|
177
|
+
- UserSig is the password for logging into Instant Messaging (IM). It is essentially ciphertext obtained by encrypting information such as the UserID.
|
|
178
|
+
|
|
179
|
+
- The recommended approach is to integrate the UserSig calculation code on your server side and provide a project-facing API. When UserSig is needed, your project requests a dynamic UserSig from the business server. For more details, see [Server-side UserSig Generation](https://cloud.tencent.com/document/product/269/32688#GeneratingdynamicUserSig).
|
|
180
|
+
|
|
181
|
+
## How to handle TUICallKit TypeScript validation errors?
|
|
182
|
+
|
|
183
|
+
[.eslintignore]
|
|
184
|
+
``` plaintext
|
|
185
|
+
TUICallKit
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
[tsconfig.json]
|
|
189
|
+
``` json
|
|
190
|
+
{
|
|
191
|
+
"compilerOptions": {
|
|
192
|
+
"noImplicitAny": true
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## How to disable beauty filters?
|
|
198
|
+
- Web: Beauty filters are disabled by default.
|
|
199
|
+
|
|
200
|
+
- Mini Program: Call the [setBeautyLevel API](https://cloud.tencent.com/document/product/647/78761#setBeautyLevel) with parameter 0 to disable the default beauty filter.
|
|
201
|
+
|
|
202
|
+
``` javascript
|
|
203
|
+
TUICallKitServer.getTUICallEngineInstance().setBeautyLevel(0);
|
|
204
|
+
```
|