@tencent-rtc/mcp 1.3.2 → 1.3.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/package.json +1 -1
- package/resource/doc/livekit/live/android/live-audience-list.md +334 -0
- package/resource/doc/livekit/live/android/live-audio-effect.md +380 -0
- package/resource/doc/livekit/live/android/live-barrage.md +565 -0
- package/resource/doc/livekit/live/android/live-base-beauty.md +275 -0
- package/resource/doc/livekit/live/android/live-co-guest-interaction.md +629 -0
- package/resource/doc/livekit/live/android/live-gift.md +822 -0
- package/resource/doc/livekit/live/android/live-host-interaction.md +888 -0
- package/resource/doc/livekit/live/android/live-integration.md +972 -0
- package/resource/doc/livekit/live/android/live-live-list.md +575 -0
- package/resource/doc/livekit/live/android/workflow.md +189 -0
- package/tools/common/record-prompt.js +2 -2
- package/tools/common/record-prompt.js.map +1 -1
- package/tools/definitions/get_native_live_extra_features_def.js +87 -0
- package/tools/definitions/get_native_live_extra_features_def.js.map +1 -0
- package/tools/definitions/get_native_live_interaction_def.js +74 -0
- package/tools/definitions/get_native_live_interaction_def.js.map +1 -0
- package/tools/definitions/get_native_live_uikit_integration_def.js +49 -0
- package/tools/definitions/get_native_live_uikit_integration_def.js.map +1 -0
- package/tools/definitions/record_prompt_def.js +42 -11
- package/tools/definitions/record_prompt_def.js.map +1 -1
- package/tools/definitions/record_result_def.js +1 -1
- package/tools/index.js +6 -0
- package/tools/index.js.map +1 -1
- package/tools/live/get-native-live-uikit-integration.js +101 -0
- package/tools/live/get-native-live-uikit-integration.js.map +1 -0
- package/tools/live/get-web-live-component-detail.js +1 -1
- package/tools/live/get-web-live-component-detail.js.map +1 -1
- package/tools/live/get-web-live-state-detail.js +1 -1
- package/tools/live/get-web-live-state-detail.js.map +1 -1
- package/tools/live/get-web-live-uikit-integration.js +6 -6
- package/tools/live/get-web-live-uikit-integration.js.map +1 -1
- package/tools/live/get_native_live_extra_features.js +105 -0
- package/tools/live/get_native_live_extra_features.js.map +1 -0
- package/tools/live/get_native_live_interaction.js +101 -0
- package/tools/live/get_native_live_interaction.js.map +1 -0
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
- /package/resource/doc/livekit/{vue → live/vue}/components/barrage.md +0 -0
- /package/resource/doc/livekit/{vue → live/vue}/components/co-guest-panel.md +0 -0
- /package/resource/doc/livekit/{vue → live/vue}/components/live-audience-list.md +0 -0
- /package/resource/doc/livekit/{vue → live/vue}/components/live-scene-panel.md +0 -0
- /package/resource/doc/livekit/{vue → live/vue}/components/live-view.md +0 -0
- /package/resource/doc/livekit/{vue → live/vue}/components/stream-mixer.md +0 -0
- /package/resource/doc/livekit/{vue → live/vue}/faq.md +0 -0
- /package/resource/doc/livekit/{vue → live/vue}/live-list-integration.md +0 -0
- /package/resource/doc/livekit/{vue → live/vue}/live-player-desk-integration.md +0 -0
- /package/resource/doc/livekit/{vue → live/vue}/live-player-h5-integration.md +0 -0
- /package/resource/doc/livekit/{vue → live/vue}/live-pusher-integration.md +0 -0
- /package/resource/doc/livekit/{vue → live/vue}/states/live-state.md +0 -0
- /package/resource/doc/livekit/{vue → live/vue}/workflow.md +0 -0
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
`GiftStore` is a dedicated module within **AtomicXCore** for managing live room gifting features. It enables you to build a complete gifting system for your live streaming application, supporting robust monetization and interactive experiences.
|
|
2
|
+
<table>
|
|
3
|
+
<tr>
|
|
4
|
+
<td rowspan="1" colSpan="1" >**Gift Panel**</td>
|
|
5
|
+
|
|
6
|
+
<td rowspan="1" colSpan="1" >**Barrage Gift**</td>
|
|
7
|
+
|
|
8
|
+
<td rowspan="1" colSpan="1" >**Full-Screen Gift**</td>
|
|
9
|
+
</tr>
|
|
10
|
+
|
|
11
|
+
<tr>
|
|
12
|
+
<td rowspan="1" colSpan="1" ></td>
|
|
13
|
+
|
|
14
|
+
<td rowspan="1" colSpan="1" ></td>
|
|
15
|
+
|
|
16
|
+
<td rowspan="1" colSpan="1" ></td>
|
|
17
|
+
</tr>
|
|
18
|
+
</table>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Core Features
|
|
22
|
+
- **Gift List Retrieval**: Retrieve gift panel data from the server, including gift categories and details.
|
|
23
|
+
|
|
24
|
+
- **Send Gift**: Viewers can send selected gifts and specify the quantity to the host.
|
|
25
|
+
|
|
26
|
+
- **Gift Event Broadcast:** Receive real-time gift events in the room for displaying gift animations and barrage notifications.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Core Concepts
|
|
30
|
+
<table>
|
|
31
|
+
<tr>
|
|
32
|
+
<td rowspan="1" colSpan="1" >**Core Concept**</td>
|
|
33
|
+
|
|
34
|
+
<td rowspan="1" colSpan="1" >**Type**</td>
|
|
35
|
+
|
|
36
|
+
<td rowspan="1" colSpan="1" >**Core Responsibilities & Description**</td>
|
|
37
|
+
</tr>
|
|
38
|
+
|
|
39
|
+
<tr>
|
|
40
|
+
<td rowspan="1" colSpan="1" >`Gift`</td>
|
|
41
|
+
|
|
42
|
+
<td rowspan="1" colSpan="1" >`data class`</td>
|
|
43
|
+
|
|
44
|
+
<td rowspan="1" colSpan="1" >Represents a gift data model, including ID, name, icon URL, animation resource URL (resourceURL), price (coins), and more.</td>
|
|
45
|
+
</tr>
|
|
46
|
+
|
|
47
|
+
<tr>
|
|
48
|
+
<td rowspan="1" colSpan="1" >`GiftCategory`</td>
|
|
49
|
+
|
|
50
|
+
<td rowspan="1" colSpan="1" >`data class`</td>
|
|
51
|
+
|
|
52
|
+
<td rowspan="1" colSpan="1" >Represents a gift category (e.g., "Popular", "Luxury"). Contains the category name and a list of Gift objects.</td>
|
|
53
|
+
</tr>
|
|
54
|
+
|
|
55
|
+
<tr>
|
|
56
|
+
<td rowspan="1" colSpan="1" >`GiftState`</td>
|
|
57
|
+
|
|
58
|
+
<td rowspan="1" colSpan="1" >`data class`</td>
|
|
59
|
+
|
|
60
|
+
<td rowspan="1" colSpan="1" >Represents the current state of the gift module. The core property, usableGifts, is a StateFlow containing the full gift list from the server.</td>
|
|
61
|
+
</tr>
|
|
62
|
+
|
|
63
|
+
<tr>
|
|
64
|
+
<td rowspan="1" colSpan="1" >`GiftEvent`</td>
|
|
65
|
+
|
|
66
|
+
<td rowspan="1" colSpan="1" >`abstract class`</td>
|
|
67
|
+
|
|
68
|
+
<td rowspan="1" colSpan="1" >Defines the event listener for gift events in the live room. Currently, only onReceiveGift is available; all users in the room receive this event when any user sends a gift.</td>
|
|
69
|
+
</tr>
|
|
70
|
+
|
|
71
|
+
<tr>
|
|
72
|
+
<td rowspan="1" colSpan="1" >`GiftStore`</td>
|
|
73
|
+
|
|
74
|
+
<td rowspan="1" colSpan="1" >`abstract class`</td>
|
|
75
|
+
|
|
76
|
+
<td rowspan="1" colSpan="1" >The core management class for gift features. Use it to fetch the gift list, send gifts, and receive gift events via listeners.</td>
|
|
77
|
+
</tr>
|
|
78
|
+
</table>
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## Implementation
|
|
82
|
+
|
|
83
|
+
### Step 1: Component Integration
|
|
84
|
+
|
|
85
|
+
> **Note:**
|
|
86
|
+
>
|
|
87
|
+
|
|
88
|
+
> To use the gifting system, activate either the **Free Trial,** or **Pro **edition. The number of configurable gifts depends on the selected package. For details, see the **Gift System** section in [Feature and Billing Description](https://write.woa.com/document/137771241658241024) and choose the package that fits your needs.
|
|
89
|
+
>
|
|
90
|
+
|
|
91
|
+
- **Video Live Streaming**: Please refer to [Quick Start](https://write.woa.com/document/194571606056804352) to integrate AtomicXCore.
|
|
92
|
+
|
|
93
|
+
- **Voice Chat Room**: Please refer to [Quick Start](https://write.woa.com/document/194571595678187521) to integrate AtomicXCore.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Step 2: Initialize and Listen for Gift Events
|
|
97
|
+
|
|
98
|
+
Obtain a `GiftStore` instance and set up listeners to receive gift events and updates to the gift list.
|
|
99
|
+
|
|
100
|
+
#### Implementation
|
|
101
|
+
1. **Get Instance**: Use `GiftStore.create(liveID) `to obtain a `GiftStore` instance for the current live room.
|
|
102
|
+
|
|
103
|
+
2. **Add Listener**: Add a `GiftListener` to receive `onReceiveGift` events.
|
|
104
|
+
|
|
105
|
+
3. **Subscribe to State**: Subscribe to `giftStore.giftState.usableGifts`to receive gift list updates.
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
#### Code Example
|
|
109
|
+
``` kotlin
|
|
110
|
+
import io.trtc.tuikit.atomicxcore.api.gift.Gift
|
|
111
|
+
import io.trtc.tuikit.atomicxcore.api.gift.GiftCategory
|
|
112
|
+
import io.trtc.tuikit.atomicxcore.api.gift.GiftListener
|
|
113
|
+
import io.trtc.tuikit.atomicxcore.api.gift.GiftStore
|
|
114
|
+
import io.trtc.tuikit.atomicxcore.api.live.LiveUserInfo
|
|
115
|
+
import kotlinx.coroutines.flow.StateFlow
|
|
116
|
+
import kotlinx.coroutines.flow.MutableStateFlow
|
|
117
|
+
import kotlinx.coroutines.flow.asStateFlow
|
|
118
|
+
import kotlinx.coroutines.CoroutineScope
|
|
119
|
+
import kotlinx.coroutines.Dispatchers
|
|
120
|
+
import kotlinx.coroutines.launch
|
|
121
|
+
|
|
122
|
+
class GiftManager(
|
|
123
|
+
private val liveId: String
|
|
124
|
+
) {
|
|
125
|
+
private val giftStore: GiftStore = GiftStore.create(liveId)
|
|
126
|
+
private val coroutineScope = CoroutineScope(Dispatchers.Main)
|
|
127
|
+
// Expose gift list externally
|
|
128
|
+
private val _giftList = MutableStateFlow<List<GiftCategory>>(emptyList())
|
|
129
|
+
val giftList: StateFlow<List<GiftCategory>> = _giftList.asStateFlow()
|
|
130
|
+
|
|
131
|
+
init {
|
|
132
|
+
setupGiftListener()
|
|
133
|
+
subscribeToGiftState()
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Subscribe to gift events
|
|
137
|
+
private fun setupGiftListener() {
|
|
138
|
+
giftStore.addGiftListener(object : GiftListener() {
|
|
139
|
+
override fun onReceiveGift(liveID: String, gift: Gift, count: Int, sender: LiveUserInfo) {
|
|
140
|
+
// Forward event to UI layer for processing
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Subscribe to gift list state
|
|
146
|
+
private fun subscribeToGiftState() {
|
|
147
|
+
coroutineScope.launch(Dispatchers.Main) {
|
|
148
|
+
giftStore.giftState.usableGifts.collect { giftList ->
|
|
149
|
+
_giftList.value = giftList
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### Gift List Structure Parameters
|
|
157
|
+
- **GiftCategory Parameter Description**
|
|
158
|
+
|
|
159
|
+
<table>
|
|
160
|
+
<tr>
|
|
161
|
+
<td rowspan="1" colSpan="1" >**Parameter**</td>
|
|
162
|
+
|
|
163
|
+
<td rowspan="1" colSpan="1" >**Type**</td>
|
|
164
|
+
|
|
165
|
+
<td rowspan="1" colSpan="1" >**Description**</td>
|
|
166
|
+
</tr>
|
|
167
|
+
|
|
168
|
+
<tr>
|
|
169
|
+
<td rowspan="1" colSpan="1" >`categoryID`</td>
|
|
170
|
+
|
|
171
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
172
|
+
|
|
173
|
+
<td rowspan="1" colSpan="1" >Unique ID of the gift category.</td>
|
|
174
|
+
</tr>
|
|
175
|
+
|
|
176
|
+
<tr>
|
|
177
|
+
<td rowspan="1" colSpan="1" >`name`</td>
|
|
178
|
+
|
|
179
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
180
|
+
|
|
181
|
+
<td rowspan="1" colSpan="1" >Display name of the gift category.</td>
|
|
182
|
+
</tr>
|
|
183
|
+
|
|
184
|
+
<tr>
|
|
185
|
+
<td rowspan="1" colSpan="1" >`desc`</td>
|
|
186
|
+
|
|
187
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
188
|
+
|
|
189
|
+
<td rowspan="1" colSpan="1" >Description of the gift category.</td>
|
|
190
|
+
</tr>
|
|
191
|
+
|
|
192
|
+
<tr>
|
|
193
|
+
<td rowspan="1" colSpan="1" >`extensionInfo`</td>
|
|
194
|
+
|
|
195
|
+
<td rowspan="1" colSpan="1" >`Map<String, String>`</td>
|
|
196
|
+
|
|
197
|
+
<td rowspan="1" colSpan="1" >Extension information field.</td>
|
|
198
|
+
</tr>
|
|
199
|
+
|
|
200
|
+
<tr>
|
|
201
|
+
<td rowspan="1" colSpan="1" >`giftList`</td>
|
|
202
|
+
|
|
203
|
+
<td rowspan="1" colSpan="1" >`List`</td>
|
|
204
|
+
|
|
205
|
+
<td rowspan="1" colSpan="1" >Array of Gift objects in this category.</td>
|
|
206
|
+
</tr>
|
|
207
|
+
</table>
|
|
208
|
+
|
|
209
|
+
- **Gift Parameter Description**
|
|
210
|
+
|
|
211
|
+
<table>
|
|
212
|
+
<tr>
|
|
213
|
+
<td rowspan="1" colSpan="1" >**Parameter**</td>
|
|
214
|
+
|
|
215
|
+
<td rowspan="1" colSpan="1" >**Type**</td>
|
|
216
|
+
|
|
217
|
+
<td rowspan="1" colSpan="1" >**Description**</td>
|
|
218
|
+
</tr>
|
|
219
|
+
|
|
220
|
+
<tr>
|
|
221
|
+
<td rowspan="1" colSpan="1" >`giftID`</td>
|
|
222
|
+
|
|
223
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
224
|
+
|
|
225
|
+
<td rowspan="1" colSpan="1" >Unique ID of the gift.</td>
|
|
226
|
+
</tr>
|
|
227
|
+
|
|
228
|
+
<tr>
|
|
229
|
+
<td rowspan="1" colSpan="1" >`name`</td>
|
|
230
|
+
|
|
231
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
232
|
+
|
|
233
|
+
<td rowspan="1" colSpan="1" >Display name of the gift.</td>
|
|
234
|
+
</tr>
|
|
235
|
+
|
|
236
|
+
<tr>
|
|
237
|
+
<td rowspan="1" colSpan="1" >`desc`</td>
|
|
238
|
+
|
|
239
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
240
|
+
|
|
241
|
+
<td rowspan="1" colSpan="1" >Description of the gift.</td>
|
|
242
|
+
</tr>
|
|
243
|
+
|
|
244
|
+
<tr>
|
|
245
|
+
<td rowspan="1" colSpan="1" >`iconURL`</td>
|
|
246
|
+
|
|
247
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
248
|
+
|
|
249
|
+
<td rowspan="1" colSpan="1" >Gift icon URL.</td>
|
|
250
|
+
</tr>
|
|
251
|
+
|
|
252
|
+
<tr>
|
|
253
|
+
<td rowspan="1" colSpan="1" >`resourceURL`</td>
|
|
254
|
+
|
|
255
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
256
|
+
|
|
257
|
+
<td rowspan="1" colSpan="1" >Gift animation resource URL.</td>
|
|
258
|
+
</tr>
|
|
259
|
+
|
|
260
|
+
<tr>
|
|
261
|
+
<td rowspan="1" colSpan="1" >`level`</td>
|
|
262
|
+
|
|
263
|
+
<td rowspan="1" colSpan="1" >`Long`</td>
|
|
264
|
+
|
|
265
|
+
<td rowspan="1" colSpan="1" >Gift level.</td>
|
|
266
|
+
</tr>
|
|
267
|
+
|
|
268
|
+
<tr>
|
|
269
|
+
<td rowspan="1" colSpan="1" >`coins`</td>
|
|
270
|
+
|
|
271
|
+
<td rowspan="1" colSpan="1" >`Long`</td>
|
|
272
|
+
|
|
273
|
+
<td rowspan="1" colSpan="1" >Gift price.</td>
|
|
274
|
+
</tr>
|
|
275
|
+
|
|
276
|
+
<tr>
|
|
277
|
+
<td rowspan="1" colSpan="1" >`extensionInfo`</td>
|
|
278
|
+
|
|
279
|
+
<td rowspan="1" colSpan="1" >`Map<String, String>`</td>
|
|
280
|
+
|
|
281
|
+
<td rowspan="1" colSpan="1" >Extension information field.</td>
|
|
282
|
+
</tr>
|
|
283
|
+
</table>
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
### Step 3: Retrieve Gift List
|
|
287
|
+
|
|
288
|
+
Call the `refreshUsableGifts` method to fetch gift data from the server.
|
|
289
|
+
|
|
290
|
+
#### Implementation
|
|
291
|
+
1. **Call API**: Call `giftStore.refreshUsableGifts()` at the appropriate time (e.g., after entering the live room).
|
|
292
|
+
|
|
293
|
+
2. **Handle Callback**: Optionally handle the completion callback to determine the result.
|
|
294
|
+
|
|
295
|
+
3. **Receive Data**: After a successful fetch, the updated usableGifts list is delivered automatically via your subscription to `giftStore.giftState.usableGifts`.
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
#### Code Example
|
|
299
|
+
``` kotlin
|
|
300
|
+
class GiftManager(
|
|
301
|
+
private val liveId: String
|
|
302
|
+
) {
|
|
303
|
+
private val giftStore: GiftStore = GiftStore.create(liveId)
|
|
304
|
+
|
|
305
|
+
// Refresh the gift list from the server
|
|
306
|
+
fun fetchGiftList() {
|
|
307
|
+
giftStore.refreshUsableGifts(object : CompletionHandler {
|
|
308
|
+
override fun onSuccess() {
|
|
309
|
+
println("Gift list fetched successfully")
|
|
310
|
+
// Data will be updated via the giftState subscription
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
override fun onFailure(code: Int, desc: String) {
|
|
314
|
+
println("Failed to fetch gift list: $desc")
|
|
315
|
+
}
|
|
316
|
+
})
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Step 4: Send Gift
|
|
322
|
+
|
|
323
|
+
When a user selects a gift and clicks send, call the `sendGift` API.
|
|
324
|
+
|
|
325
|
+
#### Implementation
|
|
326
|
+
1. **Get Parameters**: Obtain the selected `giftID` and `quantity (count)` from the UI.
|
|
327
|
+
|
|
328
|
+
2. **Call API**: Call `giftStore.sendGift(giftID, count, completion)`.
|
|
329
|
+
|
|
330
|
+
3. **Handle Callback**: Use the completion `callback` to handle failures (e.g., insufficient balance). UI updates (animations, barrage) after a successful send should be triggered by the `onReceiveGift` event.
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
#### Code Example
|
|
334
|
+
``` kotlin
|
|
335
|
+
class GiftManager(
|
|
336
|
+
private val liveId: String
|
|
337
|
+
) {
|
|
338
|
+
private val giftStore: GiftStore = GiftStore.create(liveId)
|
|
339
|
+
|
|
340
|
+
// Send a gift
|
|
341
|
+
fun sendGift(giftID: String, count: Int) {
|
|
342
|
+
giftStore.sendGift(giftID, count, object : CompletionHandler {
|
|
343
|
+
override fun onSuccess() {
|
|
344
|
+
println("Gift $giftID sent successfully")
|
|
345
|
+
// All users, including the sender, will receive the onReceiveGift event
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
override fun onFailure(code: Int, desc: String) {
|
|
349
|
+
println("Gift send failed: $desc")
|
|
350
|
+
// Prompt user if needed, e.g., "Insufficient balance" or "Network error"
|
|
351
|
+
}
|
|
352
|
+
})
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
#### **sendGift API Parameters**
|
|
358
|
+
<table>
|
|
359
|
+
<tr>
|
|
360
|
+
<td rowspan="1" colSpan="1" >**Parameter Name**</td>
|
|
361
|
+
|
|
362
|
+
<td rowspan="1" colSpan="1" >**Type**</td>
|
|
363
|
+
|
|
364
|
+
<td rowspan="1" colSpan="1" >**Description**</td>
|
|
365
|
+
</tr>
|
|
366
|
+
|
|
367
|
+
<tr>
|
|
368
|
+
<td rowspan="1" colSpan="1" >`giftID`</td>
|
|
369
|
+
|
|
370
|
+
<td rowspan="1" colSpan="1" >`String`</td>
|
|
371
|
+
|
|
372
|
+
<td rowspan="1" colSpan="1" >Unique ID of the gift to send.</td>
|
|
373
|
+
</tr>
|
|
374
|
+
|
|
375
|
+
<tr>
|
|
376
|
+
<td rowspan="1" colSpan="1" >`count`</td>
|
|
377
|
+
|
|
378
|
+
<td rowspan="1" colSpan="1" >`Int`</td>
|
|
379
|
+
|
|
380
|
+
<td rowspan="1" colSpan="1" >Number of gifts to send.</td>
|
|
381
|
+
</tr>
|
|
382
|
+
|
|
383
|
+
<tr>
|
|
384
|
+
<td rowspan="1" colSpan="1" >`completion`</td>
|
|
385
|
+
|
|
386
|
+
<td rowspan="1" colSpan="1" >`CompletionHandler?`</td>
|
|
387
|
+
|
|
388
|
+
<td rowspan="1" colSpan="1" >Callback invoked after sending completes.</td>
|
|
389
|
+
</tr>
|
|
390
|
+
</table>
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
## Advanced Features
|
|
394
|
+
|
|
395
|
+
The capabilities of `GiftStore` are closely tied to your backend services. This section explains how to build a feature-rich gifting system through server-side configuration and client integration.
|
|
396
|
+
|
|
397
|
+
### Gift Asset Configuration
|
|
398
|
+
|
|
399
|
+
Customize available gift types, categories, names, icons, prices, and animation effects to meet your operational and branding requirements.
|
|
400
|
+
|
|
401
|
+
#### Implementation
|
|
402
|
+
1. **Server-Side Configuration**: Use the `LiveKit` server REST API to manage gift information, categories, and multi-language support. See the [Gift Configuration Guide](https://write.woa.com/document/185130564680273920).
|
|
403
|
+
|
|
404
|
+
2. **Client Fetch**: On the client, call `refreshUsableGifts` to retrieve configuration data.
|
|
405
|
+
|
|
406
|
+
3. **UI Display**: Use the retrieved `List<GiftCategory>` to populate the gift panel.
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
#### Configuration Sequence Diagram
|
|
410
|
+
|
|
411
|
+

|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
#### Related REST API Interfaces Overview
|
|
415
|
+
<table>
|
|
416
|
+
<tr>
|
|
417
|
+
<td rowspan="1" colSpan="1" >**Interface Category**</td>
|
|
418
|
+
|
|
419
|
+
<td rowspan="1" colSpan="1" >**Interface**</td>
|
|
420
|
+
|
|
421
|
+
<td rowspan="1" colSpan="1" >**Request Example**</td>
|
|
422
|
+
</tr>
|
|
423
|
+
|
|
424
|
+
<tr>
|
|
425
|
+
<td rowspan="3" colSpan="1" >**Gift Management**</td>
|
|
426
|
+
|
|
427
|
+
<td rowspan="1" colSpan="1" >Add Gift Information</td>
|
|
428
|
+
|
|
429
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185130814885187584)</td>
|
|
430
|
+
</tr>
|
|
431
|
+
|
|
432
|
+
<tr>
|
|
433
|
+
<td rowspan="1" colSpan="1" >Delete Gift Information</td>
|
|
434
|
+
|
|
435
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185131021432451072)</td>
|
|
436
|
+
</tr>
|
|
437
|
+
|
|
438
|
+
<tr>
|
|
439
|
+
<td rowspan="1" colSpan="1" >Query Gift Information</td>
|
|
440
|
+
|
|
441
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185130925608591360)</td>
|
|
442
|
+
</tr>
|
|
443
|
+
|
|
444
|
+
<tr>
|
|
445
|
+
<td rowspan="3" colSpan="1" >**Gift Category Management**</td>
|
|
446
|
+
|
|
447
|
+
<td rowspan="1" colSpan="1" >Add Gift Category Information</td>
|
|
448
|
+
|
|
449
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185131054187974656)</td>
|
|
450
|
+
</tr>
|
|
451
|
+
|
|
452
|
+
<tr>
|
|
453
|
+
<td rowspan="1" colSpan="1" >Delete Specific Gift Category Information</td>
|
|
454
|
+
|
|
455
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185131288984932352)</td>
|
|
456
|
+
</tr>
|
|
457
|
+
|
|
458
|
+
<tr>
|
|
459
|
+
<td rowspan="1" colSpan="1" >Get Specific Gift Category Information</td>
|
|
460
|
+
|
|
461
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185131164168736768)</td>
|
|
462
|
+
</tr>
|
|
463
|
+
|
|
464
|
+
<tr>
|
|
465
|
+
<td rowspan="3" colSpan="1" >**Gift Relationship Management**</td>
|
|
466
|
+
|
|
467
|
+
<td rowspan="1" colSpan="1" >Add Relationship between a Specific Gift Category and Gift</td>
|
|
468
|
+
|
|
469
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185131388068356096)</td>
|
|
470
|
+
</tr>
|
|
471
|
+
|
|
472
|
+
<tr>
|
|
473
|
+
<td rowspan="1" colSpan="1" >Delete Relationship between a Specific Gift Category and Gift</td>
|
|
474
|
+
|
|
475
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185131491225227264)</td>
|
|
476
|
+
</tr>
|
|
477
|
+
|
|
478
|
+
<tr>
|
|
479
|
+
<td rowspan="1" colSpan="1" >Get Gift Relationships under a Specific Gift Category</td>
|
|
480
|
+
|
|
481
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185131634710056960)</td>
|
|
482
|
+
</tr>
|
|
483
|
+
|
|
484
|
+
<tr>
|
|
485
|
+
<td rowspan="6" colSpan="1" >**Gift Multi-language Management**</td>
|
|
486
|
+
|
|
487
|
+
<td rowspan="1" colSpan="1" >Add Gift Multi-language Information</td>
|
|
488
|
+
|
|
489
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185131766094020608)</td>
|
|
490
|
+
</tr>
|
|
491
|
+
|
|
492
|
+
<tr>
|
|
493
|
+
<td rowspan="1" colSpan="1" >Delete Specific Gift Multi-language Information</td>
|
|
494
|
+
|
|
495
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185132041665441792)</td>
|
|
496
|
+
</tr>
|
|
497
|
+
|
|
498
|
+
<tr>
|
|
499
|
+
<td rowspan="1" colSpan="1" >Get Gift Multi-language Information</td>
|
|
500
|
+
|
|
501
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185131910582956032)</td>
|
|
502
|
+
</tr>
|
|
503
|
+
|
|
504
|
+
<tr>
|
|
505
|
+
<td rowspan="1" colSpan="1" >Add Gift Category Multi-language Information</td>
|
|
506
|
+
|
|
507
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185132145524985856)</td>
|
|
508
|
+
</tr>
|
|
509
|
+
|
|
510
|
+
<tr>
|
|
511
|
+
<td rowspan="1" colSpan="1" >Delete Specific Gift Category Multi-language Information</td>
|
|
512
|
+
|
|
513
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185132396568891392)</td>
|
|
514
|
+
</tr>
|
|
515
|
+
|
|
516
|
+
<tr>
|
|
517
|
+
<td rowspan="1" colSpan="1" >Get Gift Category Multi-language Information</td>
|
|
518
|
+
|
|
519
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/185132283123777536)</td>
|
|
520
|
+
</tr>
|
|
521
|
+
</table>
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
### Billing and Gift Deduction Process
|
|
525
|
+
|
|
526
|
+
When a viewer sends a gift, ensure their account balance is sufficient and complete the deduction before triggering the gift effect playback and broadcast.
|
|
527
|
+
|
|
528
|
+
#### Implementation
|
|
529
|
+
1. **Backend Callback Configuration**: Configure your billing system's callback URL in the LiveKit backend. See [Callback Configuration Documentation](https://write.woa.com/document/155612057789870080).
|
|
530
|
+
|
|
531
|
+
2. **Client Send**: The client calls `sendGift`.
|
|
532
|
+
|
|
533
|
+
3. **Backend Interaction**: The LiveKit backend calls your callback URL; your billing system processes the deduction and returns the result.
|
|
534
|
+
|
|
535
|
+
4. **Result Synchronization**: If successful, **AtomicXCore** broadcasts the `onReceiveGift` event; if failed, the completion callback of sendGift receives an error.
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
#### Call Flow
|
|
539
|
+
|
|
540
|
+

|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
#### Related REST API Interfaces Overview
|
|
544
|
+
<table>
|
|
545
|
+
<tr>
|
|
546
|
+
<td rowspan="1" colSpan="1" >**Interface**</td>
|
|
547
|
+
|
|
548
|
+
<td rowspan="1" colSpan="1" >**Description**</td>
|
|
549
|
+
|
|
550
|
+
<td rowspan="1" colSpan="1" >**Request Example**</td>
|
|
551
|
+
</tr>
|
|
552
|
+
|
|
553
|
+
<tr>
|
|
554
|
+
<td rowspan="1" colSpan="1" >**Callback Configuration - Callback before sending a gift**</td>
|
|
555
|
+
|
|
556
|
+
<td rowspan="1" colSpan="1" >The customer's backend can use this callback to decide whether to pass pre-gifting checks, etc.</td>
|
|
557
|
+
|
|
558
|
+
<td rowspan="1" colSpan="1" >[Example](https://write.woa.com/document/183772991768039424)</td>
|
|
559
|
+
</tr>
|
|
560
|
+
</table>
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
### Implement Full-Screen Gift Animation Playback
|
|
564
|
+
|
|
565
|
+
When a user sends a luxury gift (e.g., "Rocket", "Carnival"), play a full-screen animation (such as SVGA) to enhance engagement.
|
|
566
|
+
|
|
567
|
+
#### Implementation
|
|
568
|
+
|
|
569
|
+
**AtomicXCore** does not include a built-in gift animation player. Integrate a third-party library based on your requirements. Below is a comparison of two options:
|
|
570
|
+
<table>
|
|
571
|
+
<tr>
|
|
572
|
+
<td rowspan="1" colSpan="1" >**Comparison Item**</td>
|
|
573
|
+
|
|
574
|
+
<td rowspan="1" colSpan="1" >**Basic Solution (SVGAPlayer)**</td>
|
|
575
|
+
|
|
576
|
+
<td rowspan="1" colSpan="1" >**Gift AR (TCEffectPlayerKit)**</td>
|
|
577
|
+
</tr>
|
|
578
|
+
|
|
579
|
+
<tr>
|
|
580
|
+
<td rowspan="1" colSpan="1" >Billing</td>
|
|
581
|
+
|
|
582
|
+
<td rowspan="1" colSpan="1" >Free (open source)</td>
|
|
583
|
+
|
|
584
|
+
<td rowspan="1" colSpan="1" >Paid (requires license). See [Billing Guide](https://trtc.io/document/69949?product=beautyar&menulabel=core%20sdk&platform=android#X-Series-Capabilities)</td>
|
|
585
|
+
</tr>
|
|
586
|
+
|
|
587
|
+
<tr>
|
|
588
|
+
<td rowspan="1" colSpan="1" >Integration Method</td>
|
|
589
|
+
|
|
590
|
+
<td rowspan="1" colSpan="1" >Manual integration via Gradle</td>
|
|
591
|
+
|
|
592
|
+
<td rowspan="1" colSpan="1" >Requires additional integration and authentication</td>
|
|
593
|
+
</tr>
|
|
594
|
+
|
|
595
|
+
<tr>
|
|
596
|
+
<td rowspan="1" colSpan="1" >Supported Animation Formats</td>
|
|
597
|
+
|
|
598
|
+
<td rowspan="1" colSpan="1" >SVGA only</td>
|
|
599
|
+
|
|
600
|
+
<td rowspan="1" colSpan="1" >SVGA, PAG, WebP, Lottie, MP4, and more</td>
|
|
601
|
+
</tr>
|
|
602
|
+
|
|
603
|
+
<tr>
|
|
604
|
+
<td rowspan="1" colSpan="1" >Performance</td>
|
|
605
|
+
|
|
606
|
+
<td rowspan="1" colSpan="1" >Recommended SVGA file size ≤ 10MB</td>
|
|
607
|
+
|
|
608
|
+
<td rowspan="1" colSpan="1" >Supports larger files, better performance for complex/multiple/low-end scenarios</td>
|
|
609
|
+
</tr>
|
|
610
|
+
|
|
611
|
+
<tr>
|
|
612
|
+
<td rowspan="1" colSpan="1" >Recommended Scenario</td>
|
|
613
|
+
|
|
614
|
+
<td rowspan="1" colSpan="1" >Uniform SVGA format, controllable file size</td>
|
|
615
|
+
|
|
616
|
+
<td rowspan="1" colSpan="1" >Multiple formats or higher performance/device compatibility needs</td>
|
|
617
|
+
</tr>
|
|
618
|
+
</table>
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
This section demonstrates the basic solution. For the **Gift AR** see the [TCEffectPlayer Integration Guide](https://trtc.io/document/70531?product=beautyar&menulabel=core%20sdk&platform=android).
|
|
622
|
+
|
|
623
|
+
#### Basic Solution: Using SVGAPlayer
|
|
624
|
+
1. **Integrate SVGAPlayer**: Add the SVGAPlayer dependency to your build.gradle and sync the project.
|
|
625
|
+
|
|
626
|
+
``` gradle
|
|
627
|
+
dependencies {
|
|
628
|
+
// ... other dependencies
|
|
629
|
+
implementation 'com.github.yyued:SVGAPlayer-Android:2.6.1'
|
|
630
|
+
}
|
|
631
|
+
```
|
|
632
|
+
2. **Listen for Gift Events**: Subscribe to the `GiftListener` in `GiftStore`.
|
|
633
|
+
|
|
634
|
+
3. **Parse and Play**: On `onReceiveGift`, check if `gift.resourceURL` is a valid SVGA file. Use `SVGAParser` to parse and play the animation.
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
#### Code Example
|
|
638
|
+
``` kotlin
|
|
639
|
+
import android.os.Bundle
|
|
640
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
641
|
+
import com.opensource.svgaplayer.SVGAParser
|
|
642
|
+
import com.opensource.svgaplayer.SVGAVideoEntity
|
|
643
|
+
import com.opensource.svgaplayer.SVGAImageView
|
|
644
|
+
import io.trtc.tuikit.atomicxcore.api.gift.Gift
|
|
645
|
+
import io.trtc.tuikit.atomicxcore.api.gift.GiftListener
|
|
646
|
+
import io.trtc.tuikit.atomicxcore.api.gift.GiftStore
|
|
647
|
+
import io.trtc.tuikit.atomicxcore.api.live.LiveUserInfo
|
|
648
|
+
import java.net.URL
|
|
649
|
+
|
|
650
|
+
class LiveRoomActivity : AppCompatActivity() {
|
|
651
|
+
private lateinit var giftStore: GiftStore
|
|
652
|
+
private lateinit var svgaImageView: SVGAImageView
|
|
653
|
+
private lateinit var svgaParser: SVGAParser
|
|
654
|
+
|
|
655
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
656
|
+
super.onCreate(savedInstanceState)
|
|
657
|
+
setContentView(R.layout.activity_live_room)
|
|
658
|
+
setupSVGAPlayer()
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
private fun setupSVGAPlayer() {
|
|
662
|
+
svgaImageView = findViewById(R.id.svga_player)
|
|
663
|
+
svgaParser = SVGAParser(this)
|
|
664
|
+
svgaImageView.visibility = android.view.View.GONE
|
|
665
|
+
|
|
666
|
+
// Set the gift animation to play only once.
|
|
667
|
+
svgaImageView.loops = 1
|
|
668
|
+
|
|
669
|
+
// Set a completion callback to hide and clean up resources after playback.
|
|
670
|
+
svgaImageView.callback = object : SVGACallback {
|
|
671
|
+
override fun onFinished() {
|
|
672
|
+
svgaImageView.visibility = android.view.View.GONE
|
|
673
|
+
svgaImageView.clear()
|
|
674
|
+
}
|
|
675
|
+
override fun onPause() {}
|
|
676
|
+
override fun onRepeat() {}
|
|
677
|
+
override fun onStep(frame: Int, percentage: Double) {}
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
fun setupGiftSubscription(liveId: String) {
|
|
682
|
+
giftStore = GiftStore.create(liveId)
|
|
683
|
+
|
|
684
|
+
giftStore.addGiftListener(object : GiftListener() {
|
|
685
|
+
override fun onReceiveGift(liveID: String, gift: Gift, count: Int, sender: LiveUserInfo) {
|
|
686
|
+
if (gift.resourceURL.isNotEmpty()) {
|
|
687
|
+
try {
|
|
688
|
+
val url = URL(gift.resourceURL)
|
|
689
|
+
playAnimation(url)
|
|
690
|
+
} catch (e: Exception) {
|
|
691
|
+
println("Invalid animation URL: ${gift.resourceURL}")
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
})
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
private fun playAnimation(url: URL) {
|
|
699
|
+
svgaParser.decodeFromURL(url, object : SVGAParser.ParseCompletion {
|
|
700
|
+
override fun onComplete(videoItem: SVGAVideoEntity) {
|
|
701
|
+
runOnUiThread {
|
|
702
|
+
svgaImageView.setVideoItem(videoItem)
|
|
703
|
+
svgaImageView.visibility = android.view.View.VISIBLE
|
|
704
|
+
svgaImageView.startAnimation()
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
override fun onError() {
|
|
709
|
+
println("SVGA animation parsing failed")
|
|
710
|
+
// Optionally add retry or error reporting
|
|
711
|
+
}
|
|
712
|
+
})
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
### Display Gift Messages in the Barrage Area
|
|
718
|
+
|
|
719
|
+
When a user sends a gift, display a system message in the public barrage area (e.g., "[Viewer Nickname] sent [Gift Name] x [Quantity]") for all viewers.
|
|
720
|
+
|
|
721
|
+
#### Implementation
|
|
722
|
+
1. **Listen for Events**: Subscribe to the `GiftListener` in `giftStore`.
|
|
723
|
+
|
|
724
|
+
2. **Obtain Information**: On `onReceiveGift`, extract the sender, gift, and count.
|
|
725
|
+
|
|
726
|
+
3. **Get Barrage Store**: Use `BarrageStore.create(liveID)` for the current room.
|
|
727
|
+
|
|
728
|
+
4. **Compose Message**: Create a Barrage object, set `messageType = BarrageType.TEXT`, and set textContent to your message.
|
|
729
|
+
|
|
730
|
+
5. **Insert Locally**: Call `barrageStore.appendLocalTip(message: giftTip)` to add the message to the local barrage list.
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
#### Code Example
|
|
734
|
+
``` kotlin
|
|
735
|
+
import io.trtc.tuikit.atomicxcore.api.barrage.Barrage
|
|
736
|
+
import io.trtc.tuikit.atomicxcore.api.barrage.BarrageStore
|
|
737
|
+
import io.trtc.tuikit.atomicxcore.api.barrage.BarrageType
|
|
738
|
+
import io.trtc.tuikit.atomicxcore.api.gift.Gift
|
|
739
|
+
import io.trtc.tuikit.atomicxcore.api.gift.GiftListener
|
|
740
|
+
import io.trtc.tuikit.atomicxcore.api.gift.GiftStore
|
|
741
|
+
import io.trtc.tuikit.atomicxcore.api.live.LiveUserInfo
|
|
742
|
+
|
|
743
|
+
class LiveRoomManager(
|
|
744
|
+
private val liveId: String
|
|
745
|
+
) {
|
|
746
|
+
private val giftStore: GiftStore = GiftStore.create(liveId)
|
|
747
|
+
private val barrageStore: BarrageStore = BarrageStore.create(liveId)
|
|
748
|
+
|
|
749
|
+
private fun setupGiftToBarrageFlow() {
|
|
750
|
+
giftStore.addGiftListener(object : GiftListener() {
|
|
751
|
+
override fun onReceiveGift(liveID: String, gift: Gift, count: Int, sender: LiveUserInfo) {
|
|
752
|
+
val tipText = "sent ${gift.name} x $count"
|
|
753
|
+
val giftTip = Barrage(
|
|
754
|
+
liveID = liveID,
|
|
755
|
+
messageType = BarrageType.TEXT,
|
|
756
|
+
textContent = tipText
|
|
757
|
+
sender = sender
|
|
758
|
+
)
|
|
759
|
+
barrageStore.appendLocalTip(giftTip)
|
|
760
|
+
}
|
|
761
|
+
})
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
## API Documentation
|
|
767
|
+
|
|
768
|
+
For complete details on all public interfaces, properties, and methods of [GiftStore](https://tencent-rtc.github.io/TUIKit_Android/-atomic-x%20-core%20-a-p-i/io.trtc.tuikit.atomicxcore.api.gift/-gift-store/index.html) and related classes, see the official API documentation for [AtomicXCore](https://tencent-rtc.github.io/TUIKit_Android/index.html). Key stores referenced in this guide include:
|
|
769
|
+
<table>
|
|
770
|
+
<tr>
|
|
771
|
+
<td rowspan="1" colSpan="1" >**Store/Component**</td>
|
|
772
|
+
|
|
773
|
+
<td rowspan="1" colSpan="1" >**Feature Description**</td>
|
|
774
|
+
|
|
775
|
+
<td rowspan="1" colSpan="1" >**API Documentation**</td>
|
|
776
|
+
</tr>
|
|
777
|
+
|
|
778
|
+
<tr>
|
|
779
|
+
<td rowspan="1" colSpan="1" >GiftStore</td>
|
|
780
|
+
|
|
781
|
+
<td rowspan="1" colSpan="1" >Gift interactions: fetch gift list, send/receive gifts, listen for gift events (including sender and gift details).</td>
|
|
782
|
+
|
|
783
|
+
<td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_Android/-atomic-x%20-core%20-a-p-i/io.trtc.tuikit.atomicxcore.api.gift/-gift-store/index.html)</td>
|
|
784
|
+
</tr>
|
|
785
|
+
|
|
786
|
+
<tr>
|
|
787
|
+
<td rowspan="1" colSpan="1" >BarrageStore</td>
|
|
788
|
+
|
|
789
|
+
<td rowspan="1" colSpan="1" >Barrage features: send text/custom barrage, maintain barrage list, listen to barrage status in real time.</td>
|
|
790
|
+
|
|
791
|
+
<td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_Android/-atomic-x%20-core%20-a-p-i/io.trtc.tuikit.atomicxcore.api.barrage/-barrage-store/index.html)</td>
|
|
792
|
+
</tr>
|
|
793
|
+
</table>
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
## FAQs
|
|
797
|
+
|
|
798
|
+
### The gift list in GiftStore is empty. What should I do?
|
|
799
|
+
|
|
800
|
+
You must call `refreshUsableGifts(completion)` to fetch gift data from your backend. Ensure your backend is configured with gift data via the server REST API.
|
|
801
|
+
|
|
802
|
+
### How do I implement multi-language display for gifts (e.g., Chinese, English)?
|
|
803
|
+
|
|
804
|
+
Use the `GiftStore.setLanguage(language: String)` API before calling `refreshUsableGifts`, passing the target language code (e.g., "en" or "zh-CN"). The server will return gift names and descriptions in the specified language.
|
|
805
|
+
|
|
806
|
+
### I called sendGift, but the gift animation plays twice. Why?
|
|
807
|
+
|
|
808
|
+
The `onReceiveGift` event is broadcast to all room members, including the sender. If you update the UI both in the sendGift completion callback and in the `onReceiveGift` event, the animation will play twice.
|
|
809
|
+
- **Best Practice**: Only update the UI (e.g., play animations, show barrage) in the `onReceiveGift` event handler. Use the `sendGift` completion callback only for handling failures (such as "Send failed" or "Insufficient balance").
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
### Where is the gift deduction logic implemented?
|
|
813
|
+
|
|
814
|
+
Gift deduction is handled entirely by your billing system. AtomicXCore integrates with your billing system via a backend callback. When the client calls sendGift, your backend performs the deduction. After returning the result to the AtomicXCore backend, it determines whether to broadcast the gift event.
|
|
815
|
+
|
|
816
|
+
### Will gift notifications be blocked by mute or message frequency controls?
|
|
817
|
+
|
|
818
|
+
No. Gift notifications (`onReceiveGift` events) are not affected by mute or frequency controls and are always delivered reliably.
|
|
819
|
+
|
|
820
|
+
### What should I do if gift animation playback stutters?
|
|
821
|
+
|
|
822
|
+
Check your SVGA file size; the basic player recommends files no larger than 10MB. For large or complex animations, consider integrating the **Gift AR** provided by TUILiveKit for improved performance.
|