Reaction

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

Reaction Data

There are 3 Reaction related methods on EkoMessage:

1. getReactionCount() returns Int, the total reaction count on the message.

2. getMyReactions() returns List<String>, a collection of reactions that have been added by the active user.

3. getReactions() returns EkoReactionMap, an extension of Map<String, Int> of reaction name and its count.

// To get reaction count of the message
val reactionCount = message.getReactionCount()

// To get a list of my reactions on the message
val myReactions = message.getMyReactions()

// To get a reaction map of the messsage
val reactionMap = message.getReactionMap()

// Count of a specific reactionName
val likeCount = reactionMap.getCount("like")

Add/Remove Reaction

You can choose to add/remove a reaction to/from a message by calling react() method on EkoMessage

 // Add a reaction
 message.react()
     .addReaction("like")
     .subscribe()

 // Remove a reaction
 message.react()
     .removeReaction("like")
     .subscribe()

Reaction Query

To query for a list of all reactions on a message:

message.getReactionCollection()
        .build()
        .query()
        .subscribe( { adapter.submitList(it) } )

This method will return a Flowable<PagedList<EkoReaction>> of all reactions in the specified message.

Last updated