tencent cloud

Mobile Live Video Broadcasting

LikeStore

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-11-02 17:31:52

Introduction

LikeStore provides a complete set of like management APIs, including sending likes, listening to like events, and getting like states. Through this class, you can implement like interaction features in live rooms.
Notice:
Use the create(liveID:)factory method to create a LikeStore instance, which requires a valid live room ID.
Note:
Like state updates are delivered through the state publisher. Subscribe to it to receive real-time updates of like data in the room.

Features

Like Sending: Support sending likes to the current room.
Like State: Get the accumulated like count of the current room.
Event Listening: Listen to like receiving events.

Subscribable Data

LikeState fields are described below:
Property
Type
Description
totalLikeCount
UInt
Total accumulated like count of the current live room/voice chat room, supporting real-time updates and subscription listening.

API List

Function
Description
create
Create like management instance.
Like event publisher.
sendLike
Send likes.

Creating Instance

create

Create a like management instance.
public static func create(liveID: String) -> LikeStore {
let store: LikeStoreImpl = StoreFactory.shared.getStore(roomID: liveID)
return store
}
Version
Supported since version 3.5.
Parameters
Parameter
Type
Description
liveID
String
Live room ID.

Observing State and Events

likeEventPublisher

Like event publisher.

Like Operations

sendLike

Send likes to the current room. All users who have subscribed to like events will receive this like notification.
public func sendLike(count: UInt = 1, completion: CompletionClosure?) {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.
Parameters
Parameter
Type
Description
count
UInt
Like count, default is 1.
completion
Completion callback (success/failure status).

Data Structures

LikeState

Like state, used to display and subscribe to like information in live rooms/voice chat rooms.
Property
Type
Description
totalLikeCount
UInt
Total accumulated like count of the current live room/voice chat room, supporting real-time updates and subscription listening.

LikeListener

Like event, used to receive like dynamics in live rooms/voice chat rooms.
This listener is used to receive like dynamics in live rooms/voice chat rooms.
Methods
onReceiveLikesMessage: Event callback for receiving new like messages. When other audiences send likes in the live room/voice chat room, this event will be triggered and return relevant information.
case onReceiveLikesMessage(liveID: String, totalLikesReceived: UInt, sender: LiveUserInfo)
Parameter
Type
Description
liveID
String
Live room ID.
totalLikesReceived
UInt
Number of new likes received this time.
sender
Like sender information.

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan