public final class

ChatService

extends RcsService
java.lang.Object
   ↳ com.gsma.services.rcs.RcsService
     ↳ com.gsma.services.rcs.chat.ChatService

Class Overview

Chat service offers the main entry point to initiate chat 1-1 and group conversations with contacts. Several applications may connect/disconnect to the API. The parameter contact in the API supports the following formats: MSISDN in national or international format, SIP address, SIP-URI or Tel-URI.

Summary

[Expand]
Inherited Constants
From class com.gsma.services.rcs.RcsService
Public Constructors
ChatService(Context ctx, RcsServiceListener listener)
Constructor
Public Methods
void addEventListener(GroupChatListener listener)
Adds a listener on group chat events
void addEventListener(OneToOneChatListener listener)
Adds a listener for one-to-one chat events
void clearMessageDeliveryExpiration(Set<String> msgIds)
Disables and clears any delivery expiration for a set of chat messages regardless if the delivery of them has expired already or not.
final void connect()
Connects to the API
void deleteGroupChat(String chatId)
Delete a group chat by its chat id from history and abort/reject any associated ongoing session if such exists.
void deleteGroupChats()
Deletes all group chat from history and abort/reject any associated ongoing session if such exists.
void deleteMessage(String msgId)
Delete a message from its message id from history.
void deleteOneToOneChat(ContactId contact)
Deletes a one to one chat with a given contact from history and abort/reject any associated ongoing session if such exists.
void deleteOneToOneChats()
Deletes all one to one chat from history and abort/reject any associated ongoing session if such exists.
void disconnect()
Disconnects from the API
ChatMessage getChatMessage(String msgId)
Returns a chat message from its unique ID
ChatServiceConfiguration getConfiguration()
Returns the configuration of the chat service
GroupChat getGroupChat(String chatId)
Returns a group chat from its unique ID.
OneToOneChat getOneToOneChat(ContactId contact)
Returns a chat with a given contact
GroupChat initiateGroupChat(Set<ContactId> contacts, String subject)
Initiates a group chat with a group of contact and returns a GroupChat instance.
boolean isAllowedToInitiateGroupChat()
Returns true if it is possible to initiate a new group chat now else returns false.
boolean isAllowedToInitiateGroupChat(ContactId contact)
Returns true if it's possible to initiate a new group chat with the specified contactId right now, else returns false.
void markMessageAsRead(String msgId)
Mark a received message as read (ie.
void removeEventListener(OneToOneChatListener listener)
Removes a listener for one-to-one chat events
void removeEventListener(GroupChatListener listener)
Removes a listener on group chat events
[Expand]
Inherited Methods
From class com.gsma.services.rcs.RcsService
From class java.lang.Object

Public Constructors

public ChatService (Context ctx, RcsServiceListener listener)

Since: API Level 1.5

Constructor

Parameters
ctx Application context
listener Service listener

Public Methods

public void addEventListener (GroupChatListener listener)

Since: API Level 1.5

Adds a listener on group chat events

Parameters
listener Group chat listener
Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public void addEventListener (OneToOneChatListener listener)

Since: API Level 1.5

Adds a listener for one-to-one chat events

Parameters
listener One-to-one chat listener
Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public void clearMessageDeliveryExpiration (Set<String> msgIds)

Since: API Level 1.5

Disables and clears any delivery expiration for a set of chat messages regardless if the delivery of them has expired already or not.

Parameters
msgIds the message IDs
Throws
RcsServiceNotAvailableException
RcsPersistentStorageException
RcsGenericException
RcsPersistentStorageException
RcsServiceNotAvailableException

public final void connect ()

Since: API Level 1.5

Connects to the API

public void deleteGroupChat (String chatId)

Since: API Level 1.5

Delete a group chat by its chat id from history and abort/reject any associated ongoing session if such exists.

Parameters
chatId the chat ID
Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public void deleteGroupChats ()

Since: API Level 1.5

Deletes all group chat from history and abort/reject any associated ongoing session if such exists.

Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public void deleteMessage (String msgId)

Since: API Level 1.5

Delete a message from its message id from history.

Parameters
msgId the message ID
Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public void deleteOneToOneChat (ContactId contact)

Since: API Level 1.5

Deletes a one to one chat with a given contact from history and abort/reject any associated ongoing session if such exists.

Parameters
contact the remote contact
Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public void deleteOneToOneChats ()

Since: API Level 1.5

Deletes all one to one chat from history and abort/reject any associated ongoing session if such exists.

Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public void disconnect ()

Since: API Level 1.5

Disconnects from the API

public ChatMessage getChatMessage (String msgId)

Since: API Level 1.5

Returns a chat message from its unique ID

Parameters
msgId Message id
Returns
  • ChatMessage
Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public ChatServiceConfiguration getConfiguration ()

Since: API Level 1.5

Returns the configuration of the chat service

Returns
  • ChatServiceConfiguration
Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public GroupChat getGroupChat (String chatId)

Since: API Level 1.5

Returns a group chat from its unique ID. An exception is thrown if the chat ID does not exist

Parameters
chatId Chat ID
Returns
  • GroupChat
Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public OneToOneChat getOneToOneChat (ContactId contact)

Since: API Level 1.5

Returns a chat with a given contact

Parameters
contact ContactId
Returns
  • OneToOneChat
Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public GroupChat initiateGroupChat (Set<ContactId> contacts, String subject)

Since: API Level 1.5

Initiates a group chat with a group of contact and returns a GroupChat instance. The subject is optional and may be null.

Parameters
contacts Set of contact identifiers
subject The subject is optional and may be null
Returns
  • GroupChat instance
Throws
RcsPermissionDeniedException
RcsServiceNotRegisteredException
RcsMaxAllowedSessionLimitReachedException
RcsPersistentStorageException
RcsServiceNotAvailableException
RcsGenericException
RcsMaxAllowedSessionLimitReachedException
RcsPermissionDeniedException
RcsPersistentStorageException
RcsServiceNotAvailableException
RcsServiceNotRegisteredException

public boolean isAllowedToInitiateGroupChat ()

Since: API Level 1.5

Returns true if it is possible to initiate a new group chat now else returns false.

Returns
  • boolean
Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public boolean isAllowedToInitiateGroupChat (ContactId contact)

Since: API Level 1.5

Returns true if it's possible to initiate a new group chat with the specified contactId right now, else returns false.

Parameters
contact the remote contact
Returns
  • boolean
Throws
RcsPersistentStorageException
RcsServiceNotAvailableException
RcsGenericException
RcsPersistentStorageException
RcsServiceNotAvailableException

public void markMessageAsRead (String msgId)

Since: API Level 1.5

Mark a received message as read (ie. displayed in the UI)

Parameters
msgId Message id
Throws
RcsServiceNotAvailableException
RcsPersistentStorageException
RcsGenericException
RcsPersistentStorageException
RcsServiceNotAvailableException

public void removeEventListener (OneToOneChatListener listener)

Since: API Level 1.5

Removes a listener for one-to-one chat events

Parameters
listener One-to-one chat listener
Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException

public void removeEventListener (GroupChatListener listener)

Since: API Level 1.5

Removes a listener on group chat events

Parameters
listener Group chat event listener
Throws
RcsServiceNotAvailableException
RcsGenericException
RcsServiceNotAvailableException