#import <AgoraChatConversation.h>
The chat conversation class.
◆ appendMessage:error:
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
-
aMessage | The message instance. |
pError | The error information if the method fails: Error. |
◆ deleteAllMessages:
Deletes all the messages in the conversation from the memory and local database.
- Parameters
-
pError | The error information if the method fails: Error. |
◆ deleteMessageWithId:error:
- (void) deleteMessageWithId: |
|
(NSString *_Nonnull) |
aMessageId |
error: |
|
(AgoraChatError **_Nullable) |
pError |
|
|
| |
Deletes a message from the local database.
- Parameters
-
aMessageId | The ID of the message to be deleted. |
pError | The error information if the method fails: Error. |
◆ getMessageCountStart:to:
- (NSInteger) getMessageCountStart: |
|
(NSInteger) |
aStartTimestamp |
to: |
|
(NSInteger) |
aEndTimestamp |
|
|
| |
Gets the number of messages in a conversation within a certain period of time.
- Parameters
-
aStartTimestamp | The starting timestamp for query. The unit is millisecond. |
aEndTimestamp | The ending timestamp for query. The unit is millisecond. |
- Returns
- The number of messages in a conversation within a certain period of time.
◆ insertMessage:error:
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
-
aMessage | The message instance. |
pError | The error information if the method fails: Error. |
◆ lastReceivedMessage
Gets the last received message.
- Returns
- The message instance.
◆ loadCustomMsgWithKeyword:timestamp:count:fromUser:searchDirection:
- (NSArray< AgoraChatMessage * > *_Nullable) loadCustomMsgWithKeyword: |
|
(NSString *) |
aKeyword |
timestamp: |
|
(long long) |
aTimestamp |
count: |
|
(int) |
aCount |
fromUser: |
|
(NSString *_Nullable) |
aSender |
searchDirection: |
|
(AgoraChatMessageSearchDirection) |
aDirection |
|
|
| |
Loads custom messages with keywords that the specified user sends in the conversation.
This is a synchronous method and blocks the current thread.
- Parameters
-
aKeyword | The keywords for query. Setting it as NIL means that the SDK ignores this parameter. |
aTimestamp | The starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If this parameter is set as a negative value, the SDK retrieves from the current time. |
aCount | The number of messages to load each time. If you set this parameter to a value less than 1, the SDK retrieves one message. |
aSender | The message sender. Setting it as NIL means that the SDK ignores this parameter. |
aDirection | The message search direction. See AgoraChatMessageSearchDirection . |
- Returns
- AgoraChatMessage The message list.
◆ loadCustomMsgWithKeyword:timestamp:count:fromUser:searchDirection:completion:
- (void) loadCustomMsgWithKeyword: |
|
(NSString *_Nullable) |
aKeyword |
timestamp: |
|
(long long) |
aTimestamp |
count: |
|
(int) |
aCount |
fromUser: |
|
(NSString *_Nullable) |
aSender |
searchDirection: |
|
(AgoraChatMessageSearchDirection) |
aDirection |
completion: |
|
(void(^)(NSArray< AgoraChatMessage * > *_Nullable aMessages, AgoraChatError *_Nullable aError)) |
aCompletionBlock |
|
|
| |
Loads custom messages with keywords that the specified user sends in the conversation.
- Parameters
-
aKeyword | The keyword for searching the messages. Setting it as NIL means that the SDK ignores this parameter. |
aTimestamp | The starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. If this parameter is set as a negative value, the SDK retrieves from the current time. |
aCount | The number of messages to load each time. If you set this parameter to a value less than 1, the SDK retrieves one message. |
aSender | The message sender. Setting it as NIL means that the SDK ignores this parameter. |
aDirection | The message search direction. See AgoraChatMessageSearchDirection . |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
◆ loadMessagesFrom:to:count:
- (NSArray< AgoraChatMessage * > *_Nullable) loadMessagesFrom: |
|
(long long) |
aStartTimestamp |
to: |
|
(long long) |
aEndTimestamp |
count: |
|
(int) |
aCount |
|
|
| |
Loads a certain quantity of messages sent or received in a certain period from the local database.
Messages are retrieved in the ascending order of the timestamp included in them.
This is a synchronous method and blocks the current thread.
- Parameters
-
aStartTimestamp | The starting Unix timestamp in the message for query. The unit is millisecond. |
aEndTimestamp | The ending Unix timestamp in the message for query. The unit is millisecond. |
aCount | The number of messages to load each time. If you set this parameter to a value less than 1, the SDK retrieves one message. |
- Returns
- AgoraChatMessage The message list.
◆ loadMessagesFrom:to:count:completion:
- (void) loadMessagesFrom: |
|
(long long) |
aStartTimestamp |
to: |
|
(long long) |
aEndTimestamp |
count: |
|
(int) |
aCount |
completion: |
|
(void(^)(NSArray< AgoraChatMessage * > *_Nullable aMessages, AgoraChatError *_Nullable aError)) |
aCompletionBlock |
|
|
| |
Loads a certain quantity of messages sent or received in a certain period from the local database.
- Parameters
-
aStartTimestamp | The starting Unix timestamp in the message for query. The unit is millisecond. |
aEndTimestamp | The ending Unix timestamp in the message for query. The unit is millisecond. |
aCount | The number of messages to load each time. If you set this parameter to a value less than 1, the SDK retrieves one message. |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
◆ loadMessagesStartFromId:count:searchDirection:
- (NSArray< AgoraChatMessage * > *_Nullable) loadMessagesStartFromId: |
|
(NSString *_Nullable) |
aMessageId |
count: |
|
(int) |
aCount |
searchDirection: |
|
(AgoraChatMessageSearchDirection) |
aDirection |
|
|
| |
Loads the messages from the local database, starting from a specific message ID.
This is a synchronous method and blocks the current thread.
- Parameters
-
aMessageId | The starting message ID for query. After this parameter is set, the SDK retrieves messages, from the specified one, according to the message search direction. If this parameter is set as nil , the SDK retrieves messages according to the search direction while ignoring this parameter.
- If
aDirection is set as UP , the SDK retrieves messages, starting from the latest one, in the descending order of the timestamp included in them.
- If
aDirection is set as DOWN , the SDK retrieves messages, starting from the oldest one, in the ascending order of the timestamp included in them.
|
aCount | The number of messages to load each time. If you set this parameter to a value less than 1, the SDK retrieves one message. |
aDirection | The message search direction. See AgoraChatMessageSearchDirection . |
- Returns
- AgoraChatMessage The message instance.
◆ loadMessagesStartFromId:count:searchDirection:completion:
- (void) loadMessagesStartFromId: |
|
(NSString *_Nullable) |
aMessageId |
count: |
|
(int) |
aCount |
searchDirection: |
|
(AgoraChatMessageSearchDirection) |
aDirection |
completion: |
|
(void(^)(NSArray< AgoraChatMessage * > *_Nullable aMessages, AgoraChatError *_Nullable aError)) |
aCompletionBlock |
|
|
| |
Loads messages starting from the specified message ID from local database.
Returning messages are sorted by receiving timestamp based on AgoraChatMessageSearchDirection. If the aMessageId is nil, will return starting from the latest message.
- Parameters
-
aMessageId | The starting message ID for query. After this parameter is set, the SDK retrieves messages, from the specified one, according to the message search direction. If this parameter is set as nil , the SDK retrieves messages according to the search direction while ignoring this parameter.
- If
aDirection is set as UP , the SDK retrieves messages, starting from the latest one, in the descending order of the timestamp included in them.
- If
aDirection is set as DOWN , the SDK retrieves messages, starting from the oldest one, in the ascending order of the timestamp included in them.
|
aCount | The number of messages to load each time. If you set this parameter to a value less than 1, the SDK retrieves one message. |
aDirection | The message search direction. See AgoraChatMessageSearchDirection . |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
◆ loadMessagesWithKeyword:timestamp:count:fromUser:searchDirection:
- (NSArray< AgoraChatMessage * > *_Nullable) loadMessagesWithKeyword: |
|
(NSString *_Nullable) |
aKeyword |
timestamp: |
|
(long long) |
aTimestamp |
count: |
|
(int) |
aCount |
fromUser: |
|
(NSString *_Nullable) |
aSender |
searchDirection: |
|
(AgoraChatMessageSearchDirection) |
aDirection |
|
|
| |
Loads messages with keywords that the specified user sends in the conversation.
This is a synchronous method and blocks the current thread.
- Parameters
-
aKeyword | The keywords for query. Setting it as NIL means that the SDK ignores this parameter. |
aTimestamp | The starting Unix timestamp for search. The unit is millisecond. If this parameter is set as a negative value, the SDK retrieves from the current time. |
aCount | The number of messages to load each time. If you set this parameter to a value less than 1, the SDK retrieves one message. |
aSender | The message sender. Setting it as nil means that the SDK ignores this parameter. |
aDirection | The message search direction. See AgoraChatMessageSearchDirection . |
- Returns
- AgoraChatMessage The message list.
◆ loadMessagesWithKeyword:timestamp:count:fromUser:searchDirection:completion:
- (void) loadMessagesWithKeyword: |
|
(NSString *_Nullable) |
aKeyword |
timestamp: |
|
(long long) |
aTimestamp |
count: |
|
(int) |
aCount |
fromUser: |
|
(NSString *_Nullable) |
aSender |
searchDirection: |
|
(AgoraChatMessageSearchDirection) |
aDirection |
completion: |
|
(void(^)(NSArray< AgoraChatMessage * > *_Nullable aMessages, AgoraChatError *_Nullable aError)) |
aCompletionBlock |
|
|
| |
Loads messages with specified keyword from local database. Returning messages are sorted by receiving timestamp based on AgoraChatMessageSearchDirection. If reference timestamp is negative, load from the latest messages; if message count is negative, will be handled as count=1
- Parameters
-
aKeyword | The keywords for query. Setting it as NIL means that the SDK ignores this parameter. |
aTimestamp | The starting Unix timestamp for search. The unit is millisecond. If this parameter is set as a negative value, the SDK retrieves from the current time. |
aCount | The number of messages to load each time. If you set this parameter to a value less than 1, the SDK retrieves one message. |
aSender | The message sender. Setting it as nil means that the SDK ignores this parameter. |
aDirection | The message search direction. See AgoraChatMessageSearchDirection . |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
◆ loadMessagesWithKeyword:timestamp:count:fromUser:searchDirection:scope:completion:
- (void) loadMessagesWithKeyword: |
|
(NSString *_Nullable) |
aKeyword |
timestamp: |
|
(long long) |
aTimestamp |
count: |
|
(int) |
aCount |
fromUser: |
|
(NSString *_Nullable) |
aSender |
searchDirection: |
|
(AgoraChatMessageSearchDirection) |
aDirection |
scope: |
|
(AgoraChatMessageSearchScope) |
aScope |
completion: |
|
(void(^)(NSArray< AgoraChatMessage * > *_Nullable aMessages, AgoraChatError *_Nullable aError)) |
aCompletionBlock |
|
|
| |
Loads messages with the specified keyword from a user in the local database.
The SDK returns messages in the chronological order.
- Parameters
-
aKeyword | The keyword for message search. If you set this parameter as nil , the SDK ignores this parameter when retrieving messages. |
aTimestamp | The Unix timestamp threshold for message search. The unit is millisecond. If you set this parameter as a negative value, the SDK loads messages from the latest one. If this parameter is set as a negative value, the SDK retrieves from the current time. |
aCount | The number of messages to load. If you set this parameter to 0 or less, the SDK gets one message from the local database. |
aSender | The sender of the message. If you set this parameter as nil , the SDK ignores this parameter when retrieving messages. |
aDirection | The message search direction. See AgoraChatMessageSearchDirection .
UP : The SDK retrieves messages in the descending order of the timestamp included in them.
DOWN :The SDK retrieves messages in the ascending order of the timestamp included in them.
|
aScope | The message search scope. See AgoraChatMessageSearchScope . |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
◆ loadMessagesWithType:timestamp:count:fromUser:searchDirection:
- (NSArray< AgoraChatMessage * > *_Nullable) loadMessagesWithType: |
|
(AgoraChatMessageBodyType) |
aType |
timestamp: |
|
(long long) |
aTimestamp |
count: |
|
(int) |
aCount |
fromUser: |
|
(NSString *_Nullable) |
aUsername |
searchDirection: |
|
(AgoraChatMessageSearchDirection) |
aDirection |
|
|
| |
Gets messages of certain types that a specified user sends in the conversation.
This is a synchronous method and blocks the current thread.
- Parameters
-
aType | The message type to load. Types include txt (text message), img (image message), loc (location message), audio (audio message), video (video message), file (file message), and cmd (command message). |
aTimestamp | The starting Unix timestamp in the message for query. The unit is millisecond. If you set this parameter as a negative value, the SDK loads messages from the latest one. |
aCount | The number of messages to load each time. If you set this parameter to a value less than 1, the SDK retrieves one message. |
aUsername | The message sender. Setting it as NIL means that the SDK ignores this parameter. |
aDirection | The message search direction. See AgoraChatMessageSearchDirection . |
- Returns
- AgoraChatMessage The message instance.
◆ loadMessagesWithType:timestamp:count:fromUser:searchDirection:completion:
- (void) loadMessagesWithType: |
|
(AgoraChatMessageBodyType) |
aType |
timestamp: |
|
(long long) |
aTimestamp |
count: |
|
(int) |
aCount |
fromUser: |
|
(NSString *_Nullable) |
aUsername |
searchDirection: |
|
(AgoraChatMessageSearchDirection) |
aDirection |
completion: |
|
(void(^)(NSArray< AgoraChatMessage * > *_Nullable aMessages, AgoraChatError *_Nullable aError)) |
aCompletionBlock |
|
|
| |
Gets messages of certain types that a specified user sends in the conversation.
- Parameters
-
aType | The message type to load. Types include txt (text message), img (image message), loc (location message), audio (audio message), video (video message), file (file message), and cmd (command message). |
aTimestamp | The starting Unix timestamp in the message for query. The unit is millisecond. If you set this parameter as a negative value, the SDK loads messages from the latest one. |
aCount | The number of messages to load each time. If you set this parameter to a value less than 1, the SDK retrieves one message. |
aUsername | The message sender. Setting it as nil means that the SDK ignores this parameter. |
aDirection | The message search direction. See AgoraChatMessageSearchDirection . |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
◆ loadMessageWithId:error:
Gets a message with the specified message ID from the local database.
- Parameters
-
aMessageId | The message ID. |
pError | The error information if the method fails: Error. |
◆ markAllMessagesAsRead:
Marks all messages in the local database as read.
- Parameters
-
pError | The error information if the method fails: Error. |
◆ markMessageAsReadWithId:error:
- (void) markMessageAsReadWithId: |
|
(NSString *_Nonnull) |
aMessageId |
error: |
|
(AgoraChatError **_Nullable) |
pError |
|
|
| |
Marks a message in the local database as read.
- Parameters
-
aMessageId | The message ID. |
pError | The error information if the method fails: Error. |
◆ pinnedMessages
Get the pinned messages in the conversation
◆ removeMessagesFromServerMessageIds:completion:
- (void) removeMessagesFromServerMessageIds: |
|
(NSArray< __kindof NSString * > *_Nonnull) |
messageIds |
completion: |
|
(void(^)(AgoraChatError *_Nullable aError)) |
aCompletionBlock |
|
|
| |
Removes messages from the conversation by timestamp.
This method deletes messages from both local storage and server.
- Parameters
-
messageIds | The list of IDs of messages to be removed form the current conversation. |
completion | The completion block, which contains the error message if the method fails. |
◆ removeMessagesFromServerWithTimeStamp:completion:
- (void) removeMessagesFromServerWithTimeStamp: |
|
(NSTimeInterval) |
beforeTimeStamp |
completion: |
|
(void(^)(AgoraChatError *_Nullable aError)) |
aCompletionBlock |
|
|
| |
Removes messages from the conversation by message ID.
This method deletes messages from both local storage and server.
- Parameters
-
messageIds | The message timestamp in millisecond. Messages with the timestamp smaller than the specified one will be removed from the current conversation. |
completion | The completion block, which contains the error message if the method fails. |
◆ removeMessagesStart:to:
- (AgoraChatError *_Nullable) removeMessagesStart: |
|
(NSInteger) |
aStartTimestamp |
to: |
|
(NSInteger) |
aEndTimestamp |
|
|
| |
Deletes messages sent or received in a certain period from the local database.
- Parameters
-
aStartTimestamp | The starting UNIX timestamp for message deletion. The unit is millisecond. |
aEndTimestamp | The end UNIX timestamp for message deletion. The unit is millisecond. |
- Returns
- AgoraChatError 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.
◆ searchMessagesWithTypes:timestamp:count:fromUser:searchDirection:completion:
- (void) searchMessagesWithTypes: |
|
(NSArray< NSNumber * > *_Nonnull) |
aTypes |
timestamp: |
|
(long long) |
aTimestamp |
count: |
|
(int) |
aCount |
fromUser: |
|
(NSString *_Nullable) |
aUsername |
searchDirection: |
|
(AgoraChatMessageSearchDirection) |
aDirection |
completion: |
|
(void(^)(NSArray< AgoraChatMessage * > *_Nullable aMessages, AgoraChatError *_Nullable aError)) |
aCompletionBlock |
|
|
| |
Gets messages of certain types that a specified user sends in the conversation.
- Parameters
-
aTypes | The message types to search. Types include txt (text message), img (image message), loc (location message), audio (audio message), video (video message), file (file message), and cmd (command message). AgoraChatMessageBodyType |
aTimestamp | The starting Unix timestamp in the message for query. The unit is millisecond. If you set this parameter as a negative value, the SDK loads messages from the latest one. |
aCount | The number of messages to load each time. If you set this parameter to a value less than 1, the SDK retrieves one message. |
aUsername | The message sender. Setting it as nil means that the SDK ignores this parameter. |
aDirection | The message search direction. See AgoraChatMessageSearchDirection . |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
◆ updateMessageChange:error:
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
-
aMessage | The message to be updated. |
pError | The error information if the method fails: Error. |
◆ 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.
◆ disturbType
- (AgoraChatPushRemindType) disturbType |
|
readnonatomicassign |
The conversation no disturb type.AgoraChatPushRemindType
◆ ext
The conversation extension attribute.
This attribute is not available for thread conversations.
◆ isChatThread
Whether the conversation is a thread conversation:
◆ isPinned
Whether the conversation is pinned:
◆ latestMessage
The latest message in the conversation.
◆ marks
- (NSArray<NSNumber*>*) marks |
|
readnonatomicassign |
◆ messagesCount
The message count in the conversation.
◆ pinnedTime
The UNIX timestamp when the conversation is pinned. The unit is millisecond. This value is 0
when the conversation is not pinned.
◆ type
- (AgoraChatConversationType) type |
|
readnonatomicassign |
◆ unreadMessagesCount
- (int) unreadMessagesCount |
|
readnonatomicassign |
The number of unread messages in the conversation.
The documentation for this class was generated from the following file: