HyphenateChatSDK 4.5.0
EMConversation.h
1
15#import <Foundation/Foundation.h>
16
17#import "EMMessageBody.h"
18#import "EMCursorResult.h"
19
27typedef NS_ENUM(NSInteger, EMConversationType) {
28 EMConversationTypeChat = 0,
29 EMConversationTypeGroupChat,
30 EMConversationTypeChatRoom,
31};
32
44typedef NS_ENUM(NSInteger, EMMarkType) {
45 EMMarkType0 = 0,
46 EMMarkType1 = 1,
47 EMMarkType2 = 2,
48 EMMarkType3 = 3,
49 EMMarkType4 = 4,
50 EMMarkType5 = 5,
51 EMMarkType6 = 6,
52 EMMarkType7 = 7,
53 EMMarkType8 = 8,
54 EMMarkType9 = 9,
55 EMMarkType10 = 10,
56 EMMarkType11 = 11,
57 EMMarkType12 = 12,
58 EMMarkType13 = 13,
59 EMMarkType14 = 14,
60 EMMarkType15 = 15,
61 EMMarkType16 = 16,
62 EMMarkType17 = 17,
63 EMMarkType18 = 18,
64 EMMarkType19 = 19,
65};
66
85typedef NS_ENUM(NSInteger, EMMessageSearchDirection) {
86 EMMessageSearchDirectionUp = 0,
87 EMMessageSearchDirectionDown
88};
89
97typedef NS_ENUM(NSInteger, EMMessageSearchScope) {
98 EMMessageSearchScopeContent = 0,
99 EMMessageSearchScopeExt,
100 EMMessageSearchScopeAll
101};
102
103@class EMChatMessage;
104@class EMError;
105
113@interface EMConversation : NSObject
114
128@property (nonatomic, copy, readonly) NSString *conversationId;
129
137@property (nonatomic, assign, readonly) EMConversationType type;
138
146@property (nonatomic, assign, readonly) int unreadMessagesCount;
147
155@property (nonatomic, assign, readonly) int messagesCount;
156
168@property (nonatomic, copy) NSDictionary *ext;
169
181@property (nonatomic, assign) BOOL isChatThread;
182
194@property (readonly) BOOL isPinned;
195
203@property (readonly) int64_t pinnedTime;
204
212@property (nonatomic, strong, readonly) EMChatMessage *latestMessage;
213
221@property (nonatomic, readonly) NSArray<NSNumber*>* marks;
222
235
258- (void)insertMessage:(EMChatMessage *_Nonnull)aMessage
259 error:(EMError ** _Nullable)pError;
260
283- (void)appendMessage:(EMChatMessage *_Nonnull)aMessage
284 error:(EMError **_Nullable)pError;
285
300- (void)deleteMessageWithId:(NSString *_Nonnull)aMessageId
301 error:(EMError ** _Nullable)pError;
302
314- (void)deleteAllMessages:(EMError ** _Nullable)pError;
315
316
333- (void)removeMessagesFromServerMessageIds:(NSArray <__kindof NSString*>*_Nonnull)messageIds completion:(void (^ _Nullable)(EMError * _Nullable aError))aCompletionBlock;
350- (void)removeMessagesFromServerWithTimeStamp:(NSTimeInterval)beforeTimeStamp completion:(void (^ _Nullable)(EMError * _Nullable aError))aCompletionBlock;
351
372- (void)updateMessageChange:(EMChatMessage *_Nonnull)aMessage
373 error:(EMError ** _Nullable)pError;
374
389- (void)markMessageAsReadWithId:(NSString *_Nonnull)aMessageId
390 error:(EMError ** _Nullable)pError;
391
404- (void)markAllMessagesAsRead:(EMError ** _Nullable)pError;
405
413- (NSArray<EMChatMessage*>* _Nullable)pinnedMessages;
414
415
416#pragma mark - Load Messages Methods
417
432- (EMChatMessage * _Nullable)loadMessageWithId:(NSString * _Nonnull)aMessageId
433 error:(EMError ** _Nullable)pError;
434
465- (NSArray<EMChatMessage *> * _Nullable)loadMessagesStartFromId:(NSString * _Nullable)aMessageId
466 count:(int)aCount
467 searchDirection:(EMMessageSearchDirection)aDirection;
468
495- (void)loadMessagesStartFromId:(NSString * _Nullable)aMessageId
496 count:(int)aCount
497 searchDirection:(EMMessageSearchDirection)aDirection
498 completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
499
528- (NSArray<EMChatMessage *> * _Nullable)loadMessagesWithType:(EMMessageBodyType)aType
529 timestamp:(long long)aTimestamp
530 count:(int)aCount
531 fromUser:(NSString* _Nullable)aUsername
532 searchDirection:(EMMessageSearchDirection)aDirection;
533
556- (void)loadMessagesWithType:(EMMessageBodyType)aType
557 timestamp:(long long)aTimestamp
558 count:(int)aCount
559 fromUser:(NSString* _Nullable)aUsername
560 searchDirection:(EMMessageSearchDirection)aDirection
561 completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
562
593- (NSArray<EMChatMessage *> * _Nullable)loadMessagesWithKeyword:(NSString* _Nullable)aKeyword
594 timestamp:(long long)aTimestamp
595 count:(int)aCount
596 fromUser:(NSString* _Nullable)aSender
597 searchDirection:(EMMessageSearchDirection)aDirection;
598
622- (void)loadMessagesWithKeyword:(NSString* _Nullable)aKeyword
623 timestamp:(long long)aTimestamp
624 count:(int)aCount
625 fromUser:(NSString* _Nullable)aSender
626 searchDirection:(EMMessageSearchDirection)aDirection
627 completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
628
660- (void)loadMessagesWithKeyword:(NSString* _Nullable)aKeyword
661 timestamp:(long long)aTimestamp
662 count:(int)aCount
663 fromUser:(NSString* _Nullable)aSender
664 searchDirection:(EMMessageSearchDirection)aDirection
665 scope:(EMMessageSearchScope)aScope
666 completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
667
697- (NSArray<EMChatMessage *> * _Nullable)loadCustomMsgWithKeyword:(NSString*)aKeyword
698 timestamp:(long long)aTimestamp
699 count:(int)aCount
700 fromUser:(NSString* _Nullable)aSender
701 searchDirection:(EMMessageSearchDirection)aDirection;
702
726- (void)loadCustomMsgWithKeyword:(NSString* _Nullable)aKeyword
727 timestamp:(long long)aTimestamp
728 count:(int)aCount
729 fromUser:(NSString* _Nullable)aSender
730 searchDirection:(EMMessageSearchDirection)aDirection
731 completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
732
762- (NSArray<EMChatMessage *> * _Nullable)loadMessagesFrom:(long long)aStartTimestamp
763 to:(long long)aEndTimestamp
764 count:(int)aCount;
765
784- (void)loadMessagesFrom:(long long)aStartTimestamp
785 to:(long long)aEndTimestamp
786 count:(int)aCount
787 completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
788
809- (EMError* _Nullable)removeMessagesStart:(NSInteger)aStartTimestamp
810 to:(NSInteger)aEndTimestamp;
811@end
Definition: EMChatMessage.h:114
Definition: EMConversation.h:114
NSDictionary * ext
Definition: EMConversation.h:168
int64_t pinnedTime
Definition: EMConversation.h:203
int messagesCount
Definition: EMConversation.h:155
BOOL isChatThread
Definition: EMConversation.h:181
EMChatMessage * latestMessage
Definition: EMConversation.h:212
EMConversationType type
Definition: EMConversation.h:137
NSArray< NSNumber * > * marks
Definition: EMConversation.h:221
NSArray< EMChatMessage * > *_Nullable pinnedMessages()
BOOL isPinned
Definition: EMConversation.h:194
int unreadMessagesCount
Definition: EMConversation.h:146
NSString * conversationId
Definition: EMConversation.h:128
EMChatMessage *_Nullable lastReceivedMessage()
Definition: EMError.h:27