Listen to events

Realtime events are delivered to the SDK via a websocket. These events can be subscribed to via the following methods

ComapiConfig config = new ComapiConfig()
   .messagingListener(listener /* extends MessagingListener */)
   .profileListener(listener /* extends ProfileListener */);
client.addListener(listener /* extends MessagingListener */);
client.addListener(listener /* extends ProfileListener */);
client.removeListener(listener /* extends MessagingListener */);
client.removeListener(listener /* extends ProfileListener */);

MessagingListener and ProfileListener are abstract with empty implementation of onEventName methods. Override some or all of them to receive socket events from foundation SDK. Real time events are available only when the application is in foreground (visible to the user). If app is put to the background use FCM to communicate messages to the user. Update the internal state after app is put back to foreground using services APIs.

Available events

Event NameDescription
ProfileUpdateEventSent when a user's profile is updated.
MessageSentEventSent when a new message appeared in a conversation. This event will also be delivered to the message sender.
MessageDeliveredEventSent when one of participants updated the message status to 'delivered'.
MessageReadEventSent when one of participants updated the message status to 'read'.
ParticipantAddedEventSent when a participant is added to a conversation. When a conversation is created, this event will also fire with the owner's profileId.
ParticipantUpdatedEventSent when a participant role is updated in a conversation.
ParticipantRemovedEventSent when a participant is removed from a conversation.
ConversationDeleteEventSent when a conversation is deleted.
ConversationUpdateEventSent when a conversation details were updated.
ConversationUndeleteEventSent when a conversation is restored.
ParticipantTypingEvent (from v1.0.2)Sent when 'isTyping' method has been called informing conversation participants that the user started typing a new message
ParticipantTypingOffEvent (from v1.0.2)Sent when 'isTyping' method has been called informing conversation participants that the user stopped typing a new message
// Event unique identifier.
getEventId()

// Event name/type.
getName()

In addition specific event type

// Profile unique identifier.
getProfileId();

//Time when the update event was published.
getPublishedOn();

//Revision of the profile details on the server.
getRevision();

//Gets profileId of an user that performed this update.
getCreatedBy();

//Gets profile update details.
getPayload();

// Tag specifying server data version.
getETag();
// Message unique identifier
getMessageId();

// Unique, monotonically increasing number of event for this conversation
getConversationEventId()

// Custom message metadata (sent when client sends a message)
getMetadata();

// Message sender
getFromWhom();

// Message sender defined internally on server (shouldn't be visible inside the app)
getSentBy();

// When the message was sent
getSentOn();

// Conversation unique identifier
getConversationId();

// Parts of the message with data, type, name and size 
getParts();

// Alert definitions with FCM and APNS push platforms
getAlert();
// Message unique identifier
getMessageId();

// Conversation unique identifier
getConversationId();

// Profile unique identifier
getProfileId();

// When the message was marked as delivered
getTimestamp();

// Unique, monotonically increasing number of event for this conversation
getConversationEventId();
// Same as MessageDeliveredEvent
// Conversation unique identifier
getConversationId();

// Profile unique identifier
getProfileId();

// Role definition for this participant in this conversation
getRole();
// Same as ParticipantAddedEvent
// Same as ParticipantAddedEvent
// Conversation unique identifier
getConversationId() 

// Conversation name
getConversationName();

// Conversation decription
getDescription();

// Role definitions for 'owner' and 'participant'
getRoles();

// Tag specifying server data version.
getETag();
// Conversation unique identifier
getConversationId();

// When the conversation was deleted
getDeletedOn();

// Tag specifying server data version.
getETag();
// Conversation unique identifier
getConversationId();

// Conversation details, same as ConversationUpdateEvent
getConversation();

// Tag specifying server data version.
getETag();
// Conversation unique identifier
getConversationId();

// Get profile id of an participant who started typing a new message
getProfileId();
// Conversation unique identifier
getConversationId();

// Get profile id of an participant who stopped typing a new message
getProfileId();