HyphenateChatSDK 4.2.3
Instance Methods | Properties | List of all members
EMConversation Class Reference

#import <EMConversation.h>

Inheritance diagram for EMConversation:

Instance Methods

(EMChatMessage *_Nullable) - lastReceivedMessage
 
(void) - insertMessage:error:
 
(void) - appendMessage:error:
 
(void) - deleteMessageWithId:error:
 
(void) - deleteAllMessages:
 
(void) - removeMessagesFromServerWithTimeStamp:completion:
 
(void) - updateMessageChange:error:
 
(EMError *_Nullable) - removeMessagesStart:to:
 

Properties

NSString * conversationId
 
EMConversationType type
 
int unreadMessagesCount
 
int messagesCount
 
NSDictionary * ext
 
BOOL isChatThread
 
BOOL isPinned
 
int64_t pinnedTime
 
EMChatMessagelatestMessage
 

Detailed Description

The chat conversation class.

Method Documentation

◆ appendMessage:error:

- (void) appendMessage: (EMChatMessage *_Nonnull)  aMessage
error: (EMError **_Nullable)  pError 

Inserts a message to the end of a conversation in local database.

To insert the message correctly, ensure that the conversation ID of the message is the same as that of the conversation.

After a message is inserted, the SDK will automatically update attributes of the conversation, including latestMessage.

Parameters
aMessageThe message instance.
pErrorThe error information if the method fails: Error.

◆ deleteAllMessages:

- (void) deleteAllMessages: (EMError **_Nullable)  pError

Deletes all the messages in the conversation from the memory and local database.

Parameters
pErrorThe error information if the method fails: Error.

◆ deleteMessageWithId:error:

- (void) deleteMessageWithId: (NSString *_Nonnull)  aMessageId
error: (EMError **_Nullable)  pError 

Deletes a message from the local database.

Parameters
aMessageIdThe ID of the message to be deleted.
pErrorThe error information if the method fails: Error.

◆ insertMessage:error:

- (void) insertMessage: (EMChatMessage *_Nonnull)  aMessage
error: (EMError **_Nullable)  pError 

Inserts a message to a conversation in the local database.

To insert the message correctly, ensure that the conversation ID of the message is the same as that of the conversation.

The message is inserted based on timestamp and the SDK will automatically update attributes of the conversation, including latestMessage.

Parameters
aMessageThe message instance.
pErrorThe error information if the method fails: Error.

◆ lastReceivedMessage

- (EMChatMessage *_Nullable) lastReceivedMessage

Gets the last received message.

Returns
The message instance.

◆ removeMessagesFromServerWithTimeStamp:completion:

- (void) removeMessagesFromServerWithTimeStamp: (NSTimeInterval)  beforeTimeStamp
completion: (void(^)(EMError *_Nullable aError))  aCompletionBlock 

Removes messages from the conversation by message ID.

This method deletes messages from both local storage and server.

Parameters
messageIdsThe message timestamp in millisecond. Messages with the timestamp smaller than the specified one will be removed from the current conversation.
completionThe completion block, which contains the error message if the method fails.

◆ removeMessagesStart:to:

- (EMError *_Nullable) removeMessagesStart: (NSInteger)  aStartTimestamp
to: (NSInteger)  aEndTimestamp 

Deletes messages sent or received in a certain period from the local database.

Parameters
aStartTimestampThe starting UNIX timestamp for message deletion. The unit is millisecond.
aEndTimestampThe end UNIX timestamp for message deletion. The unit is millisecond.
Returns
EMError Whether the message deletion succeeds:
  • If the operation succeeds, the SDK returns nil.
  • If the operation fails, the SDK returns the failure reason such as the parameter error or database operation failure.

◆ updateMessageChange:error:

- (void) updateMessageChange: (EMChatMessage *_Nonnull)  aMessage
error: (EMError **_Nullable)  pError 

Updates a message in the local database.

After you update a message, the message ID remains unchanged and the SDK automatically updates attributes of the conversation, like latestMessage.

Parameters
aMessageThe message to be updated.
pErrorThe error information if the method fails: Error.

Property Documentation

◆ conversationId

- (NSString*) conversationId
readnonatomiccopy

The conversation ID.

  • One-to-one chat: The conversation ID is the user ID of the peer user.
  • Group chat: The conversation ID is the group ID.
  • Chat room: The conversation ID is the chat room ID.

◆ ext

- (NSDictionary*) ext
readwritenonatomiccopy

The conversation extension attribute.

This attribute is not available for thread conversations.

◆ isChatThread

- (BOOL) isChatThread
readwritenonatomicassign

Whether the conversation is a thread conversation:

  • YES:Yes
  • NO:No

◆ isPinned

- (BOOL) isPinned
readatomicassign

Whether the conversation is pinned:

  • YES:Yes
  • NO:No

◆ latestMessage

- (EMChatMessage*) latestMessage
readnonatomicstrong

The latest message in the conversation.

◆ messagesCount

- (int) messagesCount
readnonatomicassign

The message count in the conversation.

◆ pinnedTime

- (int64_t) pinnedTime
readatomicassign

The UNIX timestamp when the conversation is pinned. The unit is millisecond. This value is 0 when the conversation is not pinned.

◆ type

- (EMConversationType) type
readnonatomicassign

The conversation type.

◆ unreadMessagesCount

- (int) unreadMessagesCount
readnonatomicassign

The number of unread messages in the conversation.


The documentation for this class was generated from the following file: