I have implemented a custom way to react to a certain message by holding down on the specific message.
I have also integrated with the SBD SDK and I can successfully make the request to addReaction and I get a success along with SBDReactionEvent object. However, when I query for the messages in a give channel and look into to the reactions property, no reaction has been recorded.
This is my code to add a reaction. Please let me know if I’m missing something.
func addReaction(to message: SBDBaseMessage, in channel: SBDGroupChannel, emoji: String) -> AnyPublisher<SBDReactionEvent?, Error> {
return Future {promise in
channel.addReaction(with: message, key: emoji) { (event, error) in
if let error = error {
promise(.failure(error))
}
else {
promise(.success(event))
}
}
}.eraseToAnyPublisher()
}
What key are you sending for your emoji? Some text or characters sent as emoji can be blocked and no error is returned. They are just not stored.
I used the example key from the documentation “smile”. Is this suppose to work? Or is there documentation around the keys that we can use or an API that we can get the keys from? Can you also give some examples of keys that work.
To know the list of emojis included in your plan, you can refer to this:
Example of a GET request: {{entrypoint}}/v3/emojis
You should see a response like:
{
"emojis": [
{
"url": "https://static.sendbird.com/icons/emoji_heart_eyes.png",
"key": "sendbird_emoji_heart_eyes"
},
{
"url": "https://static.sendbird.com/icons/emoji_laughing.png",
"key": "sendbird_emoji_laughing"
},
{
"url": "https://static.sendbird.com/icons/emoji_rage.png",
"key": "sendbird_emoji_rage"
},
{
"url": "https://static.sendbird.com/icons/emoji_sob.png",
"key": "sendbird_emoji_sob"
},
{
"url": "https://static.sendbird.com/icons/emoji_sweat_smile.png",
"key": "sendbird_emoji_sweat_smile"
},
{
"url": "https://static.sendbird.com/icons/emoji_thumbsdown.png",
"key": "sendbird_emoji_thumbsdown"
},
{
"url": "https://static.sendbird.com/icons/emoji_thumbsup.png",
"key": "sendbird_emoji_thumbsup"
}
]
}
These are the keys you can use. So, from iOS -based on the sample application we have here:
Open the GroupChannelChatViewController.swift
file and add this to the function clickSendUserMessageButton
for a quick test:
guard let um = userMessage else { return }
channel.addReaction(with: um, key: "sendbird_emoji_heart_eyes") { (event, error) in
if let error = error {
print("Error sending reaction: " + error.description)
} else {
print("OK")
}
}
The key you use for a smiling hearts eyes is sendbird_emoji_heart_eyes