TIMFriendshipDefine.h
13.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
//
// TIMFriendshipDefine.h
// imsdk
//
// Created by annidyfeng on 2019/3/7.
// Copyright © 2019年 Tencent. All rights reserved.
//
#ifndef TIMFriendshipDefine_h
#define TIMFriendshipDefine_h
#import "ImSDK.h"
@class TIMFriendMetaInfo;
@class TIMFriendPendencyResponse;
@class TIMFriendPendencyItem;
@class TIMFriendFutureMeta;
@class TIMFriendGroup;
#pragma mark - 枚举类型
/**
* 好友操作状态
*
* 详细错误码参见 https://cloud.tencent.com/document/product/269/1671#.E5.85.B3.E7.B3.BB.E9.93.BE.E9.94.99.E8.AF.AF.E7.A0.81
*/
typedef NS_ENUM(NSInteger, TIMFriendStatus) {
/**
* 操作成功
*/
TIM_FRIEND_STATUS_SUCC = 0,
/**
* 请求参数错误,请根据错误描述检查请求是否正确
*/
TIM_FRIEND_PARAM_INVALID = 30001,
/**
* 请求参数错误,SdkAppid 不匹配。
*/
TIM_FRIEND_SDK_APPID_INVALID = 30002,
/**
* 请求的用户帐号不存在
*/
TIM_FRIEND_ID_INVALID = 30003,
/**
* 请求需要 App 管理员权限
*/
TIM_FRIEND_NEED_ADMIN_PERMISSON = 30004,
/**
* 关系链字段中包含敏感词
*/
TIM_FRIEND_DIRTY_WORD = 30005,
/**
* 服务器内部错误,请重试
*/
TIM_FRIEND_SERVER_ERROR = 30006,
/**
* 网络超时,请稍后重试
*/
TIM_FRIEND_TIMEOUT = 30007,
/**
* 并发写导致写冲突,建议使用批量方式
*/
TIM_FRIEND_WRITE_ERROR = 30008,
/**
* 后台禁止该用户发起加好友请求
*/
TIM_ADD_FRIEND_FORBIDEN = 30009,
/**
* 自己的好友数已达系统上限
*/
TIM_ADD_FRIEND_STATUS_SELF_FRIEND_FULL = 30010,
/**
* 分组已达系统上限
*/
TIM_UPDATE_FRIEND_GROUP_STATUS_MAX_GROUPS_EXCEED = 30011,
/**
* 未决数已达系统上限。
*/
TIM_PENDENCY_STATUS_FULL = 30012,
/**
* 黑名单数已达系统上限
*/
TIM_ADD_BLACKLIST_STATUS_FULL = 30013,
/**
* 对方的好友数已达系统上限
*/
TIM_ADD_FRIEND_STATUS_THEIR_FRIEND_FULL = 30014,
/**
* 被加好友在自己的黑名单中
*/
TIM_ADD_FRIEND_STATUS_IN_SELF_BLACK_LIST = 30515,
/**
* 被加好友设置为禁止加好友
*/
TIM_ADD_FRIEND_STATUS_FRIEND_SIDE_FORBID_ADD = 30516,
/**
* 已被被添加好友设置为黑名单
*/
TIM_ADD_FRIEND_STATUS_IN_OTHER_SIDE_BLACK_LIST = 30525,
/**
* 等待好友审核同意
*/
TIM_ADD_FRIEND_STATUS_PENDING = 30539,
/**
* 添加好友请求被安全策略打击,请勿频繁发起添加好友请求
*/
TIM_ADD_FRIEND_STATUS_SENSITIVE = 30540,
/**
* 对方没有申请过好友
*/
TIM_RESPONSE_FRIEND_STATUS_NO_REQ = 30614,
/**
* 删除好友请求被安全策略打击,请勿频繁发起删除好友请求
*/
TIM_DELETE_FRIEND_STATUS_SENSITIVE = 31707,
};
typedef NS_ENUM(NSInteger, TIMDelFriendType) {
/**
* 删除单向好友
*/
TIM_FRIEND_DEL_SINGLE = 1,
/**
* 删除双向好友
*/
TIM_FRIEND_DEL_BOTH = 2,
};
typedef NS_ENUM(NSInteger, TIMPendencyType) {
/**
* 别人发给我的
*/
TIM_PENDENCY_COME_IN = 1,
/**
* 我发给别人的
*/
TIM_PENDENCY_SEND_OUT = 2,
/**
* 别人发给我的 和 我发给别人的。仅拉取时有效
*/
TIM_PENDENCY_BOTH = 3,
};
/**
* 推荐好友类型
*/
typedef NS_ENUM(NSInteger, TIMFutureFriendType) {
/**
* 收到的未决请求
*/
TIM_FUTURE_FRIEND_PENDENCY_IN_TYPE = 0x1,
/**
* 发出去的未决请求
*/
TIM_FUTURE_FRIEND_PENDENCY_OUT_TYPE = 0x2,
/**
* 推荐好友
*/
TIM_FUTURE_FRIEND_RECOMMEND_TYPE = 0x4,
/**
* 已决好友
*/
TIM_FUTURE_FRIEND_DECIDE_TYPE = 0x8,
};
/**
* 翻页选项
*/
typedef NS_ENUM(NSInteger, TIMPageDirectionType) {
/**
* 向上翻页
*/
TIM_PAGE_DIRECTION_UP_TYPE = 1,
/**
* 向下翻页
*/
TIM_PAGE_DIRECTION_DOWN_TYPE = 2,
};
/**
* 好友检查类型
*/
typedef NS_ENUM(NSInteger,TIMFriendCheckType) {
/**
* 单向好友
*/
TIM_FRIEND_CHECK_TYPE_UNIDIRECTION = 0x1,
/**
* 互为好友
*/
TIM_FRIEND_CHECK_TYPE_BIDIRECTION = 0x2,
};
/**
* 好友关系类型
*/
typedef NS_ENUM(NSInteger,TIMFriendRelationType) {
/**
* 不是好友
*/
TIM_FRIEND_RELATION_TYPE_NONE = 0x0,
/**
* 对方在我的好友列表中
*/
TIM_FRIEND_RELATION_TYPE_MY_UNI = 0x1,
/**
* 我在对方的好友列表中
*/
TIM_FRIEND_RELATION_TYPE_OTHER_UNI = 0x2,
/**
* 互为好友
*/
TIM_FRIEND_RELATION_TYPE_BOTHWAY = 0x3,
};
typedef NS_ENUM(NSInteger, TIMFriendResponseType) {
/**
* 同意加好友(建立单向好友)
*/
TIM_FRIEND_RESPONSE_AGREE = 0,
/**
* 同意加好友并加对方为好友(建立双向好友)
*/
TIM_FRIEND_RESPONSE_AGREE_AND_ADD = 1,
/**
* 拒绝对方好友请求
*/
TIM_FRIEND_RESPONSE_REJECT = 2,
};
#pragma mark - block回调
/**
* 获取好友列表回调
*
* @param meta 好友元信息
* @param friends 好友列表 TIMUserProfile* 数组,只包含需要的字段
*/
typedef void (^TIMGetFriendListByPageSucc)(TIMFriendMetaInfo * meta, NSArray * friends);
/**
* 获取未决请求列表成功
*
* @param pendencyResponse 未决请求元信息
*/
typedef void (^TIMGetFriendPendencyListSucc)(TIMFriendPendencyResponse *pendencyResponse);
/**
* 群搜索回调
*
* @param totalNum 搜索结果的总数
* @param users 请求的用户列表片段
*/
typedef void (^TIMUserSearchSucc)(uint64_t totalNum, NSArray * users);
/**
* 好友分组列表
*
* @param groups 好友分组(TIMFriendGroup*)列表
*/
typedef void (^TIMFriendGroupArraySucc)(NSArray<TIMFriendGroup *> * groups);
/**
* 好友关系检查回调
*
* @param results TIMCheckFriendResult列表
*/
typedef void (^TIMFriendCheckSucc)(NSArray* results);
#pragma mark - 基本类型
/**
* 加好友请求
*/
@interface TIMFriendRequest : TIMCodingModel
/**
* 用户identifier(必填)
*/
@property (nonatomic,strong) NSString* identifier;
/**
* 备注(备注最大96字节)
*/
@property (nonatomic,strong) NSString* remark;
/**
* 请求说明(最大120字节)
*/
@property (nonatomic,strong) NSString* addWording;
/**
* 添加来源
* 来源需要添加“AddSource_Type_”前缀
*/
@property (nonatomic,strong) NSString* addSource;
/**
* 分组
*/
@property (nonatomic,strong) NSString* group;
@end
/**
* 未决请求
*/
@interface TIMFriendPendencyItem : TIMCodingModel
/**
* 用户标识
*/
@property(nonatomic,strong) NSString* identifier;
/**
* 增加时间
*/
@property(nonatomic,assign) uint64_t addTime;
/**
* 来源
*/
@property(nonatomic,strong) NSString* addSource;
/**
* 加好友附言
*/
@property(nonatomic,strong) NSString* addWording;
/**
* 加好友昵称
*/
@property(nonatomic,strong) NSString* nickname;
/**
* 未决请求类型
*/
@property(nonatomic,assign) TIMPendencyType type;
@end
/**
* 未决推送
*/
@interface TIMFriendPendencyInfo : TIMCodingModel
/**
* 用户标识
*/
@property(nonatomic,strong) NSString* identifier;
/**
* 来源
*/
@property(nonatomic,strong) NSString* addSource;
/**
* 加好友附言
*/
@property(nonatomic,strong) NSString* addWording;
/**
* 加好友昵称
*/
@property(nonatomic,strong) NSString* nickname;
@end
/**
* 未决请求信息
*/
@interface TIMFriendPendencyRequest : TIMCodingModel
/**
* 序列号,未决列表序列号
* 建议客户端保存seq和未决列表,请求时填入server返回的seq
* 如果seq是server最新的,则不返回数据
*/
@property(nonatomic,assign) uint64_t seq;
/**
* 翻页时间戳,只用来翻页,server返回0时表示没有更多数据,第一次请求填0
* 特别注意的是,如果server返回的seq跟填入的seq不同,翻页过程中,需要使用客户端原始seq请求,直到数据请求完毕,才能更新本地seq
*/
@property(nonatomic,assign) uint64_t timestamp;
/**
* 每页的数量,即本次请求最多返回都个数据
*/
@property(nonatomic,assign) uint64_t numPerPage;
/**
* 未决请求拉取类型
*/
@property(nonatomic,assign) TIMPendencyType type;
@end
/**
* 未决返回信息
*/
@interface TIMFriendPendencyResponse : TIMCodingModel
/**
* 本次请求的未决列表序列号
*/
@property(nonatomic,assign) uint64_t seq;
/**
* 本次请求的翻页时间戳
*/
@property(nonatomic,assign) uint64_t timestamp;
/**
* 未决请求未读数量
*/
@property(nonatomic,assign) uint64_t unreadCnt;
/**
* 未决数据
*/
@property NSArray<TIMFriendPendencyItem *> * pendencies;
@end
/**
* 好友元信息
*/
@interface TIMFriendMetaInfo : TIMCodingModel
/**
* 时间戳,需要保存,下次拉取时传入,增量更新使用
*/
@property(nonatomic,assign) uint64_t timestamp;
/**
* 序列号,需要保存,下次拉取时传入,增量更新使用
*/
@property(nonatomic,assign) uint64_t infoSeq;
/**
* 分页信息,无需保存,返回为0时结束,非0时传入再次拉取,第一次拉取时传0
*/
@property(nonatomic,assign) uint64_t nextSeq;
/**
* 覆盖:为TRUE时需要重设timestamp, infoSeq, nextSeq为0,清除客户端存储,重新拉取资料
*/
@property(nonatomic,assign) BOOL recover;
@end
/**
* 好友分组信息
*/
@interface TIMFriendGroup : TIMCodingModel
/**
* 好友分组名称
*/
@property(nonatomic,strong) NSString* name;
/**
* 分组成员数量
*/
@property(nonatomic,assign) uint64_t userCnt;
/**
* 分组成员identifier列表
*/
@property(nonatomic,strong) NSArray* friends;
@end
/**
* 好友关系检查
*/
@interface TIMFriendCheckInfo : NSObject
/**
* 检查用户的id列表(NSString*)
*/
@property(nonatomic,strong) NSArray* users;
/**
* 检查类型
*/
@property(nonatomic,assign) TIMFriendCheckType checkType;
@end
@interface TIMCheckFriendResult : NSObject
/**
* 用户id
*/
@property NSString* identifier;
/**
* 返回码
*/
@property NSInteger result_code;
/**
* 返回信息
*/
@property NSString *result_info;
/**
* 检查结果
*/
@property(nonatomic,assign) TIMFriendRelationType resultType;
@end
@interface TIMFriendResult : NSObject
/**
* 用户Id
*/
@property NSString* identifier;
/**
* 返回码
*/
@property NSInteger result_code;
/**
* 返回信息
*/
@property NSString *result_info;
@end
/**
* 响应好友请求
*/
@interface TIMFriendResponse : NSObject
/**
* 响应类型
*/
@property(nonatomic,assign) TIMFriendResponseType responseType;
/**
* 用户identifier
*/
@property(nonatomic,strong) NSString* identifier;
/**
* 备注好友(可选,如果要加对方为好友)。备注最大96字节
*/
@property(nonatomic,strong) NSString* remark;
@end
/**
* 好友分组信息扩展
*/
@interface TIMFriendGroupWithProfiles : TIMFriendGroup
/**
* 好友资料(TIMUserProfile*)列表
*/
@property(nonatomic,strong) NSArray* profiles;
@end
// 用户资料KEY
/**
* 昵称
* 值类型: NSString
*/
extern NSString *const TIMProfileTypeKey_Nick;
/**
* 头像
* 值类型: NSString
*/
extern NSString *const TIMProfileTypeKey_FaceUrl;
/**
* 好友申请
* 值类型: NSNumber [TIM_FRIEND_ALLOW_ANY,TIM_FRIEND_NEED_CONFIRM,TIM_FRIEND_DENY_ANY]
*/
extern NSString *const TIMProfileTypeKey_AllowType;
/**
* 性别
* 值类型: NSNumber [TIM_GENDER_UNKNOWN,TIM_GENDER_MALE,TIM_GENDER_FEMALE]
*/
extern NSString *const TIMProfileTypeKey_Gender;
/**
* 生日
* 值类型: NSNumber
*/
extern NSString *const TIMProfileTypeKey_Birthday;
/**
* 位置
* 值类型: NSString
*/
extern NSString *const TIMProfileTypeKey_Location;
/**
* 语言
* 值类型: NSNumber
*/
extern NSString *const TIMProfileTypeKey_Language;
/**
* 等级
* 值类型: NSNumber
*/
extern NSString *const TIMProfileTypeKey_Level;
/**
* 角色
* 值类型: NSNumber
*/
extern NSString *const TIMProfileTypeKey_Role;
/**
* 签名
* 值类型: NSString
*/
extern NSString *const TIMProfileTypeKey_SelfSignature;
/**
* 自定义字段前缀
* 值类型: [NSString,NSData|NSNumber]
* @note 当设置自定义字的值NSString对象时,后台会将其转为UTF8保存在数据库中。由于部分用户迁移资料时可能不是UTF8类型,所以在获取资料时,统一返回NSData类型。
*/
extern NSString *const TIMProfileTypeKey_Custom_Prefix;
// 好友资料KEY
/**
* 备注
* 值类型: NSString
*/
extern NSString *const TIMFriendTypeKey_Remark;
/**
* 分组
* 值类型: [NSArray]
*/
extern NSString *const TIMFriendTypeKey_Group;
/**
* 自定义字段前缀
* 值类型: [NSString,NSData|NSNumber]
*/
extern NSString *const TIMFriendTypeKey_Custom_Prefix;
#endif /* TIMFriendshipDefine_h */