HyphenateChatSDK  5.0.0
EMConversation.h
1 
15 #import <Foundation/Foundation.h>
16 
17 #import "EMMessageBody.h"
18 #import "EMCursorResult.h"
19 #import "EMSilentModeParam.h"
20 
28 typedef NS_ENUM(NSInteger, EMConversationType) {
29  EMConversationTypeChat = 0,
30  EMConversationTypeGroupChat,
31  EMConversationTypeChatRoom,
32 };
33 
45 typedef NS_ENUM(NSInteger, EMMarkType) {
46  EMMarkType0 = 0,
47  EMMarkType1 = 1,
48  EMMarkType2 = 2,
49  EMMarkType3 = 3,
50  EMMarkType4 = 4,
51  EMMarkType5 = 5,
52  EMMarkType6 = 6,
53  EMMarkType7 = 7,
54  EMMarkType8 = 8,
55  EMMarkType9 = 9,
56  EMMarkType10 = 10,
57  EMMarkType11 = 11,
58  EMMarkType12 = 12,
59  EMMarkType13 = 13,
60  EMMarkType14 = 14,
61  EMMarkType15 = 15,
62  EMMarkType16 = 16,
63  EMMarkType17 = 17,
64  EMMarkType18 = 18,
65  EMMarkType19 = 19,
66 };
67 
86 typedef NS_ENUM(NSInteger, EMMessageSearchDirection) {
87  EMMessageSearchDirectionUp = 0,
88  EMMessageSearchDirectionDown
89 };
90 
98 typedef NS_ENUM(NSInteger, EMMessageSearchScope) {
99  EMMessageSearchScopeContent = 0,
100  EMMessageSearchScopeExt,
101  EMMessageSearchScopeAll
102 };
103 
104 @class EMChatMessage;
105 @class EMError;
106 
114 @interface EMConversation : NSObject
115 -(instancetype _Nonnull ) init NS_UNAVAILABLE;
129 @property (nonatomic, copy, readonly) NSString *conversationId;
130 
138 @property (nonatomic, assign, readonly) EMConversationType type;
139 
147 @property (nonatomic, assign, readonly) int unreadMessagesCount;
148 
156 @property (nonatomic, assign, readonly) int messagesCount;
157 
169 @property (nonatomic, copy) NSDictionary *ext;
170 
182 @property (nonatomic, assign) BOOL isChatThread;
183 
195 @property (readonly) BOOL isPinned;
196 
204 @property (readonly) int64_t pinnedTime;
205 
213 @property (nonatomic, strong, readonly) EMChatMessage *latestMessage;
214 
222 @property (nonatomic, readonly) NSArray<NSNumber*>* marks;
223 
231 @property (nonatomic, readonly) EMPushRemindType disturbType;
232 
244 - (EMChatMessage * _Nullable)lastReceivedMessage;
245 
253 - (NSString* _Nullable)conversationName;
254 
261 - (NSString* _Nullable)conversationAvatar;
262 
285 - (void)insertMessage:(EMChatMessage *_Nonnull)aMessage
286  error:(EMError ** _Nullable)pError;
287 
310 - (void)appendMessage:(EMChatMessage *_Nonnull)aMessage
311  error:(EMError **_Nullable)pError;
312 
327 - (void)deleteMessageWithId:(NSString *_Nonnull)aMessageId
328  error:(EMError ** _Nullable)pError;
329 
341 - (void)deleteAllMessages:(EMError ** _Nullable)pError;
342 
343 
360 - (void)removeMessagesFromServerMessageIds:(NSArray <__kindof NSString*>*_Nonnull)messageIds completion:(void (^ _Nullable)(EMError * _Nullable aError))aCompletionBlock;
377 - (void)removeMessagesFromServerWithTimeStamp:(NSTimeInterval)beforeTimeStamp completion:(void (^ _Nullable)(EMError * _Nullable aError))aCompletionBlock;
378 
399 - (void)updateMessageChange:(EMChatMessage *_Nonnull)aMessage
400  error:(EMError ** _Nullable)pError;
408 - (NSArray<EMChatMessage*>* _Nullable)pinnedMessages;
409 
410 
411 #pragma mark - Load Messages Methods
412 
427 - (EMChatMessage * _Nullable)loadMessageWithId:(NSString * _Nonnull)aMessageId
428  error:(EMError ** _Nullable)pError;
429 
460 - (NSArray<EMChatMessage *> * _Nullable)loadMessagesStartFromId:(NSString * _Nullable)aMessageId
461  count:(int)aCount
462  searchDirection:(EMMessageSearchDirection)aDirection;
463 
490 - (void)loadMessagesStartFromId:(NSString * _Nullable)aMessageId
491  count:(int)aCount
492  searchDirection:(EMMessageSearchDirection)aDirection
493  completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
494 
523 - (NSArray<EMChatMessage *> * _Nullable)loadMessagesWithType:(EMMessageBodyType)aType
524  timestamp:(long long)aTimestamp
525  count:(int)aCount
526  fromUser:(NSString* _Nullable)aUsername
527  searchDirection:(EMMessageSearchDirection)aDirection;
528 
551 - (void)loadMessagesWithType:(EMMessageBodyType)aType
552  timestamp:(long long)aTimestamp
553  count:(int)aCount
554  fromUser:(NSString* _Nullable)aUsername
555  searchDirection:(EMMessageSearchDirection)aDirection
556  completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
579 - (void)searchMessagesWithTypes:(NSArray <NSNumber*> *_Nonnull)aTypes
580  timestamp:(long long)aTimestamp
581  count:(int)aCount
582  fromUser:(NSString* _Nullable)aUsername
583  searchDirection:(EMMessageSearchDirection)aDirection
584  completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
615 - (NSArray<EMChatMessage *> * _Nullable)loadMessagesWithKeyword:(NSString* _Nullable)aKeywords
616  timestamp:(long long)aTimestamp
617  count:(int)aCount
618  fromUser:(NSString* _Nullable)aSender
619  searchDirection:(EMMessageSearchDirection)aDirection;
620 
644 - (void)loadMessagesWithKeyword:(NSString* _Nullable)aKeywords
645  timestamp:(long long)aTimestamp
646  count:(int)aCount
647  fromUser:(NSString* _Nullable)aSender
648  searchDirection:(EMMessageSearchDirection)aDirection
649  completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
650 
682 - (void)loadMessagesWithKeyword:(NSString* _Nullable)aKeywords
683  timestamp:(long long)aTimestamp
684  count:(int)aCount
685  fromUser:(NSString* _Nullable)aSender
686  searchDirection:(EMMessageSearchDirection)aDirection
687  scope:(EMMessageSearchScope)aScope
688  completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock __deprecated_msg("Use -loadMessagesWithKeyword:timestamp:count:fromUsers:searchDirection:scope:completion: instead");
689 
690 
691 
723 - (void)loadMessagesWithKeyword:(NSString* _Nullable)aKeywords
724  timestamp:(long long)aTimestamp
725  count:(int)aCount
726  fromUsers:(NSArray<NSString*>* _Nullable)senders
727  searchDirection:(EMMessageSearchDirection)aDirection
728  scope:(EMMessageSearchScope)aScope
729  completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
730 
760 - (NSArray<EMChatMessage *> * _Nullable)loadCustomMsgWithKeyword:(NSString*)aKeywords
761  timestamp:(long long)aTimestamp
762  count:(int)aCount
763  fromUser:(NSString* _Nullable)aSender
764  searchDirection:(EMMessageSearchDirection)aDirection;
765 
789 - (void)loadCustomMsgWithKeyword:(NSString* _Nullable)aKeywords
790  timestamp:(long long)aTimestamp
791  count:(int)aCount
792  fromUser:(NSString* _Nullable)aSender
793  searchDirection:(EMMessageSearchDirection)aDirection
794  completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
795 
825 - (NSArray<EMChatMessage *> * _Nullable)loadMessagesFrom:(long long)aStartTimestamp
826  to:(long long)aEndTimestamp
827  count:(int)aCount;
828 
847 - (void)loadMessagesFrom:(long long)aStartTimestamp
848  to:(long long)aEndTimestamp
849  count:(int)aCount
850  completion:(void (^ _Nullable)(NSArray<EMChatMessage *> * _Nullable aMessages, EMError * _Nullable aError))aCompletionBlock;
851 
872 - (EMError* _Nullable)removeMessagesStart:(NSInteger)aStartTimestamp
873  to:(NSInteger)aEndTimestamp;
874 
890 - (NSInteger)getMessageCountStart:(NSInteger)aStartTimestamp
891  to:(NSInteger)aEndTimestamp;
892 @end
NSArray< EMChatMessage * > *_Nullable pinnedMessages()
EMPushRemindType disturbType
Definition: EMConversation.h:231
NSString * conversationId
Definition: EMConversation.h:129
Definition: EMConversation.h:114
Definition: EMError.h:26
NSString *_Nullable conversationName()
Definition: EMChatMessage.h:154
int unreadMessagesCount
Definition: EMConversation.h:147
EMChatMessage * latestMessage
Definition: EMConversation.h:213
EMConversationType type
Definition: EMConversation.h:138
NSArray< NSNumber * > * marks
Definition: EMConversation.h:222
NSString *_Nullable conversationAvatar()
NSDictionary * ext
Definition: EMConversation.h:169
int64_t pinnedTime
Definition: EMConversation.h:204
BOOL isPinned
Definition: EMConversation.h:195
BOOL isChatThread
Definition: EMConversation.h:182
int messagesCount
Definition: EMConversation.h:156
EMChatMessage *_Nullable lastReceivedMessage()