AgoraChatSDK 1.3.1
IAgoraChatManager.h
1
9#import <Foundation/Foundation.h>
10
11#import "AgoraChatCommonDefs.h"
12#import "AgoraChatManagerDelegate.h"
13#import "AgoraChatConversation.h"
14
15#import "AgoraChatMessage.h"
16#import "AgoraChatTextMessageBody.h"
17#import "AgoraChatLocationMessageBody.h"
18#import "AgoraChatCmdMessageBody.h"
19#import "AgoraChatFileMessageBody.h"
20#import "AgoraChatImageMessageBody.h"
21#import "AgoraChatVoiceMessageBody.h"
22#import "AgoraChatVideoMessageBody.h"
23#import "AgoraChatCustomMessageBody.h"
24#import "AgoraChatCombineMessageBody.h"
25#import "AgoraChatCursorResult.h"
26
27#import "AgoraChatGroupMessageAck.h"
28#import "AgoraChatTranslateLanguage.h"
29#import "AgoraChatFetchServerMessagesOption.h"
30#import "AgoraChatConversationFilter.h"
31
36typedef NS_ENUM(NSUInteger, AgoraChatMessageFetchHistoryDirection) {
37 AgoraChatMessageFetchHistoryDirectionUp = 0,
38 AgoraChatMessageFetchHistoryDirectionDown
40};
41
42
43@class AgoraChatError;
44
51@protocol IAgoraChatManager <NSObject>
52
53@required
54
55#pragma mark - Delegate
56
64- (void)addDelegate:(id<AgoraChatManagerDelegate> _Nullable)aDelegate
65 delegateQueue:(dispatch_queue_t _Nullable)aQueue;
66
73- (void)removeDelegate:(id<AgoraChatManagerDelegate> _Nonnull)aDelegate;
74
75#pragma mark - Conversation
76
85- (NSArray<AgoraChatConversation *> * _Nullable)getAllConversations;
86
100- (NSArray<AgoraChatConversation *> * _Nullable)filterConversationsFromDB:(BOOL)cleanMemoryCache filter:(BOOL(^_Nullable)(AgoraChatConversation * _Nonnull conversation))filter NS_SWIFT_NAME(filterConversationsFromDB(cleanMemoryCache:filter:));
101
102
108
120- (NSArray<AgoraChatConversation *> * _Nullable)getAllConversations:(BOOL)isSort;
121
128- (void)getConversationsFromServer:(void (^_Nullable)(NSArray<AgoraChatConversation *> * _Nullable aConversations, AgoraChatError * _Nullable aError))aCompletionBlock EM_DEPRECATED_IOS(4_0_0, "Use -IAgoraChatManager getConversationsFromServerWithCursor:pageSize:completion");
129
138- (void)getConversationsFromServerByPage:(NSUInteger)pageNumber
139 pageSize:(NSUInteger)pageSize
140 completion:(void (^_Nullable)(NSArray<AgoraChatConversation *> * _Nullable aConversations, AgoraChatError * _Nullable aError))aCompletionBlock EM_DEPRECATED_IOS(4_0_0, "Use -IAgoraChatManager getConversationsFromServerWithCursor:pageSize:completion");
153- (void)getConversationsFromServerWithCursor:(nullable NSString *)cursor pageSize:(UInt8)pageSize completion:(nonnull void (^)(AgoraChatCursorResult<AgoraChatConversation *> * _Nullable result, AgoraChatError * _Nullable error))completionBlock;
154
165- (void)getPinnedConversationsFromServerWithCursor:(nullable NSString *)cursor pageSize:(UInt8)limit completion:(nonnull void (^)(AgoraChatCursorResult<AgoraChatConversation *> * _Nullable result, AgoraChatError * _Nullable error))completionBlock;
166
177- (void)pinConversation:(nonnull NSString *)conversationId isPinned:(BOOL)isPinned completionBlock:(nullable void(^)(AgoraChatError * _Nullable error))completionBlock;
178
187- (AgoraChatConversation *_Nullable)getConversationWithConvId:(NSString * _Nullable)aConversationId;
188
201- (AgoraChatConversation *_Nullable)getConversation:(NSString *_Nonnull)aConversationId
202 type:(AgoraChatConversationType)aType
203 createIfNotExist:(BOOL)aIfCreate;
204
219- (AgoraChatConversation *_Nullable)getConversation:(NSString *_Nonnull)aConversationId
220 type:(AgoraChatConversationType)aType
221 createIfNotExist:(BOOL)aIfCreate isThread:(BOOL)isThread;
222
234- (void)deleteConversation:(NSString * _Nonnull)aConversationId
235 isDeleteMessages:(BOOL)aIsDeleteMessages
236 completion:(void (^_Nullable)(NSString * _Nullable aConversationId, AgoraChatError *_Nullable aError))aCompletionBlock;
237
250 - (void)deleteServerConversation:(NSString * _Nonnull)aConversationId
251 conversationType:(AgoraChatConversationType)aConversationType
252 isDeleteServerMessages:(BOOL)aIsDeleteServerMessages
253 completion:(void (^_Nullable)(NSString * _Nullable aConversationId, AgoraChatError * _Nullable aError))aCompletionBlock;
254
266- (void)deleteConversations:(NSArray<AgoraChatConversation *> * _Nullable)aConversations
267 isDeleteMessages:(BOOL)aIsDeleteMessages
268 completion:(void (^_Nullable)(AgoraChatError * _Nullable aError))aCompletionBlock;
269
278- (void)importConversations:(NSArray<AgoraChatConversation *> * _Nullable)aConversations
279 completion:(void (^ _Nullable)(AgoraChatError * _Nullable aError))aCompletionBlock;
280
281#pragma mark - Message
282
290- (AgoraChatMessage * _Nullable)getMessageWithMessageId:(NSString * _Nonnull)aMessageId;
291
302- (NSString * _Nullable)getMessageAttachmentPath:(NSString * _Nonnull)aConversationId;
303
312- (void)importMessages:(NSArray<AgoraChatMessage *> * _Nonnull)aMessages
313 completion:(void (^_Nullable)(AgoraChatError *_Nullable aError))aCompletionBlock;
314
327- (void)updateMessage:(AgoraChatMessage *_Nonnull)aMessage
328 completion:(void (^_Nullable)(AgoraChatMessage * _Nullable aMessage, AgoraChatError * _Nullable aError))aCompletionBlock;
340- (void)modifyMessage:(NSString *_Nonnull)messageId body:(AgoraChatMessageBody *_Nonnull)body completion:(void (^_Nonnull)(AgoraChatError * _Nullable error,AgoraChatMessage *_Nullable message))completionBlock;
341
353- (void)sendMessageReadAck:(NSString * _Nonnull)aMessageId
354 toUser:(NSString * _Nonnull)aUsername
355 completion:(void (^_Nullable)(AgoraChatError *_Nullable aError))aCompletionBlock;
356
357
370- (void)sendGroupMessageReadAck:(NSString * _Nonnull)aMessageId
371 toGroup:(NSString * _Nonnull)aGroupId
372 content:(NSString * _Nullable)aContent
373 completion:(void (^_Nullable)(AgoraChatError *_Nullable aError))aCompletionBlock;
374
391- (void)ackConversationRead:(NSString * _Nonnull)conversationId
392 completion:(void (^_Nullable)(AgoraChatError *_Nullable aError))aCompletionBlock;
393
404- (void)recallMessageWithMessageId:(NSString *_Nonnull)aMessageId
405 completion:(void (^_Nullable)(AgoraChatError *_Nullable aError))aCompletionBlock;
406
418- (void)recallMessageWithMessageId:(NSString *_Nonnull)aMessageId ext:(NSString * _Nullable)ext completion:(void (^_Nonnull)(AgoraChatError * _Nullable))aCompletionBlock;
429- (void)sendMessage:(AgoraChatMessage *_Nonnull)aMessage
430 progress:(void (^_Nullable)(int progress))aProgressBlock
431 completion:(void (^_Nullable)(AgoraChatMessage *_Nullable message, AgoraChatError *_Nullable error))aCompletionBlock;
432
441- (void)resendMessage:(AgoraChatMessage *_Nonnull)aMessage
442 progress:(void (^_Nullable)(int progress))aProgressBlock
443 completion:(void (^_Nullable)(AgoraChatMessage *_Nullable message, AgoraChatError *_Nullable error))aCompletionBlock;
444
455- (void)downloadMessageThumbnail:(AgoraChatMessage *_Nonnull)aMessage
456 progress:(void (^_Nullable)(int progress))aProgressBlock
457 completion:(void (^_Nullable)(AgoraChatMessage *_Nullable message, AgoraChatError *_Nullable error))aCompletionBlock;
458
471- (void)downloadMessageAttachment:(AgoraChatMessage *_Nonnull)aMessage
472 progress:(void (^_Nullable)(int progress))aProgressBlock
473 completion:(void (^_Nullable)(AgoraChatMessage *_Nullable message, AgoraChatError *_Nullable error))aCompletionBlock;
474
484- (void)downloadAndParseCombineMessage:(AgoraChatMessage* _Nonnull)aMessage
485 completion:(void (^_Nullable)(NSArray<AgoraChatMessage *>*_Nullable messages, AgoraChatError *_Nullable error))aCompletionBlock;
486
500- (AgoraChatCursorResult<AgoraChatMessage*> *_Nullable)fetchHistoryMessagesFromServer:(NSString *_Nonnull)aConversationId
501 conversationType:(AgoraChatConversationType)aConversationType
502 startMessageId:(NSString *_Nullable)aStartMessageId
503 fetchDirection:(AgoraChatMessageFetchHistoryDirection)direction
504 pageSize:(int)aPageSize
505 error:(AgoraChatError **_Nullable)pError __deprecated_msg("Use -fetchMessagesFromServerBy:conversationType:cursor:pageSize:option:completion: instead");
518- (AgoraChatCursorResult<AgoraChatMessage*> *_Nullable)fetchHistoryMessagesFromServer:(NSString *_Nonnull)aConversationId
519 conversationType:(AgoraChatConversationType)aConversationType
520 startMessageId:(NSString *_Nullable)aStartMessageId
521 pageSize:(int)aPageSize
522 error:(AgoraChatError **_Nullable)pError __deprecated_msg("Use -fetchMessagesFromServerBy:conversationType:cursor:pageSize:option:completion: instead");
523
524
537- (void)asyncFetchHistoryMessagesFromServer:(NSString *_Nonnull)aConversationId
538 conversationType:(AgoraChatConversationType)aConversationType
539 startMessageId:(NSString *_Nullable)aStartMessageId
540 pageSize:(int)aPageSize
541 completion:(void (^_Nullable)(AgoraChatCursorResult<AgoraChatMessage*> *_Nullable aResult, AgoraChatError *_Nullable aError))aCompletionBlock __deprecated_msg("Use -fetchMessagesFromServerBy:conversationType:cursor:pageSize:option:completion: instead");
555- (void)asyncFetchHistoryMessagesFromServer:(NSString *_Nonnull)aConversationId
556 conversationType:(AgoraChatConversationType)aConversationType
557 startMessageId:(NSString *_Nullable)aStartMessageId
558 fetchDirection:(AgoraChatMessageFetchHistoryDirection)direction
559 pageSize:(int)aPageSize
560 completion:(void (^_Nullable)(AgoraChatCursorResult<AgoraChatMessage*> *_Nullable aResult, AgoraChatError *_Nullable aError))aCompletionBlock __deprecated_msg("Use -fetchMessagesFromServerBy:conversationType:cursor:pageSize:option:completion: instead");
561
562
563
564
579- (void)asyncFetchGroupMessageAcksFromServer:(NSString *_Nonnull)aMessageId
580 groupId:(NSString *_Nonnull)aGroupId
581 startGroupAckId:(NSString *_Nonnull)aGroupAckId
582 pageSize:(int)aPageSize
583 completion:(void (^_Nullable)(AgoraChatCursorResult<AgoraChatGroupMessageAck *> *_Nullable aResult, AgoraChatError *_Nullable error, int totalCount))aCompletionBlock;
584
596- (void)reportMessageWithId:(NSString *_Nonnull )aMessageId
597 tag:(NSString *_Nonnull)aTag
598 reason:(NSString *_Nonnull)aReason
599 completion:(void(^_Nullable)(AgoraChatError* _Nullable error))aCompletion;
600
609- (void)deleteMessagesBefore:(NSUInteger)aTimestamp
610 completion:(void(^)(AgoraChatError*error))aCompletion;
611
612
613
623- (void)removeMessagesFromServerWithConversation:(AgoraChatConversation *_Nonnull)conversation messageIds:(NSArray <__kindof NSString*>*_Nonnull)messageIds completion:(void (^ _Nullable)(AgoraChatError * _Nullable aError))aCompletionBlock;
633- (void)removeMessagesFromServerWithConversation:(AgoraChatConversation *_Nonnull)conversation timeStamp:(NSTimeInterval)beforeTimeStamp completion:(void (^ _Nullable)(AgoraChatError * _Nullable aError))aCompletionBlock;
634
635
644- (void)translateMessage:(AgoraChatMessage * _Nonnull)aMessage
645 targetLanguages:(NSArray<NSString*>* _Nonnull)aLanguages
646 completion:(void (^_Nullable)(AgoraChatMessage * _Nullable message, AgoraChatError * _Nullable error))aCompletionBlock;
647
655- (void)fetchSupportedLanguages:(void(^_Nullable)(NSArray<AgoraChatTranslateLanguage*>* _Nullable languages,AgoraChatError* _Nullable error))aCompletionBlock;
656
676- (NSArray<AgoraChatMessage *> * _Nullable)loadMessagesWithType:(AgoraChatMessageBodyType)aType
677 timestamp:(long long)aTimestamp
678 count:(int)aCount
679 fromUser:(NSString* _Nullable)aUsername
680 searchDirection:(AgoraChatMessageSearchDirection)aDirection;
681
698- (void)loadMessagesWithType:(AgoraChatMessageBodyType)aType
699 timestamp:(long long)aTimestamp
700 count:(int)aCount
701 fromUser:(NSString*)aUsername
702 searchDirection:(AgoraChatMessageSearchDirection)aDirection
703 completion:(void (^)(NSArray<AgoraChatMessage *> *aMessages, AgoraChatError *aError))aCompletionBlock;
704
721- (void)searchMessagesWithTypes:(NSArray <NSNumber*>* _Nonnull)aTypes
722 timestamp:(long long)aTimestamp
723 count:(int)aCount
724 fromUser:(NSString* _Nullable)aUsername
725 searchDirection:(AgoraChatMessageSearchDirection)aDirection
726 completion:(void (^_Nonnull)(NSArray<AgoraChatMessage *> * _Nullable aMessages, AgoraChatError * _Nullable aError))aCompletionBlock;
727
747- (NSArray<AgoraChatMessage *> *)loadMessagesWithKeyword:(NSString*)aKeywords
748 timestamp:(long long)aTimestamp
749 count:(int)aCount
750 fromUser:(NSString*)aSender
751 searchDirection:(AgoraChatMessageSearchDirection)aDirection;
752
768- (void)loadMessagesWithKeyword:(NSString*)aKeywords
769 timestamp:(long long)aTimestamp
770 count:(int)aCount
771 fromUser:(NSString*)aSender
772 searchDirection:(AgoraChatMessageSearchDirection)aDirection
773 completion:(void (^)(NSArray<AgoraChatMessage *> *aMessages, AgoraChatError *aError))aCompletionBlock;
774
791- (void)loadMessagesWithKeyword:(NSString*)aKeywords
792 timestamp:(long long)aTimestamp
793 count:(int)aCount
794 fromUser:(NSString*)aSender
795 searchDirection:(AgoraChatMessageSearchDirection)aDirection
796 scope:(AgoraChatMessageSearchScope)aScope
797 completion:(void (^)(NSArray<AgoraChatMessage *> *aMessages, AgoraChatError *aError))aCompletionBlock;
798
799NS_ASSUME_NONNULL_BEGIN
808- (void)addReaction:(NSString *)reaction toMessage:(NSString *)messageId completion:(nullable void(^)(AgoraChatError * _Nullable))completion;
809
818- (void)removeReaction:(NSString *)reaction fromMessage:(NSString *)messageId completion:(nullable void(^)(AgoraChatError * _Nullable))completion;
819
829- (void)getReactionList:(NSArray <NSString *>*)messageIds
830 groupId:(nullable NSString *)groupId
831 chatType:(AgoraChatType)chatType
832 completion:(void (^)(NSDictionary <NSString *, NSArray<AgoraChatMessageReaction *> *> *, AgoraChatError * _Nullable))completion;
833
844- (void)getReactionDetail:(NSString *)messageId
845 reaction:(NSString *)reaction
846 cursor:(nullable NSString *)cursor
847 pageSize:(uint64_t)pageSize
848 completion:(void (^)(AgoraChatMessageReaction *, NSString * _Nullable cursor, AgoraChatError * _Nullable))completion;
849
866- (void)fetchMessagesFromServerBy:(NSString* )conversationId
867 conversationType:(AgoraChatConversationType)type
868 cursor:(NSString* _Nullable)cursor
869 pageSize:(NSUInteger)pageSize
870 option:(AgoraChatFetchServerMessagesOption* _Nullable)option
871 completion:(void (^_Nullable)(AgoraChatCursorResult<AgoraChatMessage*>* _Nullable result, AgoraChatError* _Nullable aError))aCompletionBlock;
872
884- (void)addConversationMark:(NSArray<NSString*>* _Nonnull)conversationIds mark:(AgoraChatMarkType)mark completion:(void (^_Nullable)(AgoraChatError* _Nullable aError))completion;
885
898- (void)removeConversationMark:(NSArray<NSString*>* _Nonnull)conversationIds mark:(AgoraChatMarkType)mark completion:(void (^_Nullable)(AgoraChatError* _Nullable aError))completion;
899
909- (void)getConversationsFromServerWithCursor:(NSString * _Nullable)cursor filter:(AgoraChatConversationFilter* _Nonnull)filter completion:(nonnull void (^)(AgoraChatCursorResult<AgoraChatConversation *> * _Nullable result, AgoraChatError * _Nullable error))completionBlock;
910
923- (void)deleteAllMessagesAndConversations:(BOOL)clearServerData completion:(void (^_Nullable)(AgoraChatError * _Nullable aError))aCompletionBlock;
924
932- (void)pinMessage:(NSString* _Nonnull)messageId completion:(void (^_Nullable)(AgoraChatMessage* _Nullable message,AgoraChatError * _Nullable aError))aCompletionBlock;
941- (void)unpinMessage:(NSString* _Nonnull)messageId completion:(void (^_Nullable)(AgoraChatMessage* _Nullable message,AgoraChatError * _Nullable aError))aCompletionBlock;
942
950- (void)getPinnedMessagesFromServer:(NSString* _Nonnull)conversationId completion:(void (^_Nullable)(NSArray<AgoraChatMessage*>* _Nullable messages,AgoraChatError * _Nullable aError))aCompletionBlock;
951
959
966- (void)getMessageCountWithCompletion:(void (^)(NSInteger count, AgoraChatError * _Nullable aError))completion;
967
968NS_ASSUME_NONNULL_END
969
970@end
Definition: AgoraChatConversationFilter.h:19
Definition: AgoraChatConversation.h:87
Definition: AgoraChatCursorResult.h:16
Definition: AgoraChatError.h:18
Definition: AgoraChatFetchServerMessagesOption.h:20
Definition: AgoraChatGroupMessageAck.h:18
Definition: AgoraChatMessageBody.h:33
Definition: AgoraChatMessage.h:87
Definition: AgoraChatMessageReaction.h:18
Definition: AgoraChatTranslateLanguage.h:17
Definition: AgoraChatManagerDelegate.h:22
Definition: IAgoraChatManager.h:51
void cleanConversationsMemoryCache()
AgoraChatError * markAllConversationsAsRead()
NSArray< AgoraChatConversation * > *_Nullable getAllConversations()