AgoraChatSDK 1.0.7
Instance Methods | Properties | List of all members
AgoraChatConversation Class Reference

#import <AgoraChatConversation.h>

Inheritance diagram for AgoraChatConversation:

Instance Methods

(AgoraChatMessage *_Nullable) - lastReceivedMessage
 
(void) - insertMessage:error:
 
(void) - appendMessage:error:
 
(void) - deleteMessageWithId:error:
 
(void) - deleteAllMessages:
 
(void) - updateMessageChange:error:
 
(void) - markMessageAsReadWithId:error:
 
(void) - markAllMessagesAsRead:
 
(AgoraChatMessage *_Nullable) - loadMessageWithId:error:
 
(NSArray< AgoraChatMessage * > *_Nullable) - loadMessagesStartFromId:count:searchDirection:
 
(void) - loadMessagesStartFromId:count:searchDirection:completion:
 
(NSArray< AgoraChatMessage * > *_Nullable) - loadMessagesWithType:timestamp:count:fromUser:searchDirection:
 
(void) - loadMessagesWithType:timestamp:count:fromUser:searchDirection:completion:
 
(NSArray< AgoraChatMessage * > *_Nullable) - loadMessagesWithKeyword:timestamp:count:fromUser:searchDirection:
 
(void) - loadMessagesWithKeyword:timestamp:count:fromUser:searchDirection:completion:
 
(NSArray< AgoraChatMessage * > *_Nullable) - loadCustomMsgWithKeyword:timestamp:count:fromUser:searchDirection:
 
(void) - loadCustomMsgWithKeyword:timestamp:count:fromUser:searchDirection:completion:
 
(NSArray< AgoraChatMessage * > *_Nullable) - loadMessagesFrom:to:count:
 
(void) - loadMessagesFrom:to:count:completion:
 

Properties

NSString * conversationId
 
AgoraChatConversationType type
 
int unreadMessagesCount
 
int messagesCount
 
NSDictionary * ext
 
BOOL isChatThread
 
AgoraChatMessagelatestMessage
 

Detailed Description

The chat conversation.

Method Documentation

◆ appendMessage:error:

- (void) appendMessage: (AgoraChatMessage *_Nonnull)  aMessage
error: (AgoraChatError **_Nullable)  pError 

Inserts a message to the end of a conversation in local database. The conversationId of the message should be the same as the conversationId of the conversation in order to insert the message into the conversation correctly.

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

◆ deleteAllMessages:

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

Deletes all messages of the conversation from memory cache and local database.

Parameters
pErrorThe error information if the method fails: Error.

◆ deleteMessageWithId:error:

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

Deletes a message.

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

◆ insertMessage:error:

- (void) insertMessage: (AgoraChatMessage *_Nonnull)  aMessage
error: (AgoraChatError **_Nullable)  pError 

Inserts a message to a conversation in local database and SDK will update the last message automatically.

The conversation ID of the message should be the same as conversation ID of the conversation in order to insert the message into the conversation correctly. The inserting message will be inserted based on timestamp.

Method AgoraChatConversation insertMessage:error: = AgoraChatManager importMsessage:completion: + update conversation latest message

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

◆ lastReceivedMessage

- (AgoraChatMessage *_Nullable) 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 specified keyword from local database. The returning messages are sorted by receiving timestamp based on AgoraChatMessageSearchDirection. If the reference timestamp is negative, load from the latest messages; if message count is negative, will be handled as count=1.

This is a synchronous method and blocks the current thread.

Parameters
aKeywordThe search keyword. If aKeyword=nil, ignore.
aTimestampThe load based on reference timestamp. If aTimestamp=-1, will load from the most recent (the latest) message
aCountThe number of messages to load. If you set this parameter less than 1, it will be handled as count=1.
aSenderThe user that sends the message. Setting it as NIL means that the SDK ignores this parameter.
aDirectionThe message search direction. AgoraChatMessageSearchDirectionUp: get aCount of messages before aMessageId; AgoraChatMessageSearchDirectionDown: get aCount of messages after aMessageId * -—
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 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
aKeywordThe keyword for searching the messages. Setting it as NIL means that the SDK ignores this parameter.
aTimestampThe reference Unix timestamp for the messages to be loaded. If you set this parameter as a negative value, the SDK loads messages from the latest.
aCountThe number of messages to load. If you set this parameter less than 1, it will be handled as count=1.
aSenderThe user that sends the message. Setting it as NIL means that the SDK ignores this parameter.
aDirectionThe message search direction: AgoraChatMessageSearchDirection. AgoraChatMessageSearchDirectionUp: get aCount of messages before aMessageId; AgoraChatMessageSearchDirectionDown: get aCount of messages after aMessageId * -—
aCompletionBlockThe 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 messages within specified time range from local database. Returning messages are sorted by sending timestamp.

This is a synchronous method and blocks the current thread.

Parameters
aStartTimestampThe starting timestamp in miliseconds.
aEndTimestampThe ending timestamp in miliseconds.
aCountThe number of messages to load. If you set this parameter less than 1, it will be handled as count=1.
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 messages within specified time range from local database. Returning messages are sorted by sending timestamp.

Parameters
aStartTimestampThe starting timestamp in miliseconds.
aEndTimestampThe ending timestamp in miliseconds.
aCountThe number of messages to load. If you set this parameter less than 1, it will be handled as count=1.
aCompletionBlockThe 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 messages starting from the specified message id from local database.

This method returns messages in the sequence of the timestamp when they are received.

This is a synchronous method and blocks the current thread.

Parameters
aMessageIdThe specified message ID.
aCountThe number of messages to load. If you set this parameter less than 1, it will be handled as count=1.
aDirectionThe message search direction: AgoraChatMessageSearchDirection. AgoraChatMessageSearchDirectionUp: get aCount of messages before aMessageId; AgoraChatMessageSearchDirectionDown: get aCount of messages after aMessageId
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
aMessageIdThe specified message ID loading messages start from.
aCountThe number of messages to load. If you set this parameter less than 1, it will be handled as count=1.
aDirectionThe message search direction: AgoraChatMessageSearchDirection. AgoraChatMessageSearchDirectionUp: get aCount of messages before the timestamp of the specified message ID; AgoraChatMessageSearchDirectionDown: get aCount of messages after the timestamp of the specified message ID.
aCompletionBlockThe 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 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

This is a synchronous method and blocks the current thread.

Parameters
aKeywordThe keyword for searching the messages. Setting it as NIL means that the SDK ignores this parameter.
aTimestampThe reference timestamp for the messages to be loaded. If you set this parameter as a negative value, the SDK loads messages from the latest.
aCountThe number of messages to load. If you set this parameter less than 1, it will be handled as count=1.
aSenderThe message sender (optional). If the parameter is nil, ignore.
aDirectionThe message search direction: AgoraChatMessageSearchDirection. AgoraChatMessageSearchDirectionUp: get aCount of messages before aMessageId; AgoraChatMessageSearchDirectionDown: get aCount of messages after aMessageId * -—
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
aKeywordThe search keyword. If aKeyword=nil, ignore.
aTimestampThe load based on reference timestamp. If aTimestamp=-1, will load from the most recent (the latest) message
aCountThe number of messages to load. If you set this parameter less than 1, it will be handled as count=1.
aSenderThe message sender (optional). If the parameter is nil, ignore.
aDirectionThe message search direction. AgoraChatMessageSearchDirectionUp: get aCount of messages before aMessageId; AgoraChatMessageSearchDirectionDown: get aCount of messages after aMessageId * -—
aCompletionBlockThe 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 

Loads messages with specified message type from local database. Returning messages are sorted by receiving timestamp based on AgoraChatMessageSearchDirection.

This is a synchronous method and blocks the current thread.

Parameters
aTypeThe message type to load. Type includes txt : text msg, img : image msg, loc: location msg, audio: audio msg, video: video msg, file: file msg, cmd: command msg.
aTimestampThe reference timestamp for the messages to be loaded. If you set this parameter as a negative value, the SDK loads messages from the latest.
aCountThe number of messages to load. If you set this parameter less than 1, it will be handled as count=1.
aUsernameThe user that sends the message. Setting it as NIL means that the SDK ignores this parameter.
aDirectionThe message search direction: AgoraChatMessageSearchDirection. AgoraChatMessageSearchDirectionUp: get aCount of messages before aMessageId; AgoraChatMessageSearchDirectionDown: get aCount of messages after aMessageId
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 

Loads messages with specified message type from local database. Returning messages are sorted by receiving timestamp based on AgoraChatMessageSearchDirection.

Parameters
aTypeThe message type to load. Type includes txt : text msg, img : image msg, loc: location msg, audio: audio msg, video: video msg, file: file msg, cmd: command msg.
aTimestampThe reference timestamp for the messages to be loaded. If you set this parameter as a negative value, the SDK loads messages from the latest.
aCountThe number of messages to load. If you set this parameter less than 1, it will be handled as count=1.
aUsernameThe message sender (optional). If the parameter is nil, ignore.
aDirectionThe message search direction. AgoraChatMessageSearchDirectionUp: get aCount of messages before aMessageId; AgoraChatMessageSearchDirectionDown: get aCount of messages after aMessageId
aCompletionBlockThe completion block, which contains the error message if the method fails.

◆ loadMessageWithId:error:

- (AgoraChatMessage *_Nullable) loadMessageWithId: (NSString *_Nonnull)  aMessageId
error: (AgoraChatError **_Nullable)  pError 

Gets a message with the ID.

Parameters
aMessageIdThe message ID.
pErrorThe error information if the method fails: Error.

◆ markAllMessagesAsRead:

- (void) markAllMessagesAsRead: (AgoraChatError **_Nullable)  pError

Marks all messages as read.

Parameters
pErrorThe error information if the method fails: Error.

◆ markMessageAsReadWithId:error:

- (void) markMessageAsReadWithId: (NSString *_Nonnull)  aMessageId
error: (AgoraChatError **_Nullable)  pError 

Marks a message as read.

Parameters
aMessageIdThe message ID.
pErrorThe error information if the method fails: Error.

◆ updateMessageChange:error:

- (void) updateMessageChange: (AgoraChatMessage *_Nonnull)  aMessage
error: (AgoraChatError **_Nullable)  pError 

Uses this method to update a message in local database. Changing properties will affect data in database.

The latestMessage of the conversation and other properties will be updated accordingly. The messageID of the message cannot be updated.

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

Property Documentation

◆ conversationId

- (NSString*) conversationId
readnonatomiccopy

The conversation ID. For one-to-one chat,conversation ID is to chat user's name. For group chat, conversation ID is groupID(), different with getGroupName(). For chat room, conversation ID is chatroom ID, different with chat room name(). For help desk, it is same with one-to-one chat, conversation ID is also chat user's name.

◆ ext

- (NSDictionary*) ext
readwritenonatomiccopy

The conversation extension property.

◆ isChatThread

- (BOOL) isChatThread
readwritenonatomicassign

The latest message in the conversation.

◆ latestMessage

- (AgoraChatMessage*) latestMessage
readnonatomicstrong

The latest message in the conversation.

◆ messagesCount

- (int) messagesCount
readnonatomicassign

Message count

◆ type

- (AgoraChatConversationType) type
readnonatomicassign

The conversation type.

◆ unreadMessagesCount

- (int) unreadMessagesCount
readnonatomicassign

The number of unread messages.


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