HyphenateChatSDK 4.4.0
IEMChatManager.h
1
15#import <Foundation/Foundation.h>
16
17#import "EMCommonDefs.h"
18#import "EMChatManagerDelegate.h"
19#import "EMConversation.h"
20
21#import "EMChatMessage.h"
22#import "EMTextMessageBody.h"
23#import "EMLocationMessageBody.h"
24#import "EMCmdMessageBody.h"
25#import "EMFileMessageBody.h"
26#import "EMImageMessageBody.h"
27#import "EMVoiceMessageBody.h"
28#import "EMVideoMessageBody.h"
29#import "EMCustomMessageBody.h"
30#import "EMCombineMessageBody.h"
31#import "EMCursorResult.h"
32
33#import "EMGroupMessageAck.h"
34#import "EMTranslateLanguage.h"
35#import "EMFetchServerMessagesOption.h"
36#import "EMConversationFilter.h"
37
45typedef NS_ENUM(NSUInteger, EMMessageFetchHistoryDirection) {
46 EMMessageFetchHistoryDirectionUp = 0,
47 EMMessageFetchHistoryDirectionDown
49};
50
51
52@class EMError;
53
65@protocol IEMChatManager <NSObject>
66
67@required
68
69#pragma mark - Delegate
70
84- (void)addDelegate:(id<EMChatManagerDelegate> _Nullable)aDelegate
85 delegateQueue:(dispatch_queue_t _Nullable)aQueue;
86
98- (void)removeDelegate:(id<EMChatManagerDelegate> _Nonnull)aDelegate;
99
100#pragma mark - Conversation
101
117- (NSArray<EMConversation *> * _Nullable)getAllConversations;
118
140- (NSArray<EMConversation *> * _Nullable)getAllConversations:(BOOL)isSort;
141
153- (void)getConversationsFromServer:(void (^_Nullable)(NSArray<EMConversation *> * _Nullable aConversations, EMError * _Nullable aError))aCompletionBlock EM_DEPRECATED_IOS(4_0_0, "Use -IEMChatManager getConversationsFromServerWithCursor:pageSize:completion");
154
170- (void)getConversationsFromServerByPage:(NSUInteger)pageNumber
171 pageSize:(NSUInteger)pageSize
172 completion:(void (^_Nullable)(NSArray<EMConversation *> * _Nullable aConversations, EMError * _Nullable aError))aCompletionBlock EM_DEPRECATED_IOS(4_0_0, "Use -IEMChatManager getConversationsFromServerWithCursor:pageSize:completion");
196- (void)getConversationsFromServerWithCursor:(nullable NSString *)cursor pageSize:(UInt8)pageSize completion:(nonnull void (^)(EMCursorResult<EMConversation *> * _Nullable result, EMError * _Nullable error))completionBlock;
197
217- (void)getPinnedConversationsFromServerWithCursor:(nullable NSString *)cursor pageSize:(UInt8)limit completion:(nonnull void (^)(EMCursorResult<EMConversation *> * _Nullable result, EMError * _Nullable error))completionBlock;
218
238- (void)pinConversation:(nonnull NSString *)conversationId isPinned:(BOOL)isPinned completionBlock:(nullable void(^)(EMError * _Nullable error))completionBlock;
239
255- (EMConversation *_Nullable)getConversationWithConvId:(NSString * _Nullable)aConversationId;
256
280- (EMConversation *_Nullable)getConversation:(NSString *_Nonnull)aConversationId
281 type:(EMConversationType)aType
282 createIfNotExist:(BOOL)aIfCreate;
283
311- (EMConversation *_Nullable)getConversation:(NSString *_Nonnull)aConversationId
312 type:(EMConversationType)aType
313 createIfNotExist:(BOOL)aIfCreate isThread:(BOOL)isThread;
314
335- (void)deleteConversation:(NSString * _Nonnull)aConversationId
336 isDeleteMessages:(BOOL)aIsDeleteMessages
337 completion:(void (^_Nullable)(NSString * _Nullable aConversationId, EMError *_Nullable aError))aCompletionBlock;
338
361 - (void)deleteServerConversation:(NSString * _Nonnull)aConversationId
362 conversationType:(EMConversationType)aConversationType
363 isDeleteServerMessages:(BOOL)aIsDeleteServerMessages
364 completion:(void (^_Nullable)(NSString * _Nullable aConversationId, EMError * _Nullable aError))aCompletionBlock;
365
386- (void)deleteConversations:(NSArray<EMConversation *> * _Nullable)aConversations
387 isDeleteMessages:(BOOL)aIsDeleteMessages
388 completion:(void (^_Nullable)(EMError * _Nullable aError))aCompletionBlock;
389
405- (void)importConversations:(NSArray<EMConversation *> * _Nullable)aConversations
406 completion:(void (^ _Nullable)(EMError * _Nullable aError))aCompletionBlock;
407
408#pragma mark - Message
409
424- (EMChatMessage * _Nullable)getMessageWithMessageId:(NSString * _Nonnull)aMessageId;
425
445- (NSString * _Nullable)getMessageAttachmentPath:(NSString * _Nonnull)aConversationId;
446
461- (void)importMessages:(NSArray<EMChatMessage *> * _Nonnull)aMessages
462 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
463
484- (void)updateMessage:(EMChatMessage *_Nonnull)aMessage
485 completion:(void (^_Nullable)(EMChatMessage * _Nullable aMessage, EMError * _Nullable aError))aCompletionBlock;
505- (void)modifyMessage:(NSString *_Nonnull)messageId body:(EMMessageBody *_Nonnull)body completion:(void (^_Nonnull)(EMError * _Nullable error,EMChatMessage *_Nullable message))completionBlock;
506
527- (void)sendMessageReadAck:(NSString * _Nonnull)aMessageId
528 toUser:(NSString * _Nonnull)aUsername
529 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
530
531
554- (void)sendGroupMessageReadAck:(NSString * _Nonnull)aMessageId
555 toGroup:(NSString * _Nonnull)aGroupId
556 content:(NSString * _Nullable)aContent
557 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
558
592- (void)ackConversationRead:(NSString * _Nonnull)conversationId
593 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
594
613- (void)recallMessageWithMessageId:(NSString *_Nonnull)aMessageId
614 completion:(void (^_Nullable)(EMError *_Nullable aError))aCompletionBlock;
615
616
636- (void)sendMessage:(EMChatMessage *_Nonnull)aMessage
637 progress:(void (^_Nullable)(int progress))aProgressBlock
638 completion:(void (^_Nullable)(EMChatMessage *_Nullable message, EMError *_Nullable error))aCompletionBlock;
639
655- (void)resendMessage:(EMChatMessage *_Nonnull)aMessage
656 progress:(void (^_Nullable)(int progress))aProgressBlock
657 completion:(void (^_Nullable)(EMChatMessage *_Nullable message, EMError *_Nullable error))aCompletionBlock;
658
678- (void)downloadMessageThumbnail:(EMChatMessage *_Nonnull)aMessage
679 progress:(void (^_Nullable)(int progress))aProgressBlock
680 completion:(void (^_Nullable)(EMChatMessage *_Nullable message, EMError *_Nullable error))aCompletionBlock;
681
705- (void)downloadMessageAttachment:(EMChatMessage *_Nonnull)aMessage
706 progress:(void (^_Nullable)(int progress))aProgressBlock
707 completion:(void (^_Nullable)(EMChatMessage *_Nullable message, EMError *_Nullable error))aCompletionBlock;
708
726- (void)downloadAndParseCombineMessage:(EMChatMessage* _Nonnull)aMessage
727 completion:(void (^_Nullable)(NSArray<EMChatMessage *>*_Nullable messages, EMError *_Nullable error))aCompletionBlock;
728
755- (EMCursorResult<EMChatMessage*> *_Nullable)fetchHistoryMessagesFromServer:(NSString *_Nonnull)aConversationId
756 conversationType:(EMConversationType)aConversationType
757 startMessageId:(NSString *_Nullable)aStartMessageId
758 fetchDirection:(EMMessageFetchHistoryDirection)direction
759 pageSize:(int)aPageSize
760 error:(EMError **_Nullable)pError;
785- (EMCursorResult<EMChatMessage*> *_Nullable)fetchHistoryMessagesFromServer:(NSString *_Nonnull)aConversationId
786 conversationType:(EMConversationType)aConversationType
787 startMessageId:(NSString *_Nullable)aStartMessageId
788 pageSize:(int)aPageSize
789 error:(EMError **_Nullable)pError;
790
791
816- (void)asyncFetchHistoryMessagesFromServer:(NSString *_Nonnull)aConversationId
817 conversationType:(EMConversationType)aConversationType
818 startMessageId:(NSString *_Nullable)aStartMessageId
819 pageSize:(int)aPageSize
820 completion:(void (^_Nullable)(EMCursorResult<EMChatMessage*> *_Nullable aResult, EMError *_Nullable aError))aCompletionBlock;
847- (void)asyncFetchHistoryMessagesFromServer:(NSString *_Nonnull)aConversationId
848 conversationType:(EMConversationType)aConversationType
849 startMessageId:(NSString *_Nullable)aStartMessageId
850 fetchDirection:(EMMessageFetchHistoryDirection)direction
851 pageSize:(int)aPageSize
852 completion:(void (^_Nullable)(EMCursorResult<EMChatMessage*> *_Nullable aResult, EMError *_Nullable aError))aCompletionBlock;
853
854
855
856
885- (void)asyncFetchGroupMessageAcksFromServer:(NSString *_Nonnull)aMessageId
886 groupId:(NSString *_Nonnull)aGroupId
887 startGroupAckId:(NSString *_Nonnull)aGroupAckId
888 pageSize:(int)aPageSize
889 completion:(void (^_Nullable)(EMCursorResult<EMGroupMessageAck *> *_Nullable aResult, EMError *_Nullable error, int totalCount))aCompletionBlock;
890
914- (void)reportMessageWithId:(NSString *_Nonnull )aMessageId
915 tag:(NSString *_Nonnull)aTag
916 reason:(NSString *_Nonnull)aReason
917 completion:(void(^_Nullable)(EMError* _Nullable error))aCompletion;
918
935- (void)deleteMessagesBefore:(NSUInteger)aTimestamp
936 completion:(void(^)(EMError*error))aCompletion;
937
938
939
956- (void)removeMessagesFromServerWithConversation:(EMConversation *_Nonnull)conversation messageIds:(NSArray <__kindof NSString*>*_Nonnull)messageIds completion:(void (^ _Nullable)(EMError * _Nullable aError))aCompletionBlock;
973- (void)removeMessagesFromServerWithConversation:(EMConversation *_Nonnull)conversation timeStamp:(NSTimeInterval)beforeTimeStamp completion:(void (^ _Nullable)(EMError * _Nullable aError))aCompletionBlock;
974
975
991- (void)translateMessage:(EMChatMessage * _Nonnull)aMessage
992 targetLanguages:(NSArray<NSString*>* _Nonnull)aLanguages
993 completion:(void (^_Nullable)(EMChatMessage * _Nullable message, EMError * _Nullable error))aCompletionBlock;
994
1007- (void)fetchSupportedLanguages:(void(^_Nullable)(NSArray<EMTranslateLanguage*>* _Nullable languages,EMError* _Nullable error))aCompletionBlock;
1008
1045- (NSArray<EMChatMessage *> * _Nullable)loadMessagesWithType:(EMMessageBodyType)aType
1046 timestamp:(long long)aTimestamp
1047 count:(int)aCount
1048 fromUser:(NSString* _Nullable)aUsername
1049 searchDirection:(EMMessageSearchDirection)aDirection;
1050
1081- (void)loadMessagesWithType:(EMMessageBodyType)aType
1082 timestamp:(long long)aTimestamp
1083 count:(int)aCount
1084 fromUser:(NSString*)aUsername
1085 searchDirection:(EMMessageSearchDirection)aDirection
1086 completion:(void (^)(NSArray<EMChatMessage *> *aMessages, EMError *aError))aCompletionBlock;
1087
1124- (NSArray<EMChatMessage *> *)loadMessagesWithKeyword:(NSString*)aKeywords
1125 timestamp:(long long)aTimestamp
1126 count:(int)aCount
1127 fromUser:(NSString*)aSender
1128 searchDirection:(EMMessageSearchDirection)aDirection;
1129
1159- (void)loadMessagesWithKeyword:(NSString*)aKeywords
1160 timestamp:(long long)aTimestamp
1161 count:(int)aCount
1162 fromUser:(NSString*)aSender
1163 searchDirection:(EMMessageSearchDirection)aDirection
1164 completion:(void (^)(NSArray<EMChatMessage *> *aMessages, EMError *aError))aCompletionBlock;
1165
1197- (void)loadMessagesWithKeyword:(NSString*)aKeywords
1198 timestamp:(long long)aTimestamp
1199 count:(int)aCount
1200 fromUser:(NSString*)aSender
1201 searchDirection:(EMMessageSearchDirection)aDirection
1202 scope:(EMMessageSearchScope)aScope
1203 completion:(void (^)(NSArray<EMChatMessage *> *aMessages, EMError *aError))aCompletionBlock;
1204
1205NS_ASSUME_NONNULL_BEGIN
1221- (void)addReaction:(NSString *)reaction toMessage:(NSString *)messageId completion:(nullable void(^)(EMError * _Nullable))completion;
1222
1238- (void)removeReaction:(NSString *)reaction fromMessage:(NSString *)messageId completion:(nullable void(^)(EMError * _Nullable))completion;
1239
1257- (void)getReactionList:(NSArray <NSString *>*)messageIds
1258 groupId:(nullable NSString *)groupId
1259 chatType:(EMChatType)chatType
1260 completion:(void (^)(NSDictionary <NSString *, NSArray<EMMessageReaction *> *> *, EMError * _Nullable))completion;
1261
1281- (void)getReactionDetail:(NSString *)messageId
1282 reaction:(NSString *)reaction
1283 cursor:(nullable NSString *)cursor
1284 pageSize:(uint64_t)pageSize
1285 completion:(void (^)(EMMessageReaction *, NSString * _Nullable cursor, EMError * _Nullable))completion;
1286
1308- (void)fetchMessagesFromServerBy:(NSString* )conversationId
1309 conversationType:(EMConversationType)type
1310 cursor:(NSString* _Nullable)cursor
1311 pageSize:(NSUInteger)pageSize
1312 option:(EMFetchServerMessagesOption* _Nullable)option
1313 completion:(void (^_Nullable)(EMCursorResult<EMChatMessage*>* _Nullable result, EMError* _Nullable aError))aCompletionBlock;
1314
1335- (void)addConversationMark:(NSArray<NSString*>* _Nonnull)conversationIds mark:(EMMarkType)mark completion:(void (^_Nullable)(EMError* _Nullable aError))completion;
1336
1358- (void)removeConversationMark:(NSArray<NSString*>* _Nonnull)conversationIds mark:(EMMarkType)mark completion:(void (^_Nullable)(EMError* _Nullable aError))completion;
1359
1376- (void)getConversationsFromServerWithCursor:(NSString * _Nullable)cursor filter:(EMConversationFilter* _Nonnull)filter completion:(nonnull void (^)(EMCursorResult<EMConversation *> * _Nullable result, EMError * _Nullable error))completionBlock;
1377
1400- (void)deleteAllMessagesAndConversations:(BOOL)clearServerData completion:(void (^_Nullable)(EMError * _Nullable aError))aCompletionBlock;
1401NS_ASSUME_NONNULL_END
1402
1403@end
Definition: EMChatMessage.h:82
Definition: EMConversationFilter.h:22
Definition: EMConversation.h:114
Definition: EMCursorResult.h:27
Definition: EMError.h:27
Definition: EMFetchServerMessagesOption.h:23
Definition: EMGroupMessageAck.h:21
Definition: EMMessageBody.h:46
Definition: EMMessageReaction.h:21
Definition: EMTranslateLanguage.h:20
Definition: EMChatManagerDelegate.h:31
Definition: IEMChatManager.h:65
NSArray< EMConversation * > *_Nullable getAllConversations()