NIMSDK-iOS
载入中...
搜索中...
未找到
NIMMessage.h
浏览该文件的文档.
1//
2// NIMMessage.h
3// NIMLib
4//
5// Created by Netease.
6// Copyright (c) 2015年 Netease. All rights reserved.
7//
8
9#import <Foundation/Foundation.h>
10#import "NIMGlobalDefs.h"
11#import "NIMSession.h"
12#import "NIMLoginClient.h"
13#import "NIMImageObject.h"
14#import "NIMLocationObject.h"
15#import "NIMAudioObject.h"
16#import "NIMCustomObject.h"
17#import "NIMVideoObject.h"
18#import "NIMFileObject.h"
20#import "NIMTipObject.h"
21#import "NIMRobotObject.h"
22#import "NIMMessageSetting.h"
23#import "NIMMessageReceipt.h"
26#import "NIMAntiSpamOption.h"
30
31NS_ASSUME_NONNULL_BEGIN
32
34
35/**
36 * 消息送达状态枚举
37 */
38typedef NS_ENUM(NSInteger, NIMMessageDeliveryState){
39 /**
40 * 消息发送失败
41 */
43 /**
44 * 消息发送中
45 */
47 /**
48 * 消息发送成功
49 */
51};
52
53/**
54 * 消息附件下载状态
55 */
56typedef NS_ENUM(NSInteger, NIMMessageAttachmentDownloadState){
57 /**
58 * 附件需要进行下载 (有附件但并没有下载过)
59 */
61 /**
62 * 附件收取失败 (尝试下载过一次并失败)
63 */
65 /**
66 * 附件下载中
67 */
69 /**
70 * 附件下载成功/无附件
71 */
73};
74
75/**
76 * 消息处理状态
77 */
78typedef NS_ENUM(NSInteger, NIMMessageStatus) {
79 NIMMessageStatusNone = 0, //消息初始状态
81 NIMMessageStatusDeleted = 2 //已删除 (必须是 message status 最大值)
82};
83
84
85
86/**
87 * 消息结构
88 */
89@interface NIMMessage : NSObject
90
91/**
92 * 消息类型
93 */
94@property (nonatomic,assign,readonly) NIMMessageType messageType;
95
96/**
97 * 消息子类型.(默认0。设置值需要大于0)
98 */
99@property (nonatomic,assign) NSInteger messageSubType;
100
101/**
102 * 消息来源
103 */
104@property (nullable,nonatomic,copy) NSString *from;
105
106/**
107 * 消息所属会话
108 */
109@property (nullable,nonatomic,copy,readonly) NIMSession *session;
110
111/**
112 * 消息ID,唯一标识
113 */
114@property (nonatomic,copy,readonly) NSString *messageId;
115
116/**
117 * 消息服务端ID
118 */
119@property (nonatomic,copy,readonly) NSString * serverID;
120
121
122/**
123 * 消息文本
124 * @discussion 消息中除 NIMMessageTypeText 和 NIMMessageTypeTip 外,其他消息 text 字段都为 nil
125 */
126@property (nullable,nonatomic,copy) NSString *text;
127
128/**
129 * 消息附件内容
130 */
131@property (nullable,nonatomic,strong) id<NIMMessageObject> messageObject;
132
133/**
134 * 消息附件原始字符串内容
135 */
136@property (nullable, nonatomic, copy, readonly) NSString *rawAttachContent;
137
138/**
139 * 消息设置
140 * @discussion 可以通过这个字段制定当前消息的各种设置,如是否需要计入未读,是否需要多端同步等
141 */
142@property (nullable,nonatomic,strong) NIMMessageSetting *setting;
143
144/**
145 * 消息反垃圾配置
146 */
147@property (nullable,nonatomic,strong) NIMAntiSpamOption *antiSpamOption;
148
149
150/**
151 * 消息推送文案,长度限制500字,撤回消息时该字段无效
152 */
153@property (nullable,nonatomic,copy) NSString *apnsContent;
154
155/**
156 * 消息推送Payload
157 * @discussion 可以通过这个字段定义消息推送 Payload ,支持字段参考苹果技术文档,长度限制 2K,撤回消息时该字段无效
158 */
159@property (nullable,nonatomic,copy) NSDictionary *apnsPayload;
160
161/**
162 * 指定成员推送选项
163 * @discussion 通过这个选项进行一些更复杂的推送设定,目前只能在群会话中使用
164 */
165@property (nullable,nonatomic,strong) NIMMessageApnsMemberOption *apnsMemberOption;
166
167
168/**
169 * 服务器扩展
170 * @discussion 客户端可以设置这个字段,这个字段将在本地存储且发送至对端,上层需要保证 NSDictionary 可以转换为 JSON,长度限制 1K
171 */
172@property (nullable,nonatomic,copy) NSDictionary *remoteExt;
173
174/**
175 * 客户端本地扩展
176 * @discussion 客户端可以设置这个字段,这个字段只在本地存储,不会发送至对端,上层需要保证 NSDictionary 可以转换为 JSON
177 */
178@property (nullable,nonatomic,copy) NSDictionary *localExt;
179
180/**
181 * 消息拓展字段
182 * @discussion 服务器下发的消息拓展字段,并不在本地做持久化,目前只有聊天室中的消息才有该字段(NIMMessageChatroomExtension)
183 */
184@property (nullable,nonatomic,strong) id messageExt;
185
186/**
187 * 消息发送时间
188 * @discussion 本地存储消息可以通过修改时间戳来调整其在会话列表中的位置,发完服务器的消息时间戳将被服务器自动修正
189 */
190@property (nonatomic,assign) NSTimeInterval timestamp;
191
192/**
193 * 易盾反垃圾增强反作弊专属字段
194 * @discussion 透传易盾反垃圾增强反作弊专属字段
195 */
196@property (nullable,nonatomic,copy) NSDictionary *yidunAntiCheating;
197
198/**
199 * 易盾反垃圾扩展字段,限制json,长度限制1024
200 */
201@property (nullable,nonatomic,copy) NSString *yidunAntiSpamExt;
202
203/**
204 * 易盾反垃圾返回的结果字段
205 */
206@property (nullable,nonatomic,copy) NSString *yidunAntiSpamRes;
207
208/**
209 * X坐标,仅用于聊天室
210 */
211@property (nonatomic, copy) NSNumber *locationX;
212/**
213 * Y坐标,仅用于聊天室
214 */
215@property (nonatomic, copy) NSNumber *locationY;
216/**
217 * Z坐标。仅用于聊天室
218 */
219@property (nonatomic, copy) NSNumber *locationZ;
220/**
221 * 消息接受者列表,仅用于聊天室
222 */
223@property (nonatomic, copy) NSArray<NSString *> *toAccIds;
224
225/**
226 * 消息的目标标签表达式
227 */
228@property (nullable,nonatomic,copy) NSString *notifyTargetTags;
229
230/**
231 * 环境变量
232 * @discussion 环境变量,用于指向不同的抄送、第三方回调等配置
233 */
234@property (nullable,nonatomic,copy) NSString *env;
235
236/**
237 * 消息投递状态 仅针对发送的消息
238 */
239@property (nonatomic,assign,readonly) NIMMessageDeliveryState deliveryState;
240
241
242/**
243 * 消息附件下载状态 仅针对收到的消息
244 */
245@property (nonatomic,assign,readonly) NIMMessageAttachmentDownloadState attachmentDownloadState;
246
247
248/**
249 * 是否是收到的消息
250 * @discussion 由于有漫游消息的概念,所以自己发出的消息漫游下来后仍旧是"收到的消息",这个字段用于消息出错是时判断需要重发还是重收
251 */
252@property (nonatomic,assign,readonly) BOOL isReceivedMsg;
253
254/**
255 * 是否是往外发的消息
256 * @discussion 由于能对自己发消息,所以并不是所有来源是自己的消息都是往外发的消息,这个字段用于判断头像排版位置(是左还是右)。
257 */
258@property (nonatomic,assign,readonly) BOOL isOutgoingMsg;
259
260/**
261 * 消息是否被播放过
262 * @discussion 修改这个属性,后台会自动更新 db 中对应的数据。聊天室消息里,此字段无效。
263 */
264@property (nonatomic,assign) BOOL isPlayed;
265
266
267/**
268 * 消息是否标记为已删除
269 * @discussion 已删除的消息在获取本地消息列表时会被过滤掉,只有根据 messageId 获取消息的接口可能会返回已删除消息。聊天室消息里,此字段无效。
270 */
271@property (nonatomic,assign,readonly) BOOL isDeleted;
272
273
274/**
275 * 对端是否已读
276 * @discussion 只有当当前消息为 P2P 消息且 isOutgoingMsg 为 YES 时这个字段才有效,需要对端调用过发送已读回执的接口
277 */
278@property (nonatomic,assign,readonly) BOOL isRemoteRead;
279
280/**
281 * 是否已发送群回执
282 * @discussion 只针对群消息有效
283 */
284@property (nonatomic,assign,readonly) BOOL isTeamReceiptSended;
285
286/**
287 * 群已读回执信息
288 * @discussion 只有当当前消息为 Team 消息且 teamReceiptEnabled 为 YES 时才有效,需要对端调用过发送已读回执的接口
289 */
290@property (nullable,nonatomic,strong,readonly) NIMTeamMessageReceipt *teamReceiptInfo;
291
292
293
294/**
295 * 消息发送者名字
296 * @discussion 当发送者是自己时,这个值可能为空,这个值表示的是发送者当前的昵称,而不是发送消息时的昵称。聊天室消息里,此字段无效。
297 */
298@property (nullable,nonatomic,copy,readonly) NSString *senderName;
299
300
301/**
302 * 发送者客户端类型
303 */
304@property (nonatomic,assign,readonly) NIMLoginClientType senderClientType;
305
306/**
307 * 是否在黑名单中
308 * @discussion YES 为被目标拉黑;
309 */
310@property (nonatomic,assign,readonly) BOOL isBlackListed;
311
312#pragma mark - Thread Talk
313
314/**
315 * 该消息回复的目标消息的消息ID
316 * @discussion 如果未回复其他消息,则为空
317 * @discussion A为一条普通消息,B消息为对A回复的消息,则A是B的 replied 消息和 thread 消息; 同时, C为回复B的消息,则C的 replied 消息是B, C的thread消息为A
318 */
319@property (nullable,nonatomic,copy,readonly) NSString *repliedMessageId;
320
321/**
322 * 该消息回复的目标消息的服务端ID
323 * @discussion 如果未回复其他消息,则为空
324 */
325@property (nullable,nonatomic,copy,readonly) NSString *repliedMessageServerId;
326
327/**
328 * 该消息回复的目标消息的发送者
329 * @discussion 如果未回复其他消息,则为空
330 */
331@property (nullable,nonatomic,copy,readonly) NSString *repliedMessageFrom;
332
333/**
334 * 该消息回复的目标消息的接收者
335 * @discussion 如果未回复其他消息,则为空
336 */
337@property (nullable,nonatomic,copy,readonly) NSString *repliedMessageTo;
338
339/**
340 * 该消息回复的目标消息的发送时间
341 * @discussion 如果未回复其他消息则为0(单位:秒)
342 */
343@property (nonatomic,assign,readonly) NSTimeInterval repliedMessageTime;
344
345
346/**
347 * 该消息的父消息的消息ID
348 * @discussion 如果未回复其他消息,则为空
349 */
350@property (nullable,nonatomic,copy,readonly) NSString *threadMessageId;
351
352/**
353 * 该消息的父消息的服务端ID
354 * @discussion 如果未回复其他消息,则为空
355 */
356@property (nullable,nonatomic,copy,readonly) NSString *threadMessageServerId;
357
358/**
359 * 该消息回复的父消息的发送者
360 * @discussion 如果未回复其他消息,则为空
361 */
362@property (nullable,nonatomic,copy,readonly) NSString *threadMessageFrom;
363
364/**
365 * 该消息回复的目标消息的接收者
366 * @discussion 如果未回复其他消息,则为空
367 */
368@property (nullable,nonatomic,copy,readonly) NSString *threadMessageTo;
369
370/**
371 * 该消息回复的父消息的发送时间
372 * @discussion 如果未回复其他消息则为0(单位:秒)
373 */
374@property (nonatomic,assign,readonly) NSTimeInterval threadMessageTime;
375
376/**
377 * 第三方回调回来的自定义扩展字段
378 */
379@property (nonatomic,copy,readonly) NSString *callbackExt;
380
381
382/**
383 * 消息处理状态
384 */
385@property (nonatomic, assign) NIMMessageStatus status;
386
387/**
388 * 消息机器人信息
389 * @discussion 设置和获取消息的机器人相关信息
390 */
391@property (nullable, nonatomic, strong) NIMMessageRobotInfo *robotInfo;
392
393@end
394
395NS_ASSUME_NONNULL_END
NIMMessageType
Definition: NIMGlobalDefs.h:17
NIMLoginClientType
Definition: NIMLoginClient.h:17
NIMMessageStatus
Definition: NIMMessage.h:78
@ NIMMessageStatusRead
Definition: NIMMessage.h:80
@ NIMMessageStatusDeleted
Definition: NIMMessage.h:81
@ NIMMessageStatusNone
Definition: NIMMessage.h:79
NIMMessageDeliveryState
Definition: NIMMessage.h:38
@ NIMMessageDeliveryStateDeliveried
Definition: NIMMessage.h:50
@ NIMMessageDeliveryStateDelivering
Definition: NIMMessage.h:46
@ NIMMessageDeliveryStateFailed
Definition: NIMMessage.h:42
NIMMessageAttachmentDownloadState
Definition: NIMMessage.h:56
@ NIMMessageAttachmentDownloadStateDownloaded
Definition: NIMMessage.h:72
@ NIMMessageAttachmentDownloadStateNeedDownload
Definition: NIMMessage.h:60
@ NIMMessageAttachmentDownloadStateFailed
Definition: NIMMessage.h:64
@ NIMMessageAttachmentDownloadStateDownloading
Definition: NIMMessage.h:68
Definition: NIMAntiSpamOption.h:18
Definition: NIMMessageApnsMemberOption.h:18
Definition: NIMMessageChatroomExtension.h:18
Definition: NIMMessage.h:90
NSString * repliedMessageServerId
Definition: NIMMessage.h:325
NSNumber * locationY
Definition: NIMMessage.h:215
NSTimeInterval repliedMessageTime
Definition: NIMMessage.h:343
NSString * apnsContent
Definition: NIMMessage.h:153
NSDictionary * yidunAntiCheating
Definition: NIMMessage.h:196
NSString * threadMessageId
Definition: NIMMessage.h:350
BOOL isRemoteRead
Definition: NIMMessage.h:278
NSString * env
Definition: NIMMessage.h:234
NSString * yidunAntiSpamRes
Definition: NIMMessage.h:206
NSString * serverID
Definition: NIMMessage.h:119
NSString * rawAttachContent
Definition: NIMMessage.h:136
NSString * senderName
Definition: NIMMessage.h:298
NIMMessageType messageType
Definition: NIMMessage.h:94
NIMTeamMessageReceipt * teamReceiptInfo
Definition: NIMMessage.h:290
BOOL isPlayed
Definition: NIMMessage.h:264
id< NIMMessageObject > messageObject
Definition: NIMMessage.h:131
NIMLoginClientType senderClientType
Definition: NIMMessage.h:304
NSString * repliedMessageId
Definition: NIMMessage.h:319
NSString * threadMessageFrom
Definition: NIMMessage.h:362
NIMSession * session
Definition: NIMMessage.h:109
NSString * threadMessageServerId
Definition: NIMMessage.h:356
BOOL isBlackListed
Definition: NIMMessage.h:310
NIMMessageSetting * setting
Definition: NIMMessage.h:142
BOOL isTeamReceiptSended
Definition: NIMMessage.h:284
NIMAntiSpamOption * antiSpamOption
Definition: NIMMessage.h:147
NSNumber * locationZ
Definition: NIMMessage.h:219
NSString * text
Definition: NIMMessage.h:126
id messageExt
Definition: NIMMessage.h:184
NIMMessageAttachmentDownloadState attachmentDownloadState
Definition: NIMMessage.h:245
NSString * yidunAntiSpamExt
Definition: NIMMessage.h:201
BOOL isOutgoingMsg
Definition: NIMMessage.h:258
NSNumber * locationX
Definition: NIMMessage.h:211
NSString * from
Definition: NIMMessage.h:104
BOOL isReceivedMsg
Definition: NIMMessage.h:252
NSDictionary * apnsPayload
Definition: NIMMessage.h:159
NSDictionary * remoteExt
Definition: NIMMessage.h:172
NSInteger messageSubType
Definition: NIMMessage.h:99
NSString * callbackExt
Definition: NIMMessage.h:379
NIMMessageRobotInfo * robotInfo
Definition: NIMMessage.h:391
NIMMessageDeliveryState deliveryState
Definition: NIMMessage.h:239
NSString * messageId
Definition: NIMMessage.h:114
NSArray< NSString * > * toAccIds
Definition: NIMMessage.h:223
BOOL isDeleted
Definition: NIMMessage.h:271
NSString * repliedMessageFrom
Definition: NIMMessage.h:331
NSString * repliedMessageTo
Definition: NIMMessage.h:337
NSDictionary * localExt
Definition: NIMMessage.h:178
NSTimeInterval threadMessageTime
Definition: NIMMessage.h:374
NIMMessageStatus status
Definition: NIMMessage.h:385
NSTimeInterval timestamp
Definition: NIMMessage.h:190
NSString * notifyTargetTags
Definition: NIMMessage.h:228
NSString * threadMessageTo
Definition: NIMMessage.h:368
NIMMessageApnsMemberOption * apnsMemberOption
Definition: NIMMessage.h:165
Definition: NIMMessageRobotInfo.h:17
Definition: NIMMessageSetting.h:17
Definition: NIMSession.h:49
Definition: NIMTeamMessageReceipt.h:18