Reaction

Interactions are more fun when you can express yourself! Let users react using emojis, stickers, or thumbs up to messages.

Reaction Query

To query for a list of all reactions on the specific message in a channel, one must utilise EkoMessageRepository. We can observe this the same way as when we observe messages, the only thing difference is you will have to use messageId as the parameter. The operation will return an instance EkoCollection of EkoMessageReaction that contains the reaction name, message id, reactor id and reactor display name of the user who reacted to the message.

let reactionsCollection: EkoCollection<EkoMessageReaction> = messageRepository.allMessageReactions(withMessageId: message.messageId)

self.reactionsNotification = reactionsCollection.observe { [weak self] _, _ in
  // refresh tableview or the view
  self?.tableview.reloadData()
}

This method will return a LiveObject of all reactions of specific message in the specified channel. You can observe the LiveObject in order to update your view whenever you receive new reaction on that message.

Add Reaction

For adding a new reaction, we can use EkoMessageReactor to perform its operation. Initialize the reactor with the client and message and specify the reaction name.

let messageReactor = EkoMessageReactor(client: client, message: message)
messageReactor?.addReaction(withReaction: reaction, completion: { success, error })

Remove Reaction

In order to remove a new reaction, we can use EkoMessageReactor . Initialize the reactor with the client, message and specify the reaction name.

let messageReactor = EkoMessageReactor(client: client, message: message)
messageReactor?.removeReaction(withReaction: reaction, completion: { success, error })

Last updated