NIMChatManager Protocol Reference

Conforms to NSObject
Declared in NIMChatManagerProtocol.h

Overview

Chat protocol

– sendMessage:toSession:error: required method

Send a message

- (BOOL)sendMessage:(NIMMessage *)message toSession:(NIMSession *)session error:(NSError *__nullable *)error

Parameters

message

message

session

recipient

error

error. If an error occurs in preparing to send the message, this error will be specified with corresponding information

Return Value

result The result returned indicates whether the current function call is successful, and subsequent callbacks are required to determine whether the message has been sent to the server.

Discussion

Send a message

Declared In

NIMChatManagerProtocol.h

– sendMessage:toSession:completion: required method

Send a message in async call

- (void)sendMessage:(NIMMessage *)message toSession:(NIMSession *)session completion:(__nullable NIMChatManagerBlock)completion

Parameters

message

message

session

receipient

Return Value

completion. completion callback. The callback indicates whether the current function call is successful, and subsequent callbacks are required to determine whether the message has been sent to the server.

Discussion

Send a message in async call

Declared In

NIMChatManagerProtocol.h

– cancelSendingMessage: required method

Cancel sending a message

- (BOOL)cancelSendingMessage:(NIMMessage *)message

Parameters

message

target message

Return Value

the result

Discussion

Cancel sending a message

Declared In

NIMChatManagerProtocol.h

– resendMessage:error: required method

resend a message

- (BOOL)resendMessage:(NIMMessage *)message error:(NSError *__nullable *)error

Parameters

message

message to be resent

error

error. If an error occurs in preparing to send the message, this error will be specified with corresponding information

Return Value

result The result returned indicates whether the current function call is successful, and subsequent callbacks are required to determine whether the message has been sent to the server.

Discussion

resend a message

Declared In

NIMChatManagerProtocol.h

– makeForwardMessageFromMessage:error: required method

Generate forwarding messages After getting the forwarded message, the user calls sendMessage:toSession:error: or sendMessage:toSession:completion: to send the forwarded message. Calling forwardMessage:toSession:error: directly will get the same result, but in this way, the progress callback of the forwarded message and the callback of whether the forwarding is successful can be obtained.

- (NIMMessage *)makeForwardMessageFromMessage:(NIMMessage *)message error:(NSError *__autoreleasing _Nullable *_Nullable)error

Parameters

message

The message to be forwarded

error

error. If an error occurs in preparing to send the message, this error will be specified with corresponding information

Return Value

message generated for forwarding

Discussion

Generate forwarding messages After getting the forwarded message, the user calls sendMessage:toSession:error: or sendMessage:toSession:completion: to send the forwarded message. Calling forwardMessage:toSession:error: directly will get the same result, but in this way, the progress callback of the forwarded message and the callback of whether the forwarding is successful can be obtained.

Declared In

NIMChatManagerProtocol.h

– forwardMessage:toSession:error: required method

Forward a message

- (BOOL)forwardMessage:(NIMMessage *)message toSession:(NIMSession *)session error:(NSError *__nullable *)error

Parameters

message

message

session

receipient

error

error. If an error occurs in preparing to send the message, this error will be specified with corresponding information

Return Value

result The result returned indicates whether the current function call is successful, and subsequent callbacks are required to determine whether the message has been sent to the server.

Discussion

Forward a message

Declared In

NIMChatManagerProtocol.h

– sendMessageReceipt:completion: required method

Send read receipts for P2P messages

- (void)sendMessageReceipt:(NIMMessageReceipt *)receipt completion:(nullable NIMSendMessageReceiptBlock)completion

Parameters

completion

Completion callback

detail

read receipt

Discussion

Send read receipts for P2P messages

This interface is only applicable to P2P messages. The read receipts of group messages use sendTeamMessageReceipts:completion. If there is already a read receipt with a greater timestamp than the current read receipt, the interface returns success.

Declared In

NIMChatManagerProtocol.h

– sendTeamMessageReceipts:completion: required method

Send read receipts for multiple group messages

- (void)sendTeamMessageReceipts:(NSArray<NIMMessageReceipt*> *)receipts completion:(nullable NIMSendTeamMessageReceiptsBlock)completion

Parameters

completion

Completion callback

detail

read receipt

Discussion

Send read receipts for multiple group messages

This interface only applies to group messages.

Declared In

NIMChatManagerProtocol.h

– refreshTeamMessageReceipts: required method

Update the read and unread count of group messages

- (void)refreshTeamMessageReceipts:(NSArray<NIMMessage*> *)messages

Parameters

messages

The messages to be queried

Discussion

Update the read and unread count of group messages

After the message is read, the state will be returned to the upper layer by calling onRecvMessageReceipts: of NIMChatManager The refreshed message must be a group message

Declared In

NIMChatManagerProtocol.h

– queryMessageReceiptDetail:completion: required method

Query group message receipt details

- (void)queryMessageReceiptDetail:(NIMMessage *)message completion:(NIMQueryReceiptDetailBlock)completion

Parameters

completion

Completion callback

messages

The messages to be queried

Discussion

Query group message receipt details

details include a list of IDs of read counts and a list of IDs of unread counts. The query details will not change with the number of receipts. If you want to get the latest details, you must call this interface again

Declared In

NIMChatManagerProtocol.h

– queryMessageReceiptDetail:accountSet:completion: required method

Query group message receipt details of a specified user

- (void)queryMessageReceiptDetail:(NIMMessage *)message accountSet:(NSSet *)accountSet completion:(NIMQueryReceiptDetailBlock)completion

Parameters

message

message to be queried

accountSet

that contains specified accounts

Return Value

list of accounts that have read or unread a message

Discussion

Query group message receipt details of a specified user

Declared In

NIMChatManagerProtocol.h

– localMessageReceiptDetail: required method

Get the accounts that have read or unread a group message from the local database Note: The obtained data is earlier than the data before logging off.

- (nullable NIMTeamMessageReceiptDetail *)localMessageReceiptDetail:(NIMMessage *)message

Parameters

message

message to be queried

Return Value

list of accounts that have read or unread a message

Discussion

Get the accounts that have read or unread a group message from the local database Note: The obtained data is earlier than the data before logging off.

Declared In

NIMChatManagerProtocol.h

– localMessageReceiptDetail:accountSet: required method

Get the accounts that have read or unread a group message from the local database (sync) Note: The obtained data is earlier than the data before logging off.

- (nullable NIMTeamMessageReceiptDetail *)localMessageReceiptDetail:(NIMMessage *)message accountSet:(NSSet *)accountSet

Parameters

message

message to be queried

accountSet

that contains specified accounts

Return Value

list of accounts that have read or unread a message

Discussion

Get the accounts that have read or unread a group message from the local database (sync) Note: The obtained data is earlier than the data before logging off.

Declared In

NIMChatManagerProtocol.h

– revokeMessage:completion: required method

Recall a message, not a push notification

- (void)revokeMessage:(NIMMessage *)message completion:(nullable NIMRevokeMessageBlock)completion

Parameters

message

The message to be recalled.

completion

Completion callback

Discussion

Recall a message, not a push notification

Recalled messages counted as unread

Declared In

NIMChatManagerProtocol.h

– revokeMessage:apnsContent:apnsPayload:shouldBeCounted:completion: required method

Recall a message

- (void)revokeMessage:(NIMMessage *)message apnsContent:(nullable NSString *)apnsContent apnsPayload:(nullable NSDictionary *)apnsPayload shouldBeCounted:(BOOL)should completion:(nullable NIMRevokeMessageBlock)completion

Parameters

message

The message to be recalled.

apnsContent

Content of a push notification that allows up to 500 characters

apnsPayload

Payload of a push notification. A maximum of 2K characters are allowed.

should

specify whether the message is counted as unread

completion

completion callback

Discussion

Recall a message

Declared In

NIMChatManagerProtocol.h

– revokeMessage:option:completion: required method

Recall a message

- (void)revokeMessage:(NIMMessage *)message option:(NIMRevokeMessageOption *)option completion:(nullable NIMRevokeMessageBlock)completion

Parameters

message

The message to be recalled.

option

Revocation options

completion

Completion callback

Discussion

Recall a message

Recalled messages counted as unread

Declared In

NIMChatManagerProtocol.h

– fetchMessageAttachment:error: required method

Get a message attachment

- (BOOL)fetchMessageAttachment:(NIMMessage *)message error:(NSError *__nullable *)error

Parameters

message

message with an attachment

error

error message

Return Value

the result

Discussion

Get a message attachment

attachments include thumbnails for image messages, video thumbnails for video messages, audio files for audio messages, files for file messages, and custom files in custom messages. The SDK will automatically call this interface when receiving P2P or group messages, and automatically download all attachments except files of file messages

Declared In

NIMChatManagerProtocol.h

– cancelFetchingMessageAttachment: required method

Cancel downloading the message attachment

- (void)cancelFetchingMessageAttachment:(NIMMessage *)message

Parameters

message

message with an attachment

Discussion

Cancel downloading the message attachment

attachments include thumbnails for image messages, video thumbnails for video messages, audio files for audio messages, files for file messages, and custom files in custom messages. P2P and group messages SDK does not trigger any download callbacks

Declared In

NIMChatManagerProtocol.h

– messageInTransport: required method

Specify whether the message is in transmission (sending / accepted attachment)

- (BOOL)messageInTransport:(NIMMessage *)message

Parameters

message

message

Return Value

result

Discussion

Specify whether the message is in transmission (sending / accepted attachment)

Declared In

NIMChatManagerProtocol.h

– messageTransportProgress: required method

Progress of transferring messages (sending or accepted attachments)

- (float)messageTransportProgress:(NIMMessage *)message

Parameters

message

message

Return Value

progress. If the message is not being transmitted, 0 is returned.

Discussion

Progress of transferring messages (sending or accepted attachments)

Declared In

NIMChatManagerProtocol.h

– addDelegate: required method

Add a chat delegate

- (void)addDelegate:(id<NIMChatManagerDelegate>)delegate

Parameters

delegate

thread message delegate

Discussion

Add a chat delegate

Declared In

NIMChatManagerProtocol.h

– removeDelegate: required method

Remove a chat delegate

- (void)removeDelegate:(id<NIMChatManagerDelegate>)delegate

Parameters

delegate

thread message delegate

Discussion

Remove a chat delegate

Declared In

NIMChatManagerProtocol.h