Live SDKs iOS v1
Live SDKs iOS
Live SDKs
iOS
Version 1

Add reactions to a live event

Copy link

When participating in a live event, adding the reactions function can help users be more engaged with the event and provide feedback from each other. This function is similar to the reactions you might have seen in Instagram or YouTube live streams.


Send reactions to others

Copy link

During the live event, the host and participants can use reaction keys to express their feelings.

The increaseReactionCount method is called to increase the count of a particular reaction key. For example, to send a heart, call the method with "heart" as the parameter.

liveEvent.increaseReactionCount("heart") { reactions, error in
    guard let reactions = reactions, error == nil else {
        return // Error occurred while increasing the reaction count.
    }

    // Reaction count successfully increased.
}

The increaseReactionCount method internally uses the openChannel object to increase the meta counter for the specified reaction key.


Show reaction counts

Copy link

Users in the live event will receive update on the reaction counts as it updates through the LiveEventListener interface. You can apply special effects to show reaction counts such as animated hearts flying across the screen.

protocol LiveEventDelegate {
    func didReactionCountUpdate(_ liveEvent: LiveEvent, key: String, count: Int)
}

class MyClass : LiveEventDelegate {
    func didReactionCountUpdate(_ liveEvent: LiveEvent, key: String, count: Int) {
        // update the UI to reflect the new count for the specified reaction key
    }
}