NIMSDK-iOS
载入中...
搜索中...
未找到
NIMTeamManagerProtocol.h
浏览该文件的文档.
1//
2// NIMTeamManagerProtocol.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 "NIMTeamDefs.h"
11#import "NIMTeam.h"
12#import "NIMTeamMember.h"
18NS_ASSUME_NONNULL_BEGIN
19
20/**
21 * 群组协议
22 */
23@protocol NIMTeamManager <NSObject>
24/**
25 * 获取所有群组
26 *
27 * @return 返回所有群组
28 */
29- (nullable NSArray<NIMTeam *> *)allMyTeams;
30
31/**
32 * 根据群组 ID 获取具体的群组信息
33 *
34 * @param teamId 群组 ID
35 *
36 * @return 群组信息
37 * @discussion 如果自己不在群里,则该接口返回 nil
38 */
39- (nullable NIMTeam *)teamById:(NSString *)teamId;
40
41
42/**
43 * 根据群组ID判断是否是我所在的群
44 *
45 * @param teamId 群组ID
46 *
47 * @return 是否在此群组
48 */
49- (BOOL)isMyTeam:(NSString *)teamId;
50
51/**
52 * 创建群组
53 *
54 * @param option 创建群选项
55 * @param users 用户Accid列表
56 * @param completion 完成后的回调
57 * @deprecated 使用createTeam:completion:
58 */
59- (void)createTeam:(NIMCreateTeamOption *)option
60 users:(NSArray<NSString *> *)users
61 completion:(nullable NIMTeamCreateHandler)completion;
62
63/**
64 * 创建群组
65 *
66 * @param option 创建群选项
67 * @param completion 完成后的回调
68 */
69- (void)createTeam:(NIMCreateTeamExOption *)option
70 completion:(nullable NIMTeamCreateHandler)completion;
71
72/**
73 * 解散群组
74 *
75 * @param teamId 群组ID
76 * @param completion 完成后的回调
77 */
78- (void)dismissTeam:(NSString *)teamId
79 completion:(nullable NIMTeamHandler)completion;
80
81/**
82 * 退出群组
83 *
84 * @param teamId 群组ID
85 * @param completion 完成后的回调
86 */
87- (void)quitTeam:(NSString *)teamId
88 completion:(nullable NIMTeamHandler)completion;
89
90/**
91 * 邀请用户入群
92 *
93 * @param users 用户ID列表
94 * @param teamId 群组ID
95 * @param postscript 邀请附言
96 * @param attach 扩展消息
97 * @param completion 完成后的回调
98 */
99- (void)addUsers:(NSArray<NSString *> *)users
100 toTeam:(NSString *)teamId
101 postscript:(nullable NSString *)postscript
102 attach:(nullable NSString *)attach
103 completion:(nullable NIMTeamMemberHandler)completion;
104
105/**
106 * 从群组内移除成员
107 *
108 * @param users 需要移除的用户ID列表
109 * @param teamId 群组ID
110 * @param completion 完成后的回调
111 */
112- (void)kickUsers:(NSArray<NSString *> *)users
113 fromTeam:(NSString *)teamId
114 completion:(nullable NIMTeamHandler)completion;
115
116/**
117 * 更新群组名称
118 *
119 * @param teamName 群组名称
120 * @param teamId 群组ID
121 * @param completion 完成后的回调
122 */
123- (void)updateTeamName:(NSString *)teamName
124 teamId:(NSString *)teamId
125 completion:(nullable NIMTeamHandler)completion;
126
127
128/**
129 * 更新群组头像
130 *
131 * @param teamAvatarUrl 群组头像Url
132 * @param teamId 群组ID
133 * @param completion 完成后的回调
134 */
135- (void)updateTeamAvatar:(NSString *)teamAvatarUrl
136 teamId:(NSString *)teamId
137 completion:(nullable NIMTeamHandler)completion;
138
139
140/**
141 * 更新群组验证方式
142 *
143 * @param joinMode 验证方式
144 * @param teamId 群组ID
145 * @param completion 完成后的回调
146 */
147- (void)updateTeamJoinMode:(NIMTeamJoinMode)joinMode
148 teamId:(NSString *)teamId
149 completion:(nullable NIMTeamHandler)completion;
150
151
152/**
153 * 更新群组邀请他人方式
154 *
155 * @param inviteMode 邀请方式
156 * @param teamId 群组ID
157 * @param completion 完成后的回调
158 */
159- (void)updateTeamInviteMode:(NIMTeamInviteMode)inviteMode
160 teamId:(NSString *)teamId
161 completion:(nullable NIMTeamHandler)completion;
162
163/**
164 * 更新群组被邀请人验证方式
165 *
166 * @param beInviteMode 邀请方式
167 * @param teamId 群组ID
168 * @param completion 完成后的回调
169 */
170- (void)updateTeamBeInviteMode:(NIMTeamBeInviteMode)beInviteMode
171 teamId:(NSString *)teamId
172 completion:(nullable NIMTeamHandler)completion;
173
174
175/**
176 * 更改群组更新信息的权限
177 *
178 * @param updateInfoMode 修改谁有权限更新群组信息
179 * @param teamId 群组ID
180 * @param completion 完成后的回调
181 */
182- (void)updateTeamUpdateInfoMode:(NIMTeamUpdateInfoMode)updateInfoMode
183 teamId:(NSString *)teamId
184 completion:(nullable NIMTeamHandler)completion;
185
186
187/**
188 * 更改群组更新自定义字段的权限
189 *
190 * @param clientCustomMode 修改谁有权限更新群组自定义字段
191 * @param teamId 群组ID
192 * @param completion 完成后的回调
193 */
194- (void)updateTeamUpdateClientCustomMode:(NIMTeamUpdateClientCustomMode)clientCustomMode
195 teamId:(NSString *)teamId
196 completion:(nullable NIMTeamHandler)completion;
197
198
199
200/**
201 * 更新群介绍
202 *
203 * @param intro 群介绍
204 * @param teamId 群组ID
205 * @param completion 完成后的回调
206 */
207- (void)updateTeamIntro:(NSString *)intro
208 teamId:(NSString *)teamId
209 completion:(nullable NIMTeamHandler)completion;
210
211
212/**
213 * 更新群公告
214 *
215 * @param announcement 群公告
216 * @param teamId 群组ID
217 * @param completion 完成后的回调
218 */
219- (void)updateTeamAnnouncement:(NSString *)announcement
220 teamId:(NSString *)teamId
221 completion:(nullable NIMTeamHandler)completion;
222
223/**
224 * 更新群自定义信息
225 *
226 * @param info 群自定义信息
227 * @param teamId 群组ID
228 * @param completion 完成后的回调
229 */
230- (void)updateTeamCustomInfo:(NSString *)info
231 teamId:(NSString *)teamId
232 completion:(nullable NIMTeamHandler)completion;
233
234
235/**
236 * 更新群信息
237 *
238 * @param values 需要更新的群信息键值对
239 * @param teamId 群组ID
240 * @param completion 完成后的回调
241 * @discussion 这个接口可以一次性修改群的多个属性,如名称,公告等,传入的数据键值对是 {@(NIMTeamUpdateTag) : NSString},无效数据将被过滤
242 */
243- (void)updateTeamInfos:(NSDictionary<NSNumber *,NSString *> *)values
244 teamId:(NSString *)teamId
245 completion:(nullable NIMTeamHandler)completion;
246
247
248
249/**
250 * 群申请
251 *
252 * @param teamId 群组ID
253 * @param message 申请消息
254 * @param completion 完成后的回调
255 */
256- (void)applyToTeam:(NSString *)teamId
257 message:(NSString *)message
258 completion:(nullable NIMTeamApplyHandler)completion;
259
260
261/**
262 * 通过群申请
263 *
264 * @param teamId 群组ID
265 * @param userId 申请的用户ID
266 * @param completion 完成后的回调
267 */
268- (void)passApplyToTeam:(NSString *)teamId
269 userId:(NSString *)userId
270 completion:(nullable NIMTeamApplyHandler)completion;
271
272/**
273 * 拒绝群申请
274 *
275 * @param teamId 群组ID
276 * @param userId 申请的用户ID
277 * @param rejectReason 拒绝理由
278 * @param completion 完成后的回调
279 */
280- (void)rejectApplyToTeam:(NSString *)teamId
281 userId:(NSString *)userId
282 rejectReason:(NSString*)rejectReason
283 completion:(nullable NIMTeamHandler)completion;
284
285
286/**
287 * 更新成员群昵称
288 *
289 * @param userId 群成员ID
290 * @param newNick 新的群成员昵称
291 * @param teamId 群组ID
292 * @param completion 完成后的回调
293 */
294- (void)updateUserNick:(NSString *)userId
295 newNick:(NSString *)newNick
296 inTeam:(NSString *)teamId
297 completion:(nullable NIMTeamHandler)completion;
298
299
300/**
301 * 更新成员群自定义属性
302 *
303 * @param newInfo 新的自定义属性
304 * @param teamId 群组ID
305 * @param completion 完成后的回调
306 */
307- (void)updateMyCustomInfo:(NSString *)newInfo
308 inTeam:(NSString *)teamId
309 completion:(nullable NIMTeamHandler)completion;
310
311/**
312 * 添加管理员
313 *
314 * @param teamId 群组ID
315 * @param users 需要添加为管理员的用户ID列表
316 * @param completion 完成后的回调
317 */
318- (void)addManagersToTeam:(NSString *)teamId
319 users:(NSArray<NSString *> *)users
320 completion:(nullable NIMTeamHandler)completion;
321
322/**
323 * 移除管理员
324 *
325 * @param teamId 群组ID
326 * @param users 需要移除管理员的用户ID列表
327 * @param completion 完成后的回调
328 */
329- (void)removeManagersFromTeam:(NSString *)teamId
330 users:(NSArray<NSString *> *)users
331 completion:(nullable NIMTeamHandler)completion;
332
333
334/**
335 * 移交群主
336 *
337 * @param teamId 群组ID
338 * @param newOwnerId 新群主ID
339 * @param isLeave 是否同时离开群组
340 * @param completion 完成后的回调
341 */
342- (void)transferManagerWithTeam:(NSString *)teamId
343 newOwnerId:(NSString *)newOwnerId
344 isLeave:(BOOL)isLeave
345 completion:(nullable NIMTeamHandler)completion;
346
347
348/**
349 * 接受入群邀请
350 *
351 * @param teamId 群组ID
352 * @param invitorId 邀请者ID
353 * @param completion 完成后的回调
354 */
355- (void)acceptInviteWithTeam:(NSString*)teamId
356 invitorId:(NSString*)invitorId
357 completion:(nullable NIMTeamHandler)completion;
358
359
360/**
361 * 拒绝入群邀请
362 *
363 * @param teamId 群组ID
364 * @param invitorId 邀请者ID
365 * @param rejectReason 拒绝原因
366 * @param completion 完成后的回调
367 */
368- (void)rejectInviteWithTeam:(NSString*)teamId
369 invitorId:(NSString*)invitorId
370 rejectReason:(NSString*)rejectReason
371 completion:(nullable NIMTeamHandler)completion;
372
373
374/**
375 * 修改群通知状态
376 *
377 * @param state 群通知状态
378 * @param teamId 群组ID
379 * @param completion 完成后的回调
380 */
381- (void)updateNotifyState:(NIMTeamNotifyState)state
382 inTeam:(NSString *)teamId
383 completion:(nullable NIMTeamHandler)completion;
384
385/**
386 * 群通知状态
387 *
388 * @param teamId 群Id
389 *
390 * @return 群通知状态
391 */
392- (NIMTeamNotifyState)notifyStateForNewMsg:(NSString *)teamId;
393
394
395/**
396 * 群成员禁言
397 *
398 * @param mute 是否禁言
399 * @param userId 用户ID
400 * @param teamId 群组ID
401 * @param completion 经验操作完成后的回调
402 * @discussion 操作成功后,云信服务器会下发禁言的群通知消息
403 */
404- (void)updateMuteState:(BOOL)mute
405 userId:(NSString *)userId
406 inTeam:(NSString *)teamId
407 completion:(nullable NIMTeamHandler)completion;
408
409/**
410 * 禁言群全体成员
411 *
412 * @param mute 是否禁言
413 * @param teamId 群组ID
414 * @param completion 经验操作完成后的回调
415 * @discussion 操作成功后,云信服务器会下发禁言的群通知消息
416 */
417- (void)updateMuteState:(BOOL)mute
418 inTeam:(NSString *)teamId
419 completion:(nullable NIMTeamHandler)completion;
420
421/**
422 * 获取群组成员
423 *
424 * @param teamId 群组ID
425 * @param completion 完成后的回调
426 * @discussion 绝大多数情况这个请求都是从本地读取缓存并同步返回,但是由于群成员信息量较大, SDK 采取的是登录后延迟拉取的策略
427 * 考虑到用户网络等问题, SDK 有可能没有及时缓存群成员信息,那么这个请求将是个带网络请求的异步操作(增量请求)。
428 * 同时这个接口会去请求本地没有缓存的群用户的资料信息,但不会触发 - (void)onUserInfoChanged: 回调。
429 */
430- (void)fetchTeamMembers:(NSString *)teamId
431 completion:(nullable NIMTeamMemberHandler)completion;
432
433
434
435/**
436 * 获取群内被禁言的成员列表
437 *
438 * @param teamId 群组ID
439 * @param completion 完成后的回调
440 * @discussion 绝大多数情况这个请求都是从本地读取缓存并同步返回,但是由于群成员信息量较大, SDK 采取的是登录后延迟拉取的策略
441 * 考虑到用户网络等问题, SDK 有可能没有及时缓存群成员信息,那么这个请求将是个带网络请求的异步操作(增量请求)。
442 * 同时这个接口会去请求本地没有缓存的群用户的资料信息,但不会触发 - (void)onUserInfoChanged: 回调。
443 */
444- (void)fetchTeamMutedMembers:(NSString *)teamId
445 completion:(nullable NIMTeamMemberHandler)completion;
446
447/**
448 * 群成员类型查询成员列表
449 *
450 * @param teamId 群组ID
451 * @param option 搜索配置
452 * @param completion 完成后的回调
453 *
454 */
455- (void)getTeamMemberList:(NSString *)teamId
456 option:(NIMTeamMemberRoleTypeSearchOption *)option
457 completion:(nullable NIMTeamMemberSearchResultHandler)completion;
458
459/**
460 * 通过网络请求获取群组成员 *
461 * @param teamId 群组ID
462 * @param completion 完成后的回调
463 * @discussion 通过网络请求获取群成员列表,不同于fetchTeamMembers:completion这个接口是个必然带网络请求的异步操作(增量请求)
464 * 同时这个接口会去请求本地没有缓存的群用户的资料信息,但不会触发 - (void)onUserInfoChanged: 回调。
465 */
466- (void)fetchTeamMembersFromServer:(NSString *)teamId
467 completion:(nullable NIMTeamMemberHandler)completion;
468
469/**
470 * 获取群成员邀请人Accid
471 * @param teamID 群组ID
472 * @param memberIDs 查询的成员ID,数目不允许大于200
473 * @param completion 完成后的回调
474 */
475- (void)fetchInviterAccids:(NSString *)teamID
476 withTargetMembers:(NSArray<NSString *> *)memberIDs
477 completion:(nullable NIMTeamFetchInviterAccidsHandler)completion;
478
479/**
480 * 获取群信息
481 *
482 * @param teamId 群组ID
483 * @param completion 完成后的回调
484 */
485- (void)fetchTeamInfo:(NSString *)teamId
486 completion:(nullable NIMTeamFetchInfoHandler)completion;
487
488
489/**
490 * 获取单个群成员信息
491 *
492 * @param userId 用户ID
493 * @param teamId 群组ID
494 * @return 返回成员信息
495 * @discussion 返回本地缓存的群成员信息,如果本地没有相应数据则返回 nil。
496 */
497- (nullable NIMTeamMember *)teamMember:(NSString *)userId
498 inTeam:(NSString *)teamId;
499
500/**
501* 查询群信息
502*
503* @param option 查询选项
504* @param completion 完成回调
505* @discussion 返回本地缓存的群成员信息,如果本地没有相应数据则返回 nil。
506*/
507- (void)searchTeamWithOption:(NIMTeamSearchOption *)option
508 completion:(NIMTeamSearchHandler)completion;
509
510/**
511 * 更新群本地信息
512 *
513 * @param teams 需要更新的群对象
514 * @discussion 这个用于修改本地群信息,不会同步到服务端
515 */
516- (BOOL)updateTInfosLocal:(NSArray<NIMTeam *> *) teams;
517
518
519/**
520 * 获取所有群信息
521 *
522 * @param timestamp 0表示全量获取群信息
523 * @param block 完成后的回调
524 * @discussion 从服务端全量拉取群信息,并做本地持久化
525 */
526- (void)fetchTeamsWithTimestamp:(NSTimeInterval)timestamp completion:(nullable NIMTeamFetchTeamsHandler)block;
527/**
528* 获取指定群ID的群信息
529*
530* @param teamIds 群ID列表,数组元素超过10个会取前10个
531* @param block 完成后的回调
532* @discussion 从服务端全量拉取群信息,不做本地持久化
533*/
534- (void)fetchTeamInfoList:(NSArray <NSString *>*)teamIds completion:(NIMTeamFetchTeamInfoListHandler)block;
535
536/**
537 * 群成员添加特别关注
538 *
539 * @param teamId 群组ID
540 * @param accoutIds 群成员id
541 * @param completion 完成后的回调
542 */
543- (void)addTeamMembersFollow:(NSString *)teamId
544 accoutIds:(NSArray <NSString*>*)accoutIds
545 completion:(nullable NIMTeamHandler)completion;
546
547
548/**
549 * 群成员移除特别关注
550 *
551 * @param teamId 群组ID
552 * @param accoutIds 群成员id
553 * @param completion 完成后的回调
554 */
555- (void)removeTeamMembersFollow:(NSString *)teamId
556 accoutIds:(NSArray <NSString*>*)accoutIds
557 completion:(nullable NIMTeamHandler)completion;
558
559/**
560 * 添加群组委托
561 *
562 * @param delegate 群组委托
563 */
564- (void)addDelegate:(id<NIMTeamManagerDelegate>)delegate;
565
566/**
567 * 移除群组委托
568 *
569 * @param delegate 群组委托
570 */
571- (void)removeDelegate:(id<NIMTeamManagerDelegate>)delegate;
572@end
573
574NS_ASSUME_NONNULL_END
NIMTeamBeInviteMode
Definition: NIMTeamDefs.h:72
void(^ NIMTeamSearchHandler)(NSError *__nullable error, NSArray< NIMTeam * > *__nullable teams)
Definition: NIMTeamDefs.h:216
void(^ NIMTeamHandler)(NSError *__nullable error)
Definition: NIMTeamDefs.h:199
NIMTeamNotifyState
Definition: NIMTeamDefs.h:160
void(^ NIMTeamFetchInfoHandler)(NSError *__nullable error, NIMTeam *__nullable team)
Definition: NIMTeamDefs.h:241
NIMTeamUpdateClientCustomMode
Definition: NIMTeamDefs.h:102
void(^ NIMTeamFetchInviterAccidsHandler)(NSError *__nullable error, NSDictionary< NSString *, NSString * > *__nullable inviters)
Definition: NIMTeamDefs.h:257
NIMTeamJoinMode
Definition: NIMTeamDefs.h:37
void(^ NIMTeamFetchTeamsHandler)(NSError *__nullable error, NSArray< NIMTeam * > *__nullable teams)
Definition: NIMTeamDefs.h:265
void(^ NIMTeamCreateHandler)(NSError *__nullable error, NSString *__nullable teamId, NSArray< NSString * > *__nullable failedUserIds)
Definition: NIMTeamDefs.h:208
NIMTeamInviteMode
Definition: NIMTeamDefs.h:55
void(^ NIMTeamMemberSearchResultHandler)(NSError *__nullable error, NIMTeamMemberSearchResult *__nullable result)
Definition: NIMTeamDefs.h:233
void(^ NIMTeamApplyHandler)(NSError *__nullable error, NIMTeamApplyStatus applyStatus)
Definition: NIMTeamDefs.h:249
NIMTeamUpdateInfoMode
Definition: NIMTeamDefs.h:87
void(^ NIMTeamFetchTeamInfoListHandler)(NSError *__nullable error, NSArray< NIMTeam * > *__nullable teams, NSArray< NSString * > *__nullable failedTeamIds)
Definition: NIMTeamDefs.h:273
void(^ NIMTeamMemberHandler)(NSError *__nullable error, NSArray< NIMTeamMember * > *__nullable members)
Definition: NIMTeamDefs.h:224
Definition: NIMCreateTeamExOption.h:16
Definition: NIMCreateTeamOption.h:18
Definition: NIMTeam.h:19
Definition: NIMTeamMember.h:17
Definition: NIMTeamMemberSearchOption.h:30
Definition: NIMTeamSearchOption.h:29