Class CometChatHelper


  • public class CometChatHelper
    extends java.lang.Object
    • Constructor Detail

      • CometChatHelper

        public CometChatHelper()
    • Method Detail

      • processMessage

        public static BaseMessage processMessage​(JSONObject messageObject)
                                          throws JSONException
        This method helps to convert JSONObject of the message payload obtained from Push Notification
        Parameters:
        messageObject - JSONObject of the message payload
        Returns:
        An object of BaseMessage
        Throws:
        JSONException - * Thrown to indicate a problem with the JSON API. Such problems include
        • Attempts to parse or construct malformed documents
        • Use of null as a name
        • Use of numeric types not available to JSON, such as NaNs or infinities.
        • Lookups using an out of range index or nonexistent name
        • Type mismatches on lookups

        Although this is a checked exception, it is rarely recoverable. Most callers should simply wrap this exception in an unchecked exception and rethrow:

          public JSONArray toJSONObject() {
                                     try {
                                         JSONObject result = new JSONObject();
                                         ...
                                     } catch (JSONException e) {
                                         throw new RuntimeException(e);
                                     }
                                 }