agora_chat_SDK  3.8.2
Instance Methods | Properties | List of all members
AgoraConversation Class Reference

#import <AgoraConversation.h>

Inheritance diagram for AgoraConversation:

Instance Methods

(Message *) - lastReceivedMessage
 
(void) - insertMessage:error:
 
(void) - appendMessage:error:
 
(void) - deleteMessageWithId:error:
 
(void) - deleteAllMessages:
 
(void) - updateMessageChange:error:
 
(void) - markMessageAsReadWithId:error:
 
(void) - markAllMessagesAsRead:
 
(Message *) - loadMessageWithId:error:
 
(void) - loadMessagesStartFromId:count:searchDirection:completion:
 
(void) - loadMessagesWithType:timestamp:count:fromUser:searchDirection:completion:
 
(void) - loadMessagesWithKeyword:timestamp:count:fromUser:searchDirection:completion:
 
(void) - loadCustomMsgWithKeyword:timestamp:count:fromUser:searchDirection:completion:
 
(void) - loadMessagesFrom:to:count:completion:
 
(BOOL) - insertMessage:
 
(BOOL) - appendMessage:
 
(BOOL) - deleteMessageWithId:
 
("Use -deleteAllMessages: instead") - __deprecated_msg
 
(BOOL) - updateMessage:
 
(BOOL) - markMessageAsReadWithId:
 
("Use -markAllMessagesAsRead: instead") - __deprecated_msg
 
("setExt: will update extend properties to DB") - __deprecated_msg
 
(Message *) - loadMessageWithId:
 
(NSArray *) - loadMoreMessagesFromId:limit:direction:
 
(NSArray *) - loadMoreMessagesWithType:before:limit:from:direction:
 
(NSArray *) - loadMoreMessagesContain:before:limit:from:direction:
 
(NSArray *) - loadMoreMessagesFrom:to:maxCount:
 
("Use -lastReceivedMessage instead") - __deprecated_msg
 

Properties

NSString * conversationId
 
AgoraConversationType type
 
int unreadMessagesCount
 
NSDictionary * ext
 
MessagelatestMessage
 

Detailed Description

Chat conversation

Method Documentation

- ("Use -)deleteAllMessages:

Delete all message of the conversation

Returns
Delete result, YES: mean success, NO: mean failure.

Mark all message as read

Returns
Result of mark all message as read, YES: mean success, NO: mean failure.
- "setExt:

Update conversation extend properties to DB

Returns
Extend properties update result, YES: mean success, NO: mean failure.
- ("Use -lastReceivedMessage instead") __deprecated_msg

Get latest message that received from others

Returns
Message instance
- (BOOL) appendMessage: ("Use -appendMessage:error: instead")  __deprecated_msg

Insert a message to the tail of conversation, message's conversationId should equle to conversation's conversationId, message will be inserted to DB, and update conversation's property

Parameters
aMessageMessage
Returns
Message insert result, YES: mean success, NO: mean failure.
- (void) appendMessage: (Message *)  aMessage
error: (AgoraError **)  pError 

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

Parameters
aMessageMessage
pErrorError
- (void) deleteAllMessages: (AgoraError **)  pError

Delete all messages of the conversation from memory cache and local database

Parameters
pErrorError
- (BOOL) deleteMessageWithId: ("Use -deleteMessageWithId:error: instead")  __deprecated_msg

Delete a message

Parameters
aMessageIdMessage's ID who will be deleted
Returns
Message delete result, YES: mean success, NO: mean failure.
- (void) deleteMessageWithId: (NSString *)  aMessageId
error: (AgoraError **)  pError 

Delete a message

Parameters
aMessageIdId of the message to be deleted
pErrorError
- (BOOL) insertMessage: ("Use -insertMessage:error: instead")  __deprecated_msg

Insert a message to a conversation. ConversationId of the message should be the same as conversationId of the conversation in order to insert the message into the conversation correctly.

Parameters
aMessageMessage
Returns
Message insert result, YES: mean success, NO: mean failure.
- (void) insertMessage: (Message *)  aMessage
error: (AgoraError **)  pError 

Insert a message to a conversation in local database and SDK will update the last message automatically ConversationId of the message should be the same as conversationId of the conversation in order to insert the message into the conversation correctly. The inserting message will be inserted based on timestamp. Method AgoraConversation insertMessage:error: = AgoraChatManager importMsessage:completion: + update conversation latest message

Parameters
aMessageMessage
pErrorError
- (Message *) lastReceivedMessage

Get last received message

Returns
Message instance
- (void) loadCustomMsgWithKeyword: (NSString *)  aKeyword
timestamp: (long long)  aTimestamp
count: (int)  aCount
fromUser: (NSString *)  aSender
searchDirection: (MessageSearchDirection)  aDirection
completion: (void(^)(NSArray *aMessages, AgoraError *aError))  aCompletionBlock 

Load custom messages with specified keyword from local database,returning messages are sorted by receiving timestamp based on MessageSearchDirection. If reference timestamp is negative, load from the latest messages; if message count is negative, will be handled as count=1

Parameters
aKeywordSearch keyword. aKeyword=nil to ignore
aTimestampload based on reference timestamp. If aTimestamp=-1, will load from the most recent (the latest) message
aCountMax number of messages to load
aSenderMessage sender (optional). Pass nil to ignore
aDirectionMessage search direction MessageSearchDirectionUp: get aCount of messages before aMessageId; MessageSearchDirectionDown: get aCount of messages after aMessageId * -—
aCompletionBlockThe callback of completion block
- (void) loadMessagesFrom: (long long)  aStartTimestamp
to: (long long)  aEndTimestamp
count: (int)  aCount
completion: (void(^)(NSArray *aMessages, AgoraError *aError))  aCompletionBlock 

Load messages within specified time range from local database. Returning messages are sorted by sending timestamp

Parameters
aStartTimestampStarting timestamp in miliseconds
aEndTimestampEnding timestamp in miliseconds
aCountMax number of messages to load
aCompletionBlockThe callback of completion block
- (void) loadMessagesStartFromId: (NSString *)  aMessageId
count: (int)  aCount
searchDirection: (MessageSearchDirection)  aDirection
completion: (void(^)(NSArray *aMessages, AgoraError *aError))  aCompletionBlock 

Load messages starting from the specified message id from local database. Returning messages are sorted by receiving timestamp based on MessageSearchDirection. If the aMessageId is nil, will return starting from the latest message

Parameters
aMessageIdStart loading messages from the specified message id
aCountMax number of messages to load
aDirectionMessage search direction. MessageSearchDirectionUp: get aCount of messages before aMessageId; MessageSearchDirectionDown: get aCount of messages after aMessageId
aCompletionBlockThe callback of completion block
- (void) loadMessagesWithKeyword: (NSString *)  aKeyword
timestamp: (long long)  aTimestamp
count: (int)  aCount
fromUser: (NSString *)  aSender
searchDirection: (MessageSearchDirection)  aDirection
completion: (void(^)(NSArray *aMessages, AgoraError *aError))  aCompletionBlock 

Load messages with specified keyword from local database, returning messages are sorted by receiving timestamp based on MessageSearchDirection. If reference timestamp is negative, load from the latest messages; if message count is negative, will be handled as count=1

Parameters
aKeywordSearch keyword. aKeyword=nil to ignore
aTimestampload based on reference timestamp. If aTimestamp=-1, will load from the most recent (the latest) message
aCountMax number of messages to load
aSenderMessage sender (optional). Pass nil to ignore
aDirectionMessage search direction MessageSearchDirectionUp: get aCount of messages before aMessageId; MessageSearchDirectionDown: get aCount of messages after aMessageId * -—
aCompletionBlockThe callback of completion block
- (void) loadMessagesWithType: (MessageBodyType)  aType
timestamp: (long long)  aTimestamp
count: (int)  aCount
fromUser: (NSString *)  aUsername
searchDirection: (MessageSearchDirection)  aDirection
completion: (void(^)(NSArray *aMessages, AgoraError *aError))  aCompletionBlock 

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

Parameters
aTypeMessage type to load
aTimestampload based on reference timestamp. If aTimestamp=-1, will load from the most recent (the latest) message
aCountMax number of messages to load. if aCount<0, will be handled as count=1
aUsernameMessage sender (optional). Use aUsername=nil to ignore
aDirectionMessage search direction MessageSearchDirectionUp: get aCount of messages before aMessageId; MessageSearchDirectionDown: get aCount of messages after aMessageId
aCompletionBlockThe callback of completion block
- (Message *) loadMessageWithId: ("Use -loadMessageWithId:error: instead")  __deprecated_msg

Get a message with the ID

Parameters
aMessageIdMessage's id
Returns
Message instance
- (Message *) loadMessageWithId: (NSString *)  aMessageId
error: (AgoraError **)  pError 

Get a message with the ID

Parameters
aMessageIdMessageID
pErrorError
- (NSArray *) loadMoreMessagesContain: (NSString *)  aKeywords
before: (long long)  aTimestamp
limit: (int)  aLimit
from: (NSString *)  aSender
direction: ("Use -loadMessagesContainKeywords:timestamp:count:fromUser:searchDirection:completion: instead")  __deprecated_msg 

Get more messages contain specified keywords from DB, result messages are sorted by received time, if reference timestamp is negative, will fetch message from latest message, andd will fetch all messages that meet the condition if aLimit is negative

Parameters
aKeywordsSearch content, will ignore it if it's empty
aTimestampReference timestamp
aLimitCount of messages to load
aSenderMessage sender, will ignore it if it's empty
aDirectionMessage search direction
Returns
Message NSArray<Message>
- (NSArray *) loadMoreMessagesFrom: (long long)  aStartTimestamp
to: (long long)  aEndTimestamp
maxCount: ("Use -loadMessagesFrom:to:count:completion: instead")  __deprecated_msg 

Load messages from DB in duration, result messages are sorted by receive time, user should limit the max count to load to avoid memory issue

Parameters
aStartTimestampStart time's timestamp in miliseconds
aEndTimestampEnd time's timestamp in miliseconds
aMaxCountMessage search direction
Returns
Message NSArray<Message>
- (NSArray *) loadMoreMessagesFromId: (NSString *)  aMessageId
limit: (int)  aLimit
direction: ("Use -loadMessagesStartFromId:count:searchDirection:completion: instead")  __deprecated_msg 

Get more messages from DB, result messages are sorted by receive time, and NOT include the reference message, if reference messag's ID is nil, will fetch message from latest message

Parameters
aMessageIdReference message's ID
aLimitCount of messages to load
aDirectionMessage search direction
Returns
Message NSArray<Message>
- (NSArray *) loadMoreMessagesWithType: (MessageBodyType)  aType
before: (long long)  aTimestamp
limit: (int)  aLimit
from: (NSString *)  aSender
direction: ("Use -loadMessagesWithType:timestamp:count:fromUser:searchDirection:completion: instead")  __deprecated_msg 

Get more messages with specified type from DB, result messages are sorted by received time, if reference timestamp is negative, will fetch message from latest message, andd will fetch all messages that meet the condition if aLimit is negative

Parameters
aTypeMessage type to load
aTimestampReference timestamp
aLimitCount of messages to load
aSenderMessage sender, will ignore it if it's empty
aDirectionMessage search direction
Returns
Message NSArray<Message>
- (void) markAllMessagesAsRead: (AgoraError **)  pError

Mark all messages as read

Parameters
pErrorError
- (BOOL) markMessageAsReadWithId: ("Use -markMessageAsReadWithId:error: instead")  __deprecated_msg

Mark a message as read

Parameters
aMessageIdMessage's ID who will be set read status
Returns
Result of mark message as read, YES: mean success, NO: mean failure.
- (void) markMessageAsReadWithId: (NSString *)  aMessageId
error: (AgoraError **)  pError 

Mark a message as read

Parameters
aMessageIdMessageID
pErrorError
- (BOOL) updateMessage: ("Use -updateMessageChange:error: instead")  __deprecated_msg

Update a message, can't update message's messageId, conversation's latestMessage and so on properties will update after update the message

Parameters
aMessageMessage
Returns
Message update result, YES: mean success, NO: mean failure.
- (void) updateMessageChange: (Message *)  aMessage
error: (AgoraError **)  pError 

Use this method to update a message in local database. Changing properties will affect data in database LatestMessage of the conversation and other properties will be updated accordingly. messageId of the message cannot be updated

Parameters
aMessageMessage
pErrorError

Property Documentation

- (NSString*) conversationId
readnonatomiccopy

conversation ID For single 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 single chat, conversationID is also chat user's name

- (NSDictionary*) ext
readwritenonatomiccopy

Conversation extension property

- (Message*) latestMessage
readnonatomicstrong

Conversation latest message

- (AgoraConversationType) type
readnonatomicassign

Conversation type

- (int) unreadMessagesCount
readnonatomicassign

Unread message count


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