Emojis

Learn how to use emojis for the web

The Emoji Extension parses emojis and converts them to images. Mobile platforms already handle this smoothly.

This is only required for the web.

Settings

Login to the CometChat Dashboard and on the Extensions page simply add the Emojis extension.

How does it work?

Once the extension has been enabled from the Dashboard, recipients will receive metadata with the emojified message. Here is a sample response:

"@injected": {
  "extensions": {
    "emojis": {
      “emojified_message”: <message>
    }
  }
}

If the data is missing, it means that the extension has timed out.

Implementation

At the recipients' end, from the message object, you can fetch the metadata by calling the getMetadata() method. Using this metadata, you can fetch the emojified message.

var metadata = message.getMetadata();
if (metadata != null) {
  var injectedObject = metadata["@injected"];
  if (injectedObject != null && injectedObject.hasOwnProperty("extensions")) {
    var extensionsObject = injectedObject["extensions"];
    if (extensionsObject != null &&
      extensionsObject.hasOwnProperty("emojis")){
      var emojiObject = extensionsObject["emojis"];
      var emojified_message = emojiObject["emojified_message"];
    }
  }
}

As mentioned earlier, the emojis are very well handled by the mobile platforms. When it comes to the web, it needs to be done explicitly.
You can use libraries like EmojiOne in your Web application for adding a feature to send emojis.


Did this page help you?