HyphenateChatSDK 4.2.3
Instance Methods | List of all members
<IEMChatManager> Protocol Reference

#import <IEMChatManager.h>

Inheritance diagram for <IEMChatManager>:

Instance Methods

(void) - addDelegate:delegateQueue:
 
(void) - removeDelegate:
 
(NSArray< EMConversation * > *_Nullable) - getAllConversations
 
(void) - getConversationsFromServerWithCursor:pageSize:completion:
 
(void) - getPinnedConversationsFromServerWithCursor:pageSize:completion:
 
(void) - pinConversation:isPinned:completionBlock:
 
(EMConversation *_Nullable) - getConversationWithConvId:
 
(EMConversation *_Nullable) - getConversation:type:createIfNotExist:
 
(void) - deleteConversation:isDeleteMessages:completion:
 
(void) - deleteServerConversation:conversationType:isDeleteServerMessages:completion:
 
(EMChatMessage *_Nullable) - getMessageWithMessageId:
 
(void) - sendMessageReadAck:toUser:completion:
 
(void) - ackConversationRead:completion:
 
(void) - recallMessageWithMessageId:completion:
 
(void) - sendMessage:progress:completion:
 
(void) - downloadMessageThumbnail:progress:completion:
 
(void) - downloadMessageAttachment:progress:completion:
 
(void) - removeMessagesFromServerWithConversation:timeStamp:completion:
 
(void) - fetchMessagesFromServerBy:conversationType:cursor:pageSize:option:completion:
 

Detailed Description

This protocol that defines the operations of chat.

Messages are loaded from the local database, not from the server.

Method Documentation

◆ ackConversationRead:completion:

- (void) ackConversationRead: (NSString *_Nonnull)  conversationId
completion: (void(^)(EMError *_Nullable aError))  aCompletionBlock 
required

Sends the conversation read receipt to the server.

This method applies to one-to-one chats only.

This method call notifies the server to set the number of unread messages of the specified conversation as 0, and triggers the onConversationRead callback on the recipient's client.

To reduce the number of method calls, we recommend that you call this method when the user enters a conversation with many unread messages, and call sendMessageReadAck during a conversation to send the message read receipts.

This is an asynchronous method.

Parameters
conversationIdThe conversation ID.
aCompletionBlockThe completion block, which contains the error message if the method fails.

◆ addDelegate:delegateQueue:

- (void) addDelegate: (id< EMChatManagerDelegate > _Nullable)  aDelegate
delegateQueue: (dispatch_queue_t _Nullable)  aQueue 
required

Adds a delegate.

Parameters
aDelegateThe object that implements the protocol.
aQueue(optional) The queue of calling delegate methods. If you want to run the app on the main thread, set this parameter as nil.

◆ deleteConversation:isDeleteMessages:completion:

- (void) deleteConversation: (NSString *_Nonnull)  aConversationId
isDeleteMessages: (BOOL)  aIsDeleteMessages
completion: (void(^)(NSString *_Nullable aConversationId, EMError *_Nullable aError))  aCompletionBlock 
required

Deletes a conversation from the local database.

Parameters
aConversationIdThe conversation ID.
aIsDeleteMessagesWhether to delete the messages in the conversation.
  • YES: Yes;
  • NO: No.
aCompletionBlockThe completion block, which contains the error message if the method call fails.

◆ deleteServerConversation:conversationType:isDeleteServerMessages:completion:

- (void) deleteServerConversation: (NSString *_Nonnull)  aConversationId
conversationType: (EMConversationType)  aConversationType
isDeleteServerMessages: (BOOL)  aIsDeleteServerMessages
completion: (void(^)(NSString *_Nullable aConversationId, EMError *_Nullable aError))  aCompletionBlock 
required

Deletes a conversation from the server.

Parameters
aConversationIdThe conversation ID.
aConversationTypeThe conversation type.
aIsDeleteMessagesWhether to delete the related messages with the conversation.
  • YES: Yes;
  • NO: No.
aCompletionBlockThe completion block, which contains the error message if the method call fails.

◆ downloadMessageAttachment:progress:completion:

- (void) downloadMessageAttachment: (EMChatMessage *_Nonnull)  aMessage
progress: (void(^)(int progress))  aProgressBlock
completion: (void(^)(EMChatMessage *_Nullable message, EMError *_Nullable error))  aCompletionBlock 
required

Downloads message attachment (voice, video, image or file).

The SDK automatically downloads voice messages. If the automatic download fails, you can call this method to download voice messages manually.

This is an asynchronous method.

Parameters
aMessageThe message object.
aProgressBlockThe callback block of attachment download progress. The progress value range is [0,100].
aCompletionBlockThe completion block, which contains the error message if the method fails.

◆ downloadMessageThumbnail:progress:completion:

- (void) downloadMessageThumbnail: (EMChatMessage *_Nonnull)  aMessage
progress: (void(^)(int progress))  aProgressBlock
completion: (void(^)(EMChatMessage *_Nullable message, EMError *_Nullable error))  aCompletionBlock 
required

Downloads the message thumbnail (the thumbnail of an image or the first frame of a video).

The SDK automatically downloads the thumbnail. If the auto-download fails, you can call this method to manually download the thumbnail.

Parameters
aMessageThe message object.
aProgressBlockThe callback block of attachment download progress. The progress value range is [0,100].
aCompletionBlockThe completion block, which contains the error message if the method fails.

◆ fetchMessagesFromServerBy:conversationType:cursor:pageSize:option:completion:

- (void) fetchMessagesFromServerBy: (NSString *)  conversationId
conversationType: (EMConversationType)  type
cursor: (NSString *_Nullable)  cursor
pageSize: (NSUInteger)  pageSize
option: (EMFetchServerMessagesOption *_Nullable)  option
completion: (void(^)(EMCursorResult< EMChatMessage * > *_Nullable result, EMError *_Nullable aError))  aCompletionBlock 
required
Parameters
conversationIdThe conversation ID, which is the user ID of the peer user for one-to-one chat, but the group ID for group chat.
typeThe conversation type. You can set this parameter only to EMConversationTypeChat (one-to-one chat) or EMConversationTypeGroupChat (group chat).
cursorThe cursor position from which to start querying data.
pageSizeThe number of messages that you expect to get on each page. The value range is [1,50].
optionThe parameter configuration class for pulling historical messages from the server. See EMFetchServerMessagesOption.
aCompletionBlockThe completion block, which contains the error message if the method fails.

◆ getAllConversations

- (NSArray< EMConversation * > *_Nullable) getAllConversations
required

Gets all local conversations.

The SDK loads the conversations from the memory first. If no conversation is found in the memory, the SDK loads from the local database.

Returns
The conversation list of the NSArray<EMConversation *> * type.

◆ getConversation:type:createIfNotExist:

- (EMConversation *_Nullable) getConversation: (NSString *_Nonnull)  aConversationId
type: (EMConversationType)  aType
createIfNotExist: (BOOL)  aIfCreate 
required

Gets a conversation from the local database.

Parameters
aConversationIdThe conversation ID.
aTypeThe conversation type.
aIfCreateWhether to create the conversation if it does not exist:
  • YES: Yes;
  • NO: No.
Returns
The conversation object.

◆ getConversationsFromServerWithCursor:pageSize:completion:

- (void) getConversationsFromServerWithCursor: (nullable NSString *)  cursor
pageSize: (UInt8)  pageSize
completion: (nonnull void(^)(EMCursorResult< EMConversation * > *_Nullable result, EMError *_Nullable error))  completionBlock 
required

Get the list of conversations from the server with pagination.

The SDK retrieves the list of conversations in the reverse chronological order of their active time (the timestamp of the last message).

If there is no message in the conversation, the SDK retrieves the list of conversations in the reverse chronological order of their creation time.

Parameters
cursorThe position from which to start getting data. If you pass in nil or @"", the SDK retrieves conversations from the latest active one.
pageSizeThe number of conversations that you expect to get on each page. The value range is [1,50].
aCompletionBlockThe completion block, which contains the error message if the method fails.

◆ getConversationWithConvId:

- (EMConversation *_Nullable) getConversationWithConvId: (NSString *_Nullable)  aConversationId
required

Gets a conversation from the local database.

Parameters
aConversationIdThe conversation ID.
Returns
The conversation object.

◆ getMessageWithMessageId:

- (EMChatMessage *_Nullable) getMessageWithMessageId: (NSString *_Nonnull)  aMessageId
required

Gets the specified message.

Parameters
aMessageIdThe message ID.
Returns
EMChatMessage The message content.

◆ getPinnedConversationsFromServerWithCursor:pageSize:completion:

- (void) getPinnedConversationsFromServerWithCursor: (nullable NSString *)  cursor
pageSize: (UInt8)  limit
completion: (nonnull void(^)(EMCursorResult< EMConversation * > *_Nullable result, EMError *_Nullable error))  completionBlock 
required

Gets the list of pinned conversations from the server with pagination.

The SDK returns the pinned conversations in the reverse chronological order of their pinning.

Parameters
cursorThe position from which to start getting data. If you pass in nil or @"", the SDK retrieves conversations from the latest pinned one.
pageSizeThe number of conversations that you expect to get on each page. The value range is [1,50].
completionBlockThe completion block, which contains the error message if the method fails.

◆ pinConversation:isPinned:completionBlock:

- (void) pinConversation: (nonnull NSString *)  conversationId
isPinned: (BOOL)  isPinned
completionBlock: (nullable void(^)(EMError *_Nullable error))  completionBlock 
required

Sets whether to pin a conversation.

Parameters
conversationIdThe conversation ID.
isPinnedWhether to pin a conversation:
  • true:Yes.
    • false: No. The conversation is unpinned.
completionBlockThe completion block, which contains the error message if the method fails.

◆ recallMessageWithMessageId:completion:

- (void) recallMessageWithMessageId: (NSString *_Nonnull)  aMessageId
completion: (void(^)(EMError *_Nullable aError))  aCompletionBlock 
required

Recalls a message.

This is an asynchronous method.

Parameters
aMessageIdThe message ID
aCompletionBlockThe completion block, which contains the error message if the method fails.

◆ removeDelegate:

- (void) removeDelegate: (id< EMChatManagerDelegate > _Nonnull)  aDelegate
required

Removes a delegate.

Parameters
aDelegateThe delegate to be removed.

◆ removeMessagesFromServerWithConversation:timeStamp:completion:

- (void) removeMessagesFromServerWithConversation: (EMConversation *_Nonnull)  conversation
timeStamp: (NSTimeInterval)  beforeTimeStamp
completion: (void(^)(EMError *_Nullable aError))  aCompletionBlock 
required

Removes messages in a conversation (from both local storage and the server).

Parameters
conversationThe EMConversation object.
messageIdsThe specified Unix timestamp in miliseconds. Messages with a timestamp before the specified one will be removed from the conversation.
completionThe completion block, which contains the error message if the method fails.

◆ sendMessage:progress:completion:

- (void) sendMessage: (EMChatMessage *_Nonnull)  aMessage
progress: (void(^)(int progress))  aProgressBlock
completion: (void(^)(EMChatMessage *_Nullable message, EMError *_Nullable error))  aCompletionBlock 
required

Sends a message.

This is an asynchronous method.

Parameters
aMessageThe message instance.
aProgressBlockThe callback block of attachment upload progress. The progress value range is [0,100].
aCompletionBlockThe completion block, which contains the error message if the method fails.

◆ sendMessageReadAck:toUser:completion:

- (void) sendMessageReadAck: (NSString *_Nonnull)  aMessageId
toUser: (NSString *_Nonnull)  aUsername
completion: (void(^)(EMError *_Nullable aError))  aCompletionBlock 
required

Sends the read receipt for a message.

This is an asynchronous method.

Parameters
aMessageIdThe message ID.
aUsernameThe user ID of the recipient of the read receipt.
aCompletionBlockThe completion block, which contains the error message if the method fails.

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