@tencent-rtc/mcp 1.7.2 → 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 +26 -0
- package/README.md +25 -17
- package/knowledge/bm25.js +20 -11
- package/knowledge/path-meta.js +23 -1
- package/knowledge/search/generic-rerank.js +123 -0
- package/knowledge/search/search-pass.js +8 -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/best-practice/common/web-sdk-log-level.md +76 -0
- package/resource/knowledge/chat/best-practice/miniprogram/desktop-wechat-miniprogram-error.md +79 -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/roomkit/best-practice/vue/screen-share-auto-stop-on-leave.md +62 -0
- package/resource/knowledge/roomkit/core-sdk/react/network-proxy.md +83 -0
- package/resource/knowledge/roomkit/core-sdk/vue/network-proxy.md +83 -0
- package/resource/knowledge/roomkit/core-sdk/vue/recording.md +245 -0
- package/resource/knowledge/roomkit/core-sdk/vue/whiteboard-annotation.md +196 -0
- package/resource/knowledge/roomkit/faq/error-code.md +103 -0
- package/resource/knowledge/roomkit/preset/harmonyos/integration.md +461 -0
- package/resource/knowledge/roomkit/preset/react/features/network-proxy.md +79 -0
- package/resource/knowledge/roomkit/preset/uniapp-app/integration.md +580 -0
- package/resource/knowledge/roomkit/preset/vue/features/ai-caption-translation.md +69 -0
- package/resource/knowledge/roomkit/preset/vue/features/ai-denoiser.md +67 -0
- package/resource/knowledge/roomkit/preset/vue/features/network-proxy.md +79 -0
- package/resource/knowledge/roomkit/preset/vue/features/recording.md +85 -0
- package/resource/knowledge/roomkit/preset/vue/features/whiteboard-annotation.md +86 -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/preflight-route.js +18 -6
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
|
|
3
|
+
The audio/video calling feature is implemented through `CallStore`, enabling real-time audio and video interaction between users. `CallStore` provides a comprehensive set of APIs to manage the entire call lifecycle. When integrating `CallStore`, be sure to understand the following runtime characteristics:
|
|
4
|
+
- **Error Handling**: When actively calling APIs (such as `calls`), failures due to parameter validation or state conflicts are typically reported via asynchronous error events or error codes. Network or remote exceptions are also delivered through `onCallEnded` with the error reason.
|
|
5
|
+
|
|
6
|
+
- **Threading Model & Cleanup**: All state updates (`CallState`) and event callbacks (`CallEvent` / `CallEventListener`) are typically **guaranteed to fire on the main thread**, making them safe for direct UI updates. Under the global singleton pattern, be sure to unregister listeners when components are destroyed (e.g., `deinit` / `onDestroy`) to avoid memory leaks.
|
|
7
|
+
|
|
8
|
+
> **Important:**
|
|
9
|
+
>
|
|
10
|
+
> After successful SDK initialization, obtain the `CallStore` instance through the **shared** singleton. Do not attempt to initialize it directly, or you will not receive call state updates.
|
|
11
|
+
>
|
|
12
|
+
|
|
13
|
+
> **Note:**
|
|
14
|
+
>
|
|
15
|
+
> Call state updates are delivered through the **state** publisher. Subscribe to it to receive real-time updates on call data.
|
|
16
|
+
>
|
|
17
|
+
|
|
18
|
+
> **Warning:**
|
|
19
|
+
>
|
|
20
|
+
> Ensure proper UI state handling after a call ends to avoid interface anomalies.
|
|
21
|
+
>
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
- **Initiate Audio/Video Calls**: Supports initiating audio or video calls to one or multiple users, with configurable timeout, custom data, and other parameters.
|
|
25
|
+
|
|
26
|
+
- **Accept/Reject Calls**: When receiving an incoming call invitation, you can choose to accept or reject it.
|
|
27
|
+
|
|
28
|
+
- **Hang Up Calls**: End the current ongoing audio/video call.
|
|
29
|
+
|
|
30
|
+
- **Group Call Management**: Supports joining an existing group call or inviting other users to join during a call.
|
|
31
|
+
|
|
32
|
+
- **Call Record Management**: Query recent call records (with pagination support) and delete specified call records.
|
|
33
|
+
|
|
34
|
+
- **Event-Driven Architecture**: Provides event listeners for call started, invitation received, call ended, and more.
|
|
35
|
+
|
|
36
|
+
- **State Subscription**: Subscribe to real-time call state including participant list, volume information, network quality, etc.
|
|
37
|
+
|
|
38
|
+
## Subscribable Data
|
|
39
|
+
|
|
40
|
+
**CallState** field descriptions:
|
|
41
|
+
| **Property** | **Type** | **Description** |
|
|
42
|
+
| --- | --- | --- |
|
|
43
|
+
| activeCall | CallInfo | Current active call information.<br>**Lifecycle contract**: When `onCallEnded` fires, this object is not immediately cleared. It retains the call's final state for UI end-of-call animations (where `CallInfo.result` or other parameters reflect the end reason). It is automatically overwritten when a new call is initiated or received. Developers can manually clean up by resetting `CallStore`-related state. |
|
|
44
|
+
| recentCalls | [CallInfo] | List of recent call records.<br>**Note:**<br>After each `queryRecentCalls` call, this state currently performs an **overwrite update** rather than automatic append. To implement infinite scrolling, the business layer must concatenate newly arrived data with the existing list. |
|
|
45
|
+
| cursor | String | Pagination cursor for querying more call records. |
|
|
46
|
+
| selfInfo | CallParticipantInfo | Current user's own information. |
|
|
47
|
+
| allParticipants | [CallParticipantInfo] | List of all participants in the current call. |
|
|
48
|
+
| speakerVolumes | [String: Int] | Participant volume information. Key is user ID, value is volume level. |
|
|
49
|
+
| networkQualities | [String: NetworkQuality] | Participant network quality information. Key is user ID, value is network quality. |
|
|
50
|
+
|
|
51
|
+
## API Reference
|
|
52
|
+
|
|
53
|
+
| **Method** | **Description** |
|
|
54
|
+
|---------|---------|
|
|
55
|
+
| shared | Get the CallStore singleton instance. |
|
|
56
|
+
| callEventPublisher | Call event publisher. |
|
|
57
|
+
| calls | Initiate a call. |
|
|
58
|
+
| accept | Accept a call. |
|
|
59
|
+
| reject | Reject a call. |
|
|
60
|
+
| hangup | Hang up a call. |
|
|
61
|
+
| join | Join a group call. |
|
|
62
|
+
| invite | Invite users to join a call. |
|
|
63
|
+
| queryRecentCalls | Query recent call records. |
|
|
64
|
+
| deleteRecentCalls | Delete call records. |
|
|
65
|
+
|
|
66
|
+
### Get Instance
|
|
67
|
+
|
|
68
|
+
#### shared
|
|
69
|
+
|
|
70
|
+
Get the CallStore singleton instance.
|
|
71
|
+
|
|
72
|
+
### Observe State and Events
|
|
73
|
+
|
|
74
|
+
#### callEventPublisher
|
|
75
|
+
|
|
76
|
+
Call event publisher.
|
|
77
|
+
|
|
78
|
+
### Call Operations
|
|
79
|
+
|
|
80
|
+
#### calls
|
|
81
|
+
|
|
82
|
+
Initiate an audio or video call to specified users. Supports both one-to-one and group calls.
|
|
83
|
+
``` ets
|
|
84
|
+
calls(
|
|
85
|
+
participantIds: string[],
|
|
86
|
+
mediaType: CallMediaType,
|
|
87
|
+
params: CallParams | undefined,
|
|
88
|
+
): Promise<void> {
|
|
89
|
+
return this.impl.calls(participantIds, mediaType, params)
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Version Info**
|
|
94
|
+
|
|
95
|
+
Supported since version 3.5.
|
|
96
|
+
|
|
97
|
+
**Parameters**
|
|
98
|
+
|
|
99
|
+
| **Parameter** | **Type** | **Description** |
|
|
100
|
+
|---------|---------|---------|
|
|
101
|
+
| participantIds | [String] | List of callee IDs. Supports one or multiple users. |
|
|
102
|
+
| mediaType | CallMediaType | Call media type (audio/video). |
|
|
103
|
+
| params | CallParams? | Call parameter configuration. |
|
|
104
|
+
|
|
105
|
+
#### accept
|
|
106
|
+
|
|
107
|
+
Accept a call. Call this method to accept when receiving an incoming call invitation.
|
|
108
|
+
``` ets
|
|
109
|
+
accept(): Promise<void> {
|
|
110
|
+
return this.impl.accept()
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Version Info**
|
|
115
|
+
|
|
116
|
+
Supported since version 3.5.
|
|
117
|
+
|
|
118
|
+
#### reject
|
|
119
|
+
|
|
120
|
+
Reject a call. Call this method to reject when receiving an incoming call invitation.
|
|
121
|
+
``` ets
|
|
122
|
+
reject(): Promise<void> {
|
|
123
|
+
return this.impl.reject()
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Version Info**
|
|
128
|
+
|
|
129
|
+
Supported since version 3.5.
|
|
130
|
+
|
|
131
|
+
#### hangup
|
|
132
|
+
|
|
133
|
+
Hang up and end the current ongoing call.
|
|
134
|
+
``` ets
|
|
135
|
+
hangup(): Promise<void> {
|
|
136
|
+
return this.impl.hangup()
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Version Info**
|
|
141
|
+
|
|
142
|
+
Supported since version 3.5.
|
|
143
|
+
|
|
144
|
+
#### join
|
|
145
|
+
|
|
146
|
+
Join an ongoing group call using a specific Call ID.
|
|
147
|
+
``` ets
|
|
148
|
+
join(callId: string): Promise<void> {
|
|
149
|
+
return this.impl.join(callId)
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Version Info**
|
|
154
|
+
|
|
155
|
+
Supported since version 3.5.
|
|
156
|
+
|
|
157
|
+
**Parameters**
|
|
158
|
+
|
|
159
|
+
| **Parameter** | **Type** | **Description** |
|
|
160
|
+
|---------|---------|---------|
|
|
161
|
+
| callId | String | The call ID to join. |
|
|
162
|
+
|
|
163
|
+
#### invite
|
|
164
|
+
|
|
165
|
+
Invite other users to join during an ongoing call.
|
|
166
|
+
``` ets
|
|
167
|
+
invite(
|
|
168
|
+
participantIds: string[],
|
|
169
|
+
params: CallParams | undefined,
|
|
170
|
+
): Promise<void> {
|
|
171
|
+
return this.impl.invite(participantIds, params)
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Version Info**
|
|
176
|
+
|
|
177
|
+
Supported since version 3.5.
|
|
178
|
+
|
|
179
|
+
**Parameters**
|
|
180
|
+
|
|
181
|
+
| **Parameter** | **Type** | **Description** |
|
|
182
|
+
|---------|---------|---------|
|
|
183
|
+
| participantIds | [String] | List of invitee IDs. |
|
|
184
|
+
| params | CallParams? | Call parameter configuration. |
|
|
185
|
+
|
|
186
|
+
### Call Records
|
|
187
|
+
|
|
188
|
+
#### queryRecentCalls
|
|
189
|
+
|
|
190
|
+
Query recent call records.
|
|
191
|
+
**Current limitation**: Query results currently **overwrite (reset)** the `state.recentCalls` list rather than automatically appending.
|
|
192
|
+
``` ets
|
|
193
|
+
queryRecentCalls(cursor: string, count: number): Promise<void> {
|
|
194
|
+
return this.impl.queryRecentCalls(cursor, count)
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Version Info**
|
|
199
|
+
|
|
200
|
+
Supported since version 3.5.
|
|
201
|
+
|
|
202
|
+
**Parameters**
|
|
203
|
+
|
|
204
|
+
| **Parameter** | **Type** | **Description** |
|
|
205
|
+
|---------|---------|---------|
|
|
206
|
+
| cursor | String | Pagination cursor. Pass an empty string for the first query. |
|
|
207
|
+
| count | UInt | Number of records to query. |
|
|
208
|
+
|
|
209
|
+
#### deleteRecentCalls
|
|
210
|
+
|
|
211
|
+
Delete specified call records.
|
|
212
|
+
``` ets
|
|
213
|
+
deleteRecentCalls(callIdList: string[]): Promise<void> {
|
|
214
|
+
return this.impl.deleteRecentCalls(callIdList)
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Version Info**
|
|
219
|
+
|
|
220
|
+
Supported since version 3.5.
|
|
221
|
+
|
|
222
|
+
**Parameters**
|
|
223
|
+
|
|
224
|
+
| **Parameter** | **Type** | **Description** |
|
|
225
|
+
|---------|---------|---------|
|
|
226
|
+
| callIdList | [String] | List of call IDs to delete. |
|
|
227
|
+
|
|
228
|
+
## Data Structures
|
|
229
|
+
|
|
230
|
+
### CallMediaType
|
|
231
|
+
|
|
232
|
+
Call media type, used to specify whether to initiate an audio or video call.
|
|
233
|
+
|
|
234
|
+
| **Enum Value** | **Value** | **Description** |
|
|
235
|
+
|---------|---------|---------|
|
|
236
|
+
| audio | 1 | Audio call. |
|
|
237
|
+
| video | 2 | Video call. |
|
|
238
|
+
|
|
239
|
+
### CallEndReason
|
|
240
|
+
|
|
241
|
+
Call end reason, used to identify how the audio/video call ended (normal hangup, rejection, timeout, etc.).
|
|
242
|
+
|
|
243
|
+
| **Enum Value** | **Value** | **Description** |
|
|
244
|
+
|---------|---------|---------|
|
|
245
|
+
| unknown | 0 | Unknown reason. |
|
|
246
|
+
| hangup | 1 | Normal hangup. |
|
|
247
|
+
| reject | 2 | Call rejected. |
|
|
248
|
+
| noResponse | 3 | No response. |
|
|
249
|
+
| offline | 4 | Remote party offline. |
|
|
250
|
+
| lineBusy | 5 | Remote party busy. |
|
|
251
|
+
| canceled | 6 | Call cancelled. |
|
|
252
|
+
| otherDeviceAccepted | 7 | Accepted on another device. |
|
|
253
|
+
| otherDeviceReject | 8 | Rejected on another device. |
|
|
254
|
+
| endByServer | 9 | Call ended by server. |
|
|
255
|
+
|
|
256
|
+
### CallDirection
|
|
257
|
+
|
|
258
|
+
Call direction, used to identify whether the call is incoming, outgoing, or missed.
|
|
259
|
+
|
|
260
|
+
| **Enum Value** | **Value** | **Description** |
|
|
261
|
+
|---------|---------|---------|
|
|
262
|
+
| unknown | 0 | Unknown. |
|
|
263
|
+
| missed | 1 | Missed call. |
|
|
264
|
+
| incoming | 2 | Incoming call. |
|
|
265
|
+
| outgoing | 3 | Outgoing call. |
|
|
266
|
+
|
|
267
|
+
### CallParticipantStatus
|
|
268
|
+
|
|
269
|
+
Call participant status, used to identify whether a participant is waiting or has accepted.
|
|
270
|
+
|
|
271
|
+
| **Enum Value** | **Value** | **Description** |
|
|
272
|
+
|---------|---------|---------|
|
|
273
|
+
| none | 0 | No status (not in a call). |
|
|
274
|
+
| waiting | 1 | Waiting (calling/being called). |
|
|
275
|
+
| accept | 2 | Accepted. |
|
|
276
|
+
|
|
277
|
+
### CloudRecordPolicy
|
|
278
|
+
|
|
279
|
+
Cloud recording policy for audio/video calls, used to configure whether cloud recording is enabled for a specific call.
|
|
280
|
+
|
|
281
|
+
| **Enum Value** | **Value** | **Description** |
|
|
282
|
+
|---------|---------|---------|
|
|
283
|
+
| followConsoleConfig | 0 | Follow the console's global configuration (default). |
|
|
284
|
+
| enable | 1 | Enable cloud recording, overriding the console configuration. |
|
|
285
|
+
| disable | 2 | Disable cloud recording, overriding the console configuration. |
|
|
286
|
+
|
|
287
|
+
### CallEventListener
|
|
288
|
+
|
|
289
|
+
Call events, used to receive various event notifications during a call.
|
|
290
|
+
|
|
291
|
+
**Methods**
|
|
292
|
+
|
|
293
|
+
| **Method** | **Description** |
|
|
294
|
+
|---------|---------|
|
|
295
|
+
| onCallStarted | Callback when the call starts.<br>Timing note: This indicates "the call flow has been successfully entered (e.g., `calls` was initiated and internally accepted)", but **does not mean the audio/video room has been connected or established**. It is recommended to use this only for initial UI navigation (caller side). |
|
|
296
|
+
| onCallReceived | Callback when a new call invitation is received.<br>Field recommendation: Event parameters only pass through `callId`, `mediaType`, and `userData`. To read the full information such as inviter, room ID, or associated group ID, read from `state.activeCall` after receiving this event. |
|
|
297
|
+
| onCallEnded | Unified call end event callback.<br>Scenario note: Whether the call ends after connection, times out without answer, is cancelled by the remote party, or is accepted on another device, this event is ultimately triggered. Developers must use the `reason` parameter to determine the specific cause and display the corresponding UI text or handle branching logic.<br>Getting call duration: This event's parameters do not include a duration field. To get call duration, read `state.activeCall.duration` (in seconds) when receiving this callback. After the call is connected, the SDK internally increments this value every second; `activeCall` is not immediately cleared when the call ends, so it can be safely read in this callback. |
|
|
298
|
+
| onSuggestSwitchToCellular | Callback triggered when the system detects poor WiFi quality and suggests switching to cellular network. |
|
|
299
|
+
|
|
300
|
+
### CallParams
|
|
301
|
+
|
|
302
|
+
Call parameter configuration, used to set room ID, timeout, custom data, and other parameters when initiating audio/video calls.
|
|
303
|
+
| **Property** | **Type** | **Description** |
|
|
304
|
+
| --- | --- | --- |
|
|
305
|
+
| roomId | String | TRTC room ID (CallStore's media stream management uses Tencent Cloud TRTC service). Optional.<br>When not provided, automatically generated by the server. If the business needs to specify or reuse a TRTC room, pass a specific string. |
|
|
306
|
+
| timeout | Int | Ring timeout in seconds. Optional.<br>Only controls the unanswered timeout phase from call initiation (`calls`) to acceptance. Does not apply to connected calls or `invite` operations.<br>When set to 0, the server default (30s) is used. |
|
|
307
|
+
| userData | String | Custom pass-through data attached to the call. Optional.<br>This data is primarily exposed to the business side through the callee's `onCallReceived` event.<br>**Note:**<br>It does not persist in the long-term `CallInfo` state nor is it saved to call records. It is recommended to pass a short JSON string. |
|
|
308
|
+
| chatGroupId | String | Tencent Cloud IM group ID. Optional.<br>Only required in "call initiated from a group chat" scenarios. When provided, the system routes signaling and associates this call with the group's call records, enabling call start/end status messages in the group chat and inviting group members to join during the call.<br>For one-to-one calls or ad-hoc multi-party calls not bound to a fixed group, leave this empty.<br>**Note:**<br>This field takes effect on the initial `calls`. Subsequent `invite` calls cannot change the group binding for this call. |
|
|
309
|
+
| isEphemeralCall | Bool | Ephemeral call (no call record). Optional.<br>When set to `true`, no call message is generated after this call ends. Common scenario: initiating a call in a 1v1 chat without wanting to display a call message. |
|
|
310
|
+
| cloudRecordPolicy | CloudRecordPolicy | Cloud recording policy for this call. Requires the relevant capability to be activated in the console.<br>- followConsoleConfig (default): Follow the console's global configuration.<br>- enable: Force enable cloud recording, overriding the console's global configuration.<br>- disable: Force disable cloud recording, overriding the console's global configuration. |
|
|
311
|
+
| offlinePushTitle | string | Offline push notification title.<br>When non-empty, overrides the default title (logged-in user's nickname). |
|
|
312
|
+
| offlinePushDescription | string | Offline push notification description.<br>When non-empty, overrides the default description. |
|
|
313
|
+
|
|
314
|
+
### CallParticipantInfo
|
|
315
|
+
|
|
316
|
+
Call participant information, including user ID, nickname, avatar, participation status, microphone/camera on/off status, etc.
|
|
317
|
+
|
|
318
|
+
| **Property** | **Type** | **Description** |
|
|
319
|
+
|---------|---------|---------|
|
|
320
|
+
| id | String | User ID. |
|
|
321
|
+
| name | String | User nickname. |
|
|
322
|
+
| avatarURL | String | User avatar URL. |
|
|
323
|
+
| remark | String | Friend remark. |
|
|
324
|
+
| status | CallParticipantStatus | Participant status. |
|
|
325
|
+
| isMicrophoneOpened | Bool | Whether the microphone is on. |
|
|
326
|
+
| isCameraOpened | Bool | Whether the camera is on. |
|
|
327
|
+
|
|
328
|
+
### CallInfo
|
|
329
|
+
|
|
330
|
+
Call information, including call ID, room ID, initiator, invitees, media type, call direction, start time, duration, and other complete details.
|
|
331
|
+
| **Property** | **Type** | **Description** |
|
|
332
|
+
| --- | --- | --- |
|
|
333
|
+
| callId | String | Call ID. |
|
|
334
|
+
| roomId | String | Room ID. |
|
|
335
|
+
| inviterId | String | Initiator ID. |
|
|
336
|
+
| inviteeIds | [String] | List of invitee IDs. |
|
|
337
|
+
| chatGroupId | String | Chat group ID. |
|
|
338
|
+
| mediaType | CallMediaType? | Call media type.<br>**Note:**<br>May be null during early event phases, for unknown types, or when historical call records (recent calls) have not fully populated this field. Business code should handle optional unwrapping. |
|
|
339
|
+
| result | CallDirection | Call direction/record type (e.g., incoming, outgoing, missed).<br>**Note:**<br>This does not represent the specific reason for call termination. |
|
|
340
|
+
| startTime | TimeInterval | Timestamp when the call was actually connected (unit: milliseconds). |
|
|
341
|
+
| duration | TimeInterval | Call duration (seconds). |
|
|
342
|
+
|
|
343
|
+
### CallState
|
|
344
|
+
|
|
345
|
+
Call state data, managing the real-time data state of the current call.
|
|
346
|
+
| **Property** | **Type** | **Description** |
|
|
347
|
+
| --- | --- | --- |
|
|
348
|
+
| activeCall | CallInfo | Current active call information.<br>**Lifecycle contract**: When `onCallEnded` fires, this object is not immediately cleared. It retains the call's final state for UI end-of-call animations (where `CallInfo.result` or other parameters reflect the end reason). It is automatically overwritten when a new call is initiated or received. Developers can manually clean up by resetting `CallStore`-related state. |
|
|
349
|
+
| recentCalls | [CallInfo] | List of recent call records.<br>**Note:**<br>After each `queryRecentCalls` call, this state currently performs an **overwrite update** rather than automatic append. To implement infinite scrolling, the business layer must concatenate newly arrived data with the existing list. |
|
|
350
|
+
| cursor | String | Pagination cursor for querying more call records. |
|
|
351
|
+
| selfInfo | CallParticipantInfo | Current user's own information. |
|
|
352
|
+
| allParticipants | [CallParticipantInfo] | List of all participants in the current call. |
|
|
353
|
+
| speakerVolumes | [String: Int] | Participant volume information. Key is user ID, value is volume level. |
|
|
354
|
+
| networkQualities | [String: NetworkQuality] | Participant network quality information. Key is user ID, value is network quality. |
|
|
355
|
+
|
|
356
|
+
## Usage Example
|
|
357
|
+
``` ets
|
|
358
|
+
import AtomicXCore
|
|
359
|
+
// Initiate a video call
|
|
360
|
+
CallStore.shared.calls(participantIds: ["mike"], mediaType: .video, params: nil) { code, message in
|
|
361
|
+
}
|
|
362
|
+
```
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
This guide walks you through quickly integrating the TUICallKit component. You can complete the following key steps in 10 minutes and get a fully functional audio/video calling interface.
|
|
2
|
+
|
|
3
|
+
## Prerequisites
|
|
4
|
+
|
|
5
|
+
### **Environment Requirements**
|
|
6
|
+
- IDE: DevEco Studio 6.0.0.858 or later.
|
|
7
|
+
|
|
8
|
+
- Device OS: HarmonyOS 5.0.5 or later.
|
|
9
|
+
|
|
10
|
+
- API Version: 17 or later.
|
|
11
|
+
|
|
12
|
+
### **Activate the Service**
|
|
13
|
+
|
|
14
|
+
Before using Tencent Cloud audio/video services, you need to go to the console to activate the service for your application. For detailed steps, see Activate Service. After activation, note down the `SDKAppID` and `SDKSecretKey` — you will need them in the subsequent login step.
|
|
15
|
+
|
|
16
|
+
## Quick Integration
|
|
17
|
+
|
|
18
|
+
### Step 1: Import the Component
|
|
19
|
+
|
|
20
|
+
2. In your project's `entry/oh-package.json5` file, add the following plugin dependencies:
|
|
21
|
+
|
|
22
|
+
``` json
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@tencentcloud/atomicxcore": "^4.2.0",
|
|
25
|
+
"@tencentcloud/tuicallkit": "file:../../../call",
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> **Note:**
|
|
30
|
+
>
|
|
31
|
+
> The `call` directory can be placed anywhere, as long as the relative path is correctly set in oh-package.json5.
|
|
32
|
+
>
|
|
33
|
+
|
|
34
|
+
3. After modifying **oh-package.json5**, run the following command to install the local TUIKit component:
|
|
35
|
+
|
|
36
|
+
``` bash
|
|
37
|
+
ohpm install
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`ohpm install` will automatically install the required dependencies.
|
|
41
|
+
|
|
42
|
+
> **Warning:**
|
|
43
|
+
>
|
|
44
|
+
> - When using local integration, to upgrade you need to get the latest component code from GitHub and overwrite your local project's call directory.
|
|
45
|
+
> - When private modifications conflict with remote changes, you need to manually merge and resolve conflicts.
|
|
46
|
+
|
|
47
|
+
### Step 2: Project Configuration
|
|
48
|
+
1. Permission configuration: In your project's `entry/module.json5` module section, declare the following required permissions:
|
|
49
|
+
|
|
50
|
+
``` json
|
|
51
|
+
"requestPermissions":[
|
|
52
|
+
{
|
|
53
|
+
"name" : "ohos.permission.INTERNET"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name" : "ohos.permission.USE_BLUETOOTH"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name" : "ohos.permission.GET_BUNDLE_INFO"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name" : "ohos.permission.GET_NETWORK_INFO"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name" : "ohos.permission.GET_WIFI_INFO"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name" : "ohos.permission.MODIFY_AUDIO_SETTINGS"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name" : "ohos.permission.MICROPHONE",
|
|
72
|
+
"reason": "$string:module_desc",
|
|
73
|
+
"usedScene": { "abilities": [ "EntryAbility" ], "when":"always" }
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name" : "ohos.permission.CAMERA",
|
|
77
|
+
"reason": "$string:module_desc",
|
|
78
|
+
"usedScene": { "abilities": [ "EntryAbility" ], "when":"always" }
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name" : "ohos.permission.KEEP_BACKGROUND_RUNNING"
|
|
82
|
+
},
|
|
83
|
+
]
|
|
84
|
+
```
|
|
85
|
+
2. Module declaration: After integrating the source code into your existing project, declare the module in the `build-profile.json5` file:
|
|
86
|
+
|
|
87
|
+
``` bash
|
|
88
|
+
"modules": [
|
|
89
|
+
{
|
|
90
|
+
"name": "entry",
|
|
91
|
+
"srcPath": "./entry",
|
|
92
|
+
"targets": [
|
|
93
|
+
{
|
|
94
|
+
"name": "default",
|
|
95
|
+
"applyToProducts": [
|
|
96
|
+
"default"
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"name": "tuicallkit",
|
|
103
|
+
"srcPath": "../call", // Adjust based on actual directory
|
|
104
|
+
"targets": [
|
|
105
|
+
{
|
|
106
|
+
"name": "default",
|
|
107
|
+
"applyToProducts": [
|
|
108
|
+
"default"
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
```
|
|
115
|
+
3. Bind **TUICallKit** to your application's main window (WindowStage), enabling the entire app to accept incoming calls and initiate calls globally after startup, without repeated initialization in business pages.
|
|
116
|
+
|
|
117
|
+
``` typescript
|
|
118
|
+
// Your project's EntryAbility.ets
|
|
119
|
+
import { UIAbility } from '@kit.AbilityKit';
|
|
120
|
+
import { window } from '@kit.ArkUI';
|
|
121
|
+
import { TUICallKit } from '@tencentcloud/tuicallkit';
|
|
122
|
+
|
|
123
|
+
export default class EntryAbility extends UIAbility {
|
|
124
|
+
async onWindowStageCreate(windowStage: window.WindowStage): Promise<void> {
|
|
125
|
+
windowStage.loadContent('pages/Index');
|
|
126
|
+
// Hand the call UI hosting window to TUICallKit for management, establishing incoming call listeners
|
|
127
|
+
TUICallKit.createInstance(this.context).attach(windowStage);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
onWindowStageDestroy(): void {
|
|
131
|
+
// Unbind the window and release resources
|
|
132
|
+
TUICallKit.createInstance(this.context).detach();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
4. Declare backgroundModes. Under the UIAbility hosting the call interface (typically EntryAbility), add backgroundModes to the abilities node in module.json5:
|
|
137
|
+
|
|
138
|
+
``` java
|
|
139
|
+
"abilities": [
|
|
140
|
+
{
|
|
141
|
+
"name": "EntryAbility",
|
|
142
|
+
// ... other configurations remain unchanged
|
|
143
|
+
"backgroundModes": [
|
|
144
|
+
"audioRecording",
|
|
145
|
+
"audioPlayback"
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Step 3: Login
|
|
152
|
+
|
|
153
|
+
After code integration, you need to complete the login process. This is a **critical step for using TUICallKit**. TUICallKit features are only available after a successful login, so please carefully verify that the relevant parameters are correctly configured:
|
|
154
|
+
|
|
155
|
+
> **Note:**
|
|
156
|
+
> In the sample code, the login API is called directly. However, in real projects, it is **strongly recommended to call TUICallKit's login service after completing your own user authentication flow**. This avoids business logic confusion or data inconsistencies caused by premature login calls, and better adapts to your project's existing user management and permission control system.
|
|
157
|
+
>
|
|
158
|
+
|
|
159
|
+
[ArkTS]
|
|
160
|
+
``` typescript
|
|
161
|
+
import { LoginStore } from '@tencentcloud/atomicxcore'
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
await LoginStore.shared().login(
|
|
165
|
+
1400000000, // Replace with your SDKAPPID
|
|
166
|
+
'userID', // Replace with your UserID
|
|
167
|
+
'userSig', // Replace with your UserSig
|
|
168
|
+
);
|
|
169
|
+
// login success
|
|
170
|
+
} catch (error) {
|
|
171
|
+
// login error
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Login API parameter reference:**
|
|
176
|
+
| Parameter | Type | Description |
|
|
177
|
+
| --- | --- | --- |
|
|
178
|
+
| `sdkAppID` | `number` | Obtained from the [console](https://console.cloud.tencent.com/trtc). Usually a 10-digit number starting with `140` or `160`. |
|
|
179
|
+
| `userID` | `string` | Unique ID of the current user. Only contains letters, numbers, hyphens, and underscores. To avoid multi-device login conflicts, **do not use** simple IDs like `1` or `123`. |
|
|
180
|
+
| `userSig` | `string` | Authentication ticket for Tencent Cloud. For more information, see How to Calculate and Use UserSig.<br>**Note:**<br>- Development: You can use the local [GenerateTestUserSig.genTestSig](https://github.com/Tencent-RTC/TUIKit_Harmony/blob/main/application/entry/src/main/ets/debug/GenerateTestUserSig.ts) function or the [UserSig Tool](https://console.cloud.tencent.com/im/tool-usersig) to generate a temporary userSig.<br>- Production: To prevent key leakage, always generate userSig on the server side. See Server-side UserSig Generation for details. |
|
|
181
|
+
|
|
182
|
+
### Step 4: Set Nickname and Avatar [Optional]
|
|
183
|
+
|
|
184
|
+
First-time users have no avatar or nickname. Use the `setSelfInfo` API from `LoginStore` to set personal information:
|
|
185
|
+
``` typescript
|
|
186
|
+
import { LoginStore, UserProfile, ErrorInfo } from '@tencentcloud/atomicxcore';
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
await LoginStore.shared().setSelfInfo(new UserProfile('userID', 'userName', 'avatarURL'));
|
|
190
|
+
console.info("setSelfInfo success");
|
|
191
|
+
} catch (error) {
|
|
192
|
+
const err = error as ErrorInfo;
|
|
193
|
+
console.error(`setSelfInfo failed [code: ${err.code}] ${err.message}`);
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**setSelfInfo API parameter reference:**
|
|
198
|
+
| Parameter/Return | Type | Description |
|
|
199
|
+
| --- | --- | --- |
|
|
200
|
+
| `userProfile` | `UserProfile` | Core user profile model containing:<br>- userID: The user ID to set information for.<br>- nickname: Nickname.<br>- avatarURL: Avatar URL. |
|
|
201
|
+
|
|
202
|
+
### Step 5: Initiate a Call
|
|
203
|
+
|
|
204
|
+
The caller can initiate a voice or video call by calling the `calls` function and specifying the call type and callee's userID. The `calls` API supports both one-to-one and group calls. When userIDList contains one userID, it is a one-to-one call; when it contains multiple userIDs, it is a group call.
|
|
205
|
+
``` typescript
|
|
206
|
+
import { TUICallKit, CallMediaType } from '@tencentcloud/tuicallkit';
|
|
207
|
+
import { ErrorInfo } from '@tencentcloud/atomicxcore';
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
await TUICallKit.createInstance(getContext(this)).calls(['mike'], CallMediaType.audio);
|
|
211
|
+
// Success handling
|
|
212
|
+
} catch (error) {
|
|
213
|
+
const err = error as ErrorInfo;
|
|
214
|
+
// Failure handling
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
| Parameter | Type | Description |
|
|
219
|
+
|---------|---------|---------|
|
|
220
|
+
| userIdList | string[] | List of target user IDs. |
|
|
221
|
+
| mediaType | CallMediaType | Call media type, e.g., video call or voice call. |
|
|
222
|
+
| params? | CallParams | Call extension parameters, e.g., room ID, call invitation timeout, etc. |
|
|
223
|
+
|
|
224
|
+
### Step 6: Accept a Call
|
|
225
|
+
|
|
226
|
+
After the callee completes login, when the caller initiates a call, the callee receives a call invitation accompanied by a ringtone and vibration.
|
|
227
|
+
|
|
228
|
+
## More Features
|
|
229
|
+
|
|
230
|
+
### Enable Incoming Call Banner
|
|
231
|
+
|
|
232
|
+
You can call the `enableIncomingBanner` API to enable/disable the incoming call banner display. This feature is disabled by default (`false`). When the callee receives a call, a full-screen call waiting UI is shown by default. When enabled, a banner notification is shown first, then switches to the full-screen call UI as needed.
|
|
233
|
+
|
|
234
|
+
``` typescript
|
|
235
|
+
import { TUICallKit } from '@tencentcloud/tuicallkit';
|
|
236
|
+
|
|
237
|
+
TUICallKit.createInstance(context).enableIncomingBanner(true);
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**Details:** Default is `false`. After the callee receives an invitation, a full-screen call waiting UI is shown by default. When enabled, a banner is shown first, then the full-screen call UI is launched as needed.
|
|
241
|
+
|
|
242
|
+
### Group Calls
|
|
243
|
+
|
|
244
|
+
When the caller uses the `calls` method to initiate a call with more than one user in the callee list, it is automatically treated as a group call. Other members can join via the `join` method.
|
|
245
|
+
- **Initiate a group call:** When using `calls` with more than one user in the `userIdList`, it is automatically treated as a group call.
|
|
246
|
+
|
|
247
|
+
``` typescript
|
|
248
|
+
import { TUICallKit, CallMediaType } from '@tencentcloud/tuicallkit';
|
|
249
|
+
import { ErrorInfo } from '@tencentcloud/atomicxcore';
|
|
250
|
+
|
|
251
|
+
try {
|
|
252
|
+
await TUICallKit.createInstance(getContext(this)).calls(['mike','tate'], CallMediaType.audio);
|
|
253
|
+
// Success handling
|
|
254
|
+
} catch (error) {
|
|
255
|
+
const err = error as ErrorInfo;
|
|
256
|
+
// Failure handling
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
- **Join a group call:** Use the `join` method to join a specified group call.
|
|
260
|
+
|
|
261
|
+
``` typescript
|
|
262
|
+
import { TUICallKit } from '@tencentcloud/tuicallkit';
|
|
263
|
+
|
|
264
|
+
await TUICallKit.createInstance(context).join('your_call_id');
|
|
265
|
+
```
|
|
266
|
+
| Parameter | Type | Description |
|
|
267
|
+
|---------|---------|---------|
|
|
268
|
+
| callId | string | Unique identifier of this call. |
|
|
269
|
+
|
|
270
|
+
### Ringtone Settings
|
|
271
|
+
|
|
272
|
+
You can set the default ringtone, mute mode for incoming calls, and offline push ringtone:
|
|
273
|
+
- **Set default ringtone (Method 1):** If you integrated TUICallKit via source code dependency, you can replace the ringtone resource files ([dialing tone](https://github.com/Tencent-RTC/TUIKit_Harmony/blob/main/call/src/main/resources/rawfile/phone_dialing.m4a), [ringing tone](https://github.com/Tencent-RTC/TUIKit_Harmony/blob/main/call/src/main/resources/rawfile/phone_ringing.mp3)) to set custom default ringtones.
|
|
274
|
+
|
|
275
|
+
- **Set default ringtone (Method 2):** Use the `setCallingBell` API to set the incoming call ringtone for the callee.
|
|
276
|
+
|
|
277
|
+
``` typescript
|
|
278
|
+
import { TUICallKit } from '@tencentcloud/tuicallkit';
|
|
279
|
+
|
|
280
|
+
TUICallKit.createInstance(context).setCallingBell('***/callingBell.mp3');
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Details:** Only local file paths are accepted. Ensure the file directory is accessible by the application. The ringtone setting is bound to the device — it persists even when switching users. To restore the default ringtone, pass an empty filePath.
|
|
284
|
+
|
|
285
|
+
| Parameter | Type | Description |
|
|
286
|
+
|---------|---------|---------|
|
|
287
|
+
| filePath | string | Path to the ringtone file. |
|
|
288
|
+
|
|
289
|
+
- **Mute mode for incoming calls:** Use the `enableMuteMode` API to enable mute mode.
|
|
290
|
+
|
|
291
|
+
``` typescript
|
|
292
|
+
import { TUICallKit } from '@tencentcloud/tuicallkit';
|
|
293
|
+
|
|
294
|
+
TUICallKit.createInstance(context).enableMuteMode(true);
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
**Details:** When enabled, no ringtone is played when receiving a call request.
|
|
298
|
+
|
|
299
|
+
## Customize Your UI
|
|
300
|
+
|
|
301
|
+
### Replace Icon Buttons
|
|
302
|
+
|
|
303
|
+
You can directly replace the icons in the [src/main/resources/base/media](https://github.com/Tencent-RTC/TUIKit_Harmony/tree/main/call/src/main/resources/base/media) folder to ensure consistent icon styles throughout your app. Below are the basic function buttons — replace the corresponding icons to match your business scenario.
|
|
304
|
+
|
|
305
|
+
Common icon file list:
|
|
306
|
+
| Icon | Filename | Description |
|
|
307
|
+
| --- | --- | --- |
|
|
308
|
+
| | icon_dialing.png | Accept call icon |
|
|
309
|
+
| | icon_hangup.png | Hang up call icon |
|
|
310
|
+
| | icon_mute_on.png | Mute microphone icon |
|
|
311
|
+
| | icon_handsfree.png | Disable speaker icon |
|
|
312
|
+
| | icon_camera_off.png | Disable camera icon |
|
|
313
|
+
|
|
314
|
+
## FAQ
|
|
315
|
+
|
|
316
|
+
### Is there a sample oh-package.json5 configuration for reference?
|
|
317
|
+
|
|
318
|
+
You can refer to the `oh-package.json5` sample file in the GitHub TUIKit_Harmony [application](https://github.com/Tencent-RTC/TUIKit_Harmony/tree/main/application) project.
|