Team Features
Update time: 2024/08/20 15:45:46
Overview
The team features correspond to the management category of NIMTeamManager
. NIMTeamManager
provides the team chat features: the ordinary team and the advanced team. The advanced team has more operation permissions, and The APIs are kept consistent under common operations. We recommend to select one team type only for APP development. In principle, the ordinary team and the advanced team can not be interchanged, since their types have been confirmed at creation. Following the version SDK 2.4.0
, the advanced team can perform all the features of the ordinary team. we recommend using the advanced team for development.
- ordinary team
Similar to a discussion team or quick group session in the current IM chat application, an ordinary team does not have full team privileges. Each ordinary team can only have one administrator. The administrator can add members to and remove members from a team. Members can add members without the consent of the team members.
- Advanced team
The The advanced team is subject to more limitations on permission which is granted to the owner, administrator, and team members.
- NIMTeam prototype:
objc@interface NIMTeam : NSObject
/**
* Team ID
*/
@property (nullable,nonatomic,copy,readonly) NSString *teamId;
/**
* Team name
*/
@property (nullable,nonatomic,copy) NSString *teamName;
/**
* Team avatar
*/
@property (nullable,nonatomic,copy) NSString *avatarUrl;
/**
* Thumbnails of profile picturesin a team
* @discussion - Only apply to use CommsEase upload server for uploading resources. Otherwise, it is invalid.
*/
@property (nullable,nonatomic,copy) NSString *thumbAvatarUrl;
/**
* Team type
*/
@property (nonatomic,assign,readonly) NIMTeamType type;
/**
* Team owner ID
* @discussion - The owner of an ordinary team is the creator, but information can be transferred to an advanced team.
*/
@property (nullable,nonatomic,copy,readonly) NSString *owner;
/**
* Team introduction
*/
@property (nullable,nonatomic,copy) NSString *intro;
/**
* Team announcement
*/
@property (nullable,nonatomic,copy) NSString *announcement;
/**
* The number of team members
* @discussion - This is the data of team members, which is synchronized after the last login and will not have real-time changes. If necessary, fetchTeamInfo:completion: can be invoked to refresh.
*/
@property (nonatomic,assign,readonly) NSInteger memberNumber;
/**
* Team level
* @discussion - The maximum number of team members now.
*/
@property (nonatomic,assign,readonly) NSInteger level;
/**
* Creation time of team
*/
@property (nonatomic,assign,readonly) NSTimeInterval createTime;
/**
* Verification mode of team
* @discussion - It is only valid for the advanced team.
*/
@property (nonatomic,assign) NIMTeamJoinMode joinMode;
/**
* Permission for team invitation
* @discussion - It is only valid for advanced teams and SuperTeam.
*/
@property (nonatomic,assign) NIMTeamInviteMode inviteMode;
/**
* Mode of being invited
* @discussion - It is only valid for advanced teams and SuperTeam.
*/
@property (nonatomic,assign) NIMTeamBeInviteMode beInviteMode;
/**
* Permission for updating team profile
* @discussion - It is only valid for the advanced team.
*/
@property (nonatomic,assign) NIMTeamUpdateInfoMode updateInfoMode;
/**
* Permission for updating team-client custom field
* @discussion - It is only valid for the advanced team.
*/
@property (nonatomic,assign) NIMTeamUpdateClientCustomMode updateClientCustomMode;
/**
* Custom information at team server
* @discussion - The app party can independently extend the field for individual configuration. The field cannot be updated on the client.
*/
@property (nullable,nonatomic,copy,readonly) NSString *serverCustomInfo;
/**
* Custom information at team client
* @discussion - The app party can independently extend the field for individual configuration. The field can be updated on the client.
*/
@property (nullable,nonatomic,copy,readonly) NSString *clientCustomInfo;
/**
* Status of team message tip
* @discussion - This configuration will influence the APNS of team message.
*/
@property (nonatomic,assign,readonly) NIMTeamNotifyState notifyStateForNewMsg;
/**
* It determines that all team members are muted.
* @discussion - It is only valid for advanced teams and SuperTeam.
*/
- (BOOL)inAllMuteMode;
@end
Create a superteam
objc@protocol NIMTeamManager <NSObject>
/**
* Create a team
*
* @param option - Options for creating a team
* @param users - List of user IDs
* @param completion - Callback that is returned after completion
*/
- (void)createTeam:(NIMCreateTeamOption *)option
users:(NSArray<NSString *> *)users
completion:(nullable NIMTeamCreateHandler)completion
@end
The option provides the following parameter information
Parameter | Type | Description |
---|---|---|
name | NSString | Team name |
type | NIMTeamType | Team type |
intro | NSString | Team introduction |
announcement | NSString | Team announcement |
clientCustomInfo | NSString | Client custom information |
postscript | NSString | Postscript for inviting others (valid for advanced teams); no postscript is required for ordinary teams |
joinMode | NIMTeamJoinMode | Team join mode. Valid for advanced teams, NIMTeamJoinModeNoAuth in default |
inviteMode | NIMTeamInviteMode | Invitation authority, valid for advanced teams, NIMTeamInviteModeManager in default |
beInviteMode | NIMTeamBeInviteMode | Invited mode, valid for advanced teams, NIMTeamBeInviteModeNeedAuth in default |
updateInfoMode | NIMTeamUpdateInfoMode | Authority to update team profile, valid for advanced teams, NIMTeamUpdateInfoModeManager in default |
updateClientCustomMode | NIMTeamUpdateClientCustomMode | Authority to update client custom field. Valid for advanced teams, NIMTeamUpdateClientCustomModeManager in default |
Get team
Since NIM SDK will synchronize local team messages at the startup, a team may be fetched by calling the local cache API. SDK provides massive team APIs required to fetch it and The APIs required for inquiry based on a team ID. SDK also provides The APIs for remote access to team messages.
Get All Teams Locally
Prototype
objc@protocol NIMTeamManager <NSObject>
/**
* Get all teams
*
* @return - Return all teams
*/
- (nullable NSArray<NIMTeam *> *)allMyTeams;
@end
Get a specified team locally
objc@protocol NIMTeamManager <NSObject>
/**
* Get detailed team profile by team ID
*
* @param teamId - Team ID
*
* @return - Team information
*/
- (nullable NIMTeam *)teamById:(NSString *)teamId;
@end
Get a specified team from the cloud
objc@protocol NIMTeamManager <NSObject>
/**
* Get team profile
*
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)fetchTeamInfo:(NSString *)teamId
completion:(nullable NIMTeamGetInfoHandler)completion;
@end
Parameter List
Parameter | Type | Description |
---|---|---|
teamId | NSString | Team ID |
completion | NIMTeamGetInfoHandler | Request for completion of callback |
If one's team is fetched, the team data cached locally will be updated.
Dismiss a team
objc@protocol NIMTeamManager <NSObject>
/**
* Dismiss a team
*
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)dismissTeam:(NSString*)teamId
completion:(NIMTeamHandler)block
@end
Parameter List
Parameter | Type | Description |
---|---|---|
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
After the team is dismissed, all users' sessions in the team will be retained, but the users cannot send or receive messages in the team.
Manage team members
Joining operation
Apply for joining
Voluntary application for joining a team (limited to advanced team)
objc@protocol NIMTeamManager <NSObject>
/**
* Team application
*
* @param teamId - Team ID
* @param message - Apply for message
* @param completion - Callback that is returned after completion
*/
- (void)applyToTeam:(NSString *)teamId
message:(NSString *)message
completion:(NIMTeamApplyHandler)block
@end
Parameter List
Parameter | Type | Description |
---|---|---|
teamId | NSString | Team ID |
message | NSString | Application message |
completion | NIMTeamApplyHandler | Callback after completion |
After the request, CommsEase server will issue a system message NIMSystemNotification
(type: NIMSystemNotificationTypeTeamApply
) to the team administrator.
The administrator may approve or reject the application.
Verify team application
Approve application (limited to advanced team)
objc@protocol NIMTeamManager <NSObject>
/**
* Approve team application
*
* @param teamId - Team ID
* @param userId - Applied user ID
* @param completion - Callback that is returned after completion
*/
- (void)passApplyToTeam:(NSString *)teamId
userId:(NSString *)userId
completion:(NIMTeamApplyHandler)block
@end
Parameter List
Parameter | Type | Description |
---|---|---|
teamId | NSString | Team ID |
userId | NSString | User ID |
completion | NIMTeamApplyHandler | Callback after completion |
After the application is approved, the new member will automatically join the team, and a notification message will be generated in the team
Reject application (limited to advanced team)
objc@protocol NIMTeamManager <NSObject>
/**
* Reject a team application
*
* @param teamId - Team ID
* @param userId - Applied user ID
* @param rejectReason - Reason for rejection
* @param completion - Callback that is returned after completion
*/
- (void)rejectApplyToTeam:(NSString *)teamId
userId:(NSString *)userId
rejectReason:(NSString *)rejectReason
completion:(NIMTeamHandler)block
@end
After the request, CommsEase server will issue a system message NIMSystemNotification
(type: NIMSystemNotificationTypeTeamIviteReject
) to the applicant.
Invite to join a team
objc@protocol NIMTeamManager <NSObject>
/**
* Invite users to a team
*
* @param users - List of user IDs
* @param teamId - Team ID
* @param postscript - Postscript for invitation
* @param attach - Extension message
* @param completion - Callback that is returned after completion
*/
- (void)addUsers:(NSArray<NSString *> *)users
toTeam:(NSString *)teamId
postscript:(NSString *)postscript
attach:(NSString *)attach
completion:(nullable NIMTeamMemberHandler)completion;
@end
Parameter List
Parameter | Type | Description |
---|---|---|
users | NSArray<NSString *> | List of user ID |
teamId | NSString | Team ID |
postscript | NSString | Invitation P.S. |
attach | NSString | Extend messages |
completion | NIMTeamMemberHandler | Callback after completion |
After the request, the invitee of an ordinary team will join the team; for an advanced team, CommsEase server will issue a system message to the target user who may approve or reject the request.
Verify the application for joining
After being invited to the team, the user will receive a NIMSystemNotification
, with the type type
of NIMSystemNotificationTypeTeamInvite
. The following information may be fetched in the notification
Parameter List
Parameter | Type | Description |
---|---|---|
sourceID | NSString | Invitee ID |
targetID | NSString | Target team ID |
postscript | NSString | Invitation P.S. |
Approve invitation (limited to advanced team)
objc@protocol NIMTeamManager <NSObject>
/**
* Accept team invitation
*
* @param teamId - Team ID
* @param inviterId - Inviter ID
* @param completion - Callback that is returned after completion
*/
- (void)acceptInviteWithTeam:(NSString*)teamId
inviterId:(NSString*)inviterId
completion:(NIMTeamHandler)completion
@end
Parameter List
Parameter | Type | Description |
---|---|---|
teamId | NSString | Team ID |
inviterId | NSString | Invitor ID |
completion | NIMTeamHandler | Callback after completion |
After the invitation is accepted, the new member will automatically join the team, and a notification message will be generated in the team
Example of team notification message analysis process
objc //NIMMessage can be returned with the callback, with variable name "message".
NIMNotificationObject *object = message.messageObject;
if (message.messageType == NIMMessageTypeNotification && object.notificationType == NIMNotificationTypeTeam)
{
//Resolution for team notification message
NIMTeamNotificationContent *content = (NIMTeamNotificationContent*)object.content;
//Service for detailed content "NIMTeamNotificationContent" of team notification
...
}
Reject invitation (limited to advanced team)
objc/**
* Reject team invitation
*
* @param teamId - Team ID
* @param inviterId - Inviter ID
* @param rejectReason - Reason for rejection
* @param completion - Callback that is returned after completion
*/
- (void)rejectInviteWithTeam:(NSString*)teamId
inviterId:(NSString*)inviterId
rejectReason:(NSString*)rejectReason
completion:(NIMTeamHandler)completion
Parameter List
Parameter | Type | Description |
---|---|---|
teamId | NSString | Team ID |
inviterId | NSString | Invitor ID |
rejectReason | NSString | Reject reason |
completion | NIMTeamHandler | Callback after completion |
After rejecting the invitation, the inviter will receive a system notification NIMSystemNotification
(type: NIMSystemNotificationTypeTeamApplyReject
).
Search inviter
objc/**
* Get Accid of member inviter
* @param teamId - Team ID
* @param memberIDs - Queried member ID. The number of members shall not exceed 200.
* @param completion - Callback that is returned after completion
*/
- (void)fetchInviterAccids:(NSString *)teamID
withTargetMembers:(NSArray<NSString *> *)memberIDs
completion:(nullable NIMTeamGetInviterAccidsHandler)completion;
Parameter List
Parameter | Type | Description |
---|---|---|
teamId | NSString | Team ID |
memberIDs | NSArray | Team member ID searched |
completion | NIMTeamGetInviterAccidsHandler | Callback after completion |
Kick out team member
objc@protocol NIMTeamManager <NSObject>
/**
* Remove members from a team
*
* @param users - List of user IDs to be removed
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)kickUsers:(NSArray<NSString *> *)users
fromTeam:(NSString *)teamId
completion:(NIMTeamHandler)completion
@end
Session information of users kicked out of the team will be retained, but such users will longer receive any message concerning the team.
Parameter List
Parameter | Type | Description |
---|---|---|
users | NSArray<NSString *> | List of user ID to be removed |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Leave a team
objc@protocol NIMTeamManager <NSObject>
/**
* Leave a team
*
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)quitTeam:(NSString *)teamId
completion:(NIMTeamHandler)completion
@end
Parameter List
Parameter | Type | Description |
---|---|---|
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Upon the successful withdrawal of a user from the team, related session information will be retained, but no message concerning the team will be received any longer.
Get team members
Differing from user data, team member information is mainly associated with a team. In relation to a user, there is the difference among different teams in his/her information as a team member. Team member information includes nickname, joining time and team member type.
Prototype
objc@interface NIMTeamMember : NSObject
/**
* Team ID
*/
@property (nullable,nonatomic,copy,readonly) NSString *teamId;
/**
* Team member ID
*/
@property (nullable,nonatomic,copy,readonly) NSString *userId;
/**
* Inviter ID
* @dicusssion - The field is valid only when you are a member. It is not allowed to view the inviter of other team members
*/
@property (nullable,nonatomic,copy,readonly) NSString *inviter;
/**
* Group member types
*/
@property (nonatomic,assign) NIMTeamMemberType type;
/**
* Team nickname
*/
@property (nullable,nonatomic,copy) NSString *nickname;
/**
* Be muted
*/
@property (nonatomic,assign,readonly) BOOL isMuted;
/**
*Time of joining in a team
*/
@property (nonatomic,assign,readonly) NSTimeInterval createTime;
/**
* Team custom information of a new member
*/
@property (nullable,nonatomic,copy) NSString *customInfo;
@end
Property List
Parameter | Type | Description |
---|---|---|
teamId | NSString | Team ID |
userId | NSString | Team member ID |
inviter | NSString | Invitor ID, valid only when the inviter is the member. It is not allowed to view the inviter of other team members |
type | NIMTeamMemberType | Team member type |
nickname | NSString | Team nickname |
isMuted | BOOL | : It determines whether a user is muted |
createTime | NSTimeInterval | Joining time |
customInfo | NSString | New member custom information |
For team members, SDK makes no warranties that there is local data, and team members will be synchronized at each login. SDK will cache data locally for the team members who have been synchronized or fetched actively and remotely.
Get the list of team members
objc@protocol NIMTeamManager <NSObject>
/**
* Get team members
*
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)fetchTeamMembers:(NSString *)teamId
completion:(NIMTeamMemberHandler)completion
@end
Parameter List
Parameter | Type | Description |
---|---|---|
teamId | NSString | Team ID |
completion | NIMTeamMemberHandler | Callback after completion |
In most cases, the request is read and cached locally, synchronized, and returned. However, due to a large amount of team member information, SDK delays the pull after login. Since SDK is probably unable to timely cache team member information due to user network and other issues, the request will be an asynchronous operation with network request (increment request). The API will request team user profile that has not been cached locally, without triggering - (void)onUserInfoChanged: Callback.
Only the data concerning the team under trusteeship of CommsEase server is fetched. Developers should display such data with The API in combination with the self-managed user data.
The list of team members from the cloud may be fetched with the following API:
objc@protocol NIMTeamManager <NSObject>
/**
Get team members with a network request
*
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)fetchTeamMembersFromServer:(NSString *)teamId
completion:(nullable NIMTeamMemberHandler)completion
@end
The list of team members is fetched using network requests. Different from fetchTeamMembers: completion, The API undoubtedly involves the asynchronous operations with network request (increment request), while requesting team user profile that has not been cached locally, without triggering - (void)onUserInfoChanged: Callback.
Get a specified team member
SDK supports the acquisition of a specified team member object:
objc@protocol NIMTeamManager <NSObject>
/**
* Get information from a single team member. The information of team members cached in the local database is returned. If there is not related data in a local database, nil will be returned.
*
* @param userId - Team member ID
* @param teamId - Team ID
*/
- (nullable NIMTeamMember *)teamMember:(NSString *)userId
inTeam:(NSString *)teamId
@end
Update team member information
Two updating options are available. Only the administrator can update or all members can update.
objc@protocol NIMTeamManager <NSObject>
/**
* Update member nickname in a team
*
* @param userId - Team member ID
* @param newNick - Nickname of a new team member
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateUserNick:(NSString *)userId
newNick:(NSString *)newNick
inTeam:(NSString *)teamId
completion:(NIMTeamHandler)completion
@end
Parameter List
Parameter | Type | Description |
---|---|---|
userId | NSString | User ID |
newNick | NSString | New nickname of team member |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Modify the team member custom attribute
objc@protocol NIMTeamManager <NSObject>
/**
* Update team custom attribute of a member
*
* @param newInfo - New custom attribute
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateMyCustomInfo:(NSString *)newInfo
inTeam:(NSString *)teamId
completion:(NIMTeamHandler)completion
@end
Parameter List
Parameter | Type | Description |
---|---|---|
newInfo | NSString | New custom attribute |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
After the modification, other online users will automatically fetch the updated attribute.
Monitor team member change
objc@protocol NIMTeamManagerDelegate <NSObject>
/**
* A callback for changing team members, including number change and change in member attribute.
*
* @param team - Changed team
*/
- (void)onTeamMemberChanged:(NIMTeam *)team;
@end
Judge the existence in team
objc@protocol NIMTeamManager <NSObject>
/**
* It determines that a member is existing in a member.
*
*/
- (BOOL)isMyTeam:(NSString *)teamId
@end
Ownership transfer
objc@protocol NIMTeamManager <NSObject>
/**
* Transfer a team owner
*
* @param teamId - Team ID
* @param newOwnerId - New team owner ID
* @param isLeave - It determines that members leave a team synchronously.
* @param completion - Callback that is returned after completion
*/
- (void)transferManagerWithTeam:(NSString *)teamId
newOwnerId:(NSString *)newOwnerId
isLeave:(BOOL)isLeave
completion:(NIMTeamHandler)block
@end
Parameter List
Parameter | Type | Description |
---|---|---|
teamId | NSString | Team ID |
newOwnerId | NSString | New owner ID |
isLeave | BOOL | Synchronously leave the team or not |
completion | NIMTeamHandler | Callback after completion |
Add an administrator
objc@protocol NIMTeamManager <NSObject>
/**
* Add an administrator
*
* @param teamId - Team ID
* @param users - List of user IDs to be added as administrators
* @param completion - Callback that is returned after completion
*/
- (void)addManagersToTeam:(NSString *)teamId
users:(NSArray<NSString *> *)users
completion:(NIMTeamHandler)completion
@end
Parameter List
Parameter | Type | Description |
---|---|---|
clientCustomMode | NIMTeamUpdateClientCustomMode | Modify the one who has the authority to update the team custom field |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Remove an administrator
objc@protocol NIMTeamManager <NSObject>
/**
* Remove an administrator
*
* @param teamId - Team ID
* @param users - List of user IDs for administrators to be removed
* @param completion - Callback that is returned after completion
*/
- (void)removeManagersFromTeam:(NSString *)teamId
users:(NSArray<NSString *> *)users
completion:(NIMTeamHandler)completion
@end
Parameter List
Parameter | Type | Description |
---|---|---|
teamId | NSString | Team ID |
users | NSArray<NSString *> | List of user ID to be removed from the list of administrators |
completion | NIMTeamHandler | Callback after completion |
Mute
Mute specified members
objc@protocol NIMTeamManager <NSObject>
/**
* Team members are muted.
*
* @param mute - It determines that team members are muted.
* @param userId - User ID
* @param teamId - Team ID
* @param completion - Returned callback after completion of experimental operation
*/
- (void)updateMuteState:(BOOL)mute
userId:(NSString *)userId
inTeam:(NSString *)teamId
completion:(NIMTeamHandler)block
@end
After a user is muted, CommsEase server will issue a notification of the fact that the user is muted.
Parameter List
Parameter | Type | Description |
---|---|---|
mute | BOOL | Whether to mute users |
userId | NSString | User ID |
teamId | BOOL | Team ID |
completion | NIMTeamHandler | Callback after completion |
Mute all team members
Mute all ordinary members
objc/**
* Mute all team members
*
* @param mute - It determines that team members are muted.
* @param teamId - Team ID
* @param completion - Returned callback after completion of experimental operation
* @discussion - If the operation is successful, the CommsEase server will send a team notification message for mute.
*/
- (void)updateMuteState:(BOOL)mute
inTeam:(NSString *)teamId
completion:(nullable NIMTeamHandler)completion;
Parameter description:
Parameter | Type | Description |
---|---|---|
mute | BOOL | Whether to mute users |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
The API is used to mute and un-mute the ordinary members of a team, for which the owner of an advanced team has the authority.
Query mute status
- Search the list of mute users
Only the team members who are muted with the method "mute specified members" will be included in the list.
objc@protocol NIMTeamManager <NSObject>
/**
* Get the list of muted team members
*
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)fetchTeamMutedMembers:(NSString *)teamId
completion:(nullable NIMTeamMemberHandler)completion;
@end
Parameter List
Parameter | Type | Description |
---|---|---|
teamId | BOOL | Team ID |
completion | NIMTeamHandler | Callback after completion |
In most cases, the request is read and cached locally, synchronized, and returned. However, due to a large amount of team member information, SDK delays the pull after login.
Since SDK is probably unable to timely cache team member information due to user network and other issues, the request will be an asynchronous operation with network request (increment request).
The API will request team user profile that has not been cached locally, without triggering the callback of -(void)onUserInfoChanged:
.
- Whether the whole team is muted
Judge by NIMTeam
's - (BOOL)inAllMuteMode
.
- Whether a team member is muted
Judge by NIMTeamMember
's - (BOOL)isMuted
.
Note: if a member has never been muted by the method "mute specified members" after the whole mute, NO applies to NIMTeamMember
's -(BOOL)isMuted
.
Team information management
Edit team profile
Modify team name
objc@protocol NIMTeamManager <NSObject>
/**
* Get team name
*
* @param teamName - Team name
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateTeamName:(NSString *)teamName
teamId:(NSString *)teamId
completion:(NIMTeamHandler)completion
@end
Parameter List
Parameter | Type | Description |
---|---|---|
teamName | NSString | Team name |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Modify team avatar
objc@protocol NIMTeamManager <NSObject>
/**
* Update team avatar
*
* @param teamAvatarUrl - Team avatar Url
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateTeamAvatar:(NSString *)teamAvatarUrl
teamId:(NSString *)teamId
completion:(NIMTeamHandler) completion;
@end
Parameter List
Parameter | Type | Description |
---|---|---|
teamAvatarUrl | NSString | Team avatar Url |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
For uploading team a team avatar to CommsEase server, see Avatar resource processing.
Modify team introduction
objc@protocol NIMTeamManager <NSObject>
/**
* Update team introduction
*
* @param intro - Team introduction
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateTeamIntro:(NSString *)intro
teamId:(NSString *)teamId
completion:(NIMTeamHandler)block
@end
Parameter List
Parameter | Type | Description |
---|---|---|
intro | NSString | Team introduction |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Modify announcement
objc@protocol NIMTeamManager <NSObject>
/**
* Update team announcement
*
* @param announcement - Team announcement
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateTeamAnnouncement:(NSString *)announcement
teamId:(NSString *)teamId
completion:(NIMTeamHandler)completion
@end
Parameter List
Parameter | Type | Description |
---|---|---|
announcement | NSString | Team announcement |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Modify join mode
objc@protocol NIMTeamManager <NSObject>
/**
* Update team verification mode
*
* @param joinMode - Verification mode
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateTeamJoinMode:(NIMTeamJoinMode)joinMode
teamId:(NSString *)teamId
completion:(NIMTeamHandler)completion
@end
Parameter List
Parameter | Type | Description |
---|---|---|
joinMode | NIMTeamJoinMode | Join mode |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Update the join mode of invitees
objc@protocol NIMTeamManager <NSObject>
/**
* Update team verification mode for invited users
*
* @param beInviteMode - Invitation mode
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateTeamBeInviteMode:(NIMTeamBeInviteMode)beInviteMode
teamId:(NSString *)teamId
completion:(NIMTeamHandler)completion;
@enc
Parameter List
Parameter | Type | Description |
---|---|---|
beInviteMode | NIMTeamBeInviteMode | Invitation mode |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Modify the one who can invite others to join team
objc@protocol NIMTeamManager <NSObject>
/**
* Update team invitation mode
*
* @param inviteMode - Invitation mode
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateTeamInviteMode:(NIMTeamInviteMode)inviteMode
teamId:(NSString *)teamId
completion:(NIMTeamHandler)completion
@end
Parameter List
Parameter | Type | Description |
---|---|---|
inviteMode | NIMTeamInviteMode | Invitation mode |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Modify the one who can update team profile
objc@protocol NIMTeamManager <NSObject>
/**
* Permission for changing team update information
*
* @param updateInfoMode - Modify the one who has permission for updating team profile
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateTeamUpdateInfoMode:(NIMTeamUpdateInfoMode)updateInfoMode
teamId:(NSString *)teamId
completion:(NIMTeamHandler)block
@end
Parameter List
Parameter | Type | Description |
---|---|---|
updateInfoMode | NIMTeamUpdateInfoMode | Modify the one who has the authority to update the team profile |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Modify the one who can update the team custom attribute
objc@protocol NIMTeamManager <NSObject>
/**
* Change team permission for updating custom field
*
* @param clientCustomMode - Modify the one who has permission for updating team custom field
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateTeamUpdateClientCustomMode:(NIMTeamUpdateClientCustomMode)clientCustomMode
teamId:(NSString *)teamId
completion:(NIMTeamHandler)block
@end
Parameter List
Parameter | Type | Description |
---|---|---|
clientCustomMode | NIMTeamUpdateClientCustomMode | Modify the one who has the authority to update the team custom field |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Modify team custom attribute
SDK provides a team profile extension API, for which the developer may define the contents.
objc@protocol NIMTeamManager <NSObject>
/**
* Update team custom information
*
* @param info - Team custom information
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateTeamCustomInfo:(NSString *)info
teamId:(NSString *)teamId
completion:(NIMTeamHandler)block
@end
Parameter List
Parameter | Type | Description |
---|---|---|
info | NSString | Team custom information |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
Monitor team change
- Team information update callback
objc@protocol NIMTeamManagerDelegate <NSObject>
/**
* A callback for updating a team
*
* @param team - Updated team
*/
- (void)onTeamUpdated:(NIMTeam *)team
@end
- Team addition callback
objc@protocol NIMTeamManagerDelegate <NSObject>
/**
* Add callback for team
*
* @param team - Updated team
*/
- (void)onTeamAdded:(NIMTeam *)team;
@end
- Team removal callback
objc@protocol NIMTeamManagerDelegate <NSObject>
/**
* A callback for removing a team
*
* @param team - Updated team
*/
- (void)onTeamRemoved:(NIMTeam *)team;
@end
Team notification message
Team notification is a type of message (NIMMessageTypeNotification
). After a user joins a team, a team notification message will be issued by the Xinyun server in case of any change in a team (including the joining action). Like other messages, team notification messages can be fetched from the message query API provided by NIMConversationManager
.
Events triggering team notification message currently include:
NIMTeamOperationType Enum | Event description |
---|---|
NIMTeamOperationTypeInvite | Invite members into a team (a mode not requiring approval of invitee) |
NIMTeamOperationTypeAcceptInvitation | Add members into team after approval for invitation (a mode requiring approval of invitee) |
NIMTeamOperationTypeKick | Kick out of team |
NIMTeamOperationTypeLeave | Leave a team |
NIMTeamOperationTypeUpdate | Team information update |
NIMTeamOperationTypeDismiss | Dismiss a team |
NIMTeamOperationTypeApplyPass | Successfully join a team |
NIMTeamOperationTypeTransferOwner | Transfer owner |
NIMTeamOperationTypeAddManager | Add an administrator |
NIMTeamOperationTypeRemoveManager | Remove manager |
NIMTeamOperationTypeMute | Team mute/unmute |
Team notification analysis step:
- Judge the noficiation message based on
NIMMessage
'smessageType
. - Convert
NIMMessage
's fieldmessageObject
intoNIMNotificationObject
in a strongly typed manner. - In
NIMNotificationObject
, resolve the fieldcontent
, obtaining the superclassNIMNotificationContent
. - based on
NIMNotificationContent
's fieldnotificationType
, judge theNIMNotificationTypeTeam
. - Convert the superclass
NIMNotificationContent
intoNIMTeamNotificationContent
in a strongly typed manner. - The specific type of team notification can be resolved using the
NIMTeamNotificationContent
'soperationType
. The specific type is shown in the table above. - Upon the receipt of team notification, SDK will update the team relevant information cached locally, and then trigger and update the callback of delegated events.
Field description of team notification content NIMTeamNotificationContent
:
operationType
: team notification event type, which indicates the type of team notification. The notification type is defined by the enumNIMTeamOperationType
.sourceID
: Event operator ID, i.e. the one who voluntarily executes the operation.targetIDs
: List of IDs of the one operated, i.e. the operation bearer.notifyExt
: extension field notified, which is defined by each operation API that trigger the notification. The field can be defined only by the server operation API currently. For example, users removed from the team may call the server HTTP API, and input the notification extension parameters. The call will trigger a message notification of such event as users kick-out, in which case the other members who receive the message may fetch the extension field defined at kick-out by readingNIMTeamNotificationContent
's fieldnotifyExt
.attachment
: Some notifications are relatively complex, which require some additional information to assist the upper-level display. Team notification with additional information includes:- Team update notification NIMTeamOperationTypeUpdate: additional information is encapsulated as
NIMUpdateTeamInfoAttachment
. It is same type for the global mute. - Mute notification NIMTeamOperationTypeMute: additional information is encapsulated as
NIMMuteTeamMemberAttachment
.
- Team update notification NIMTeamOperationTypeUpdate: additional information is encapsulated as
Particularly, as to the team update notification NIMTeamOperationTypeUpdate, it is required to judge the details in NIMUpdateTeamInfoAttachment, as well as the team message updated. Details are given in Demo:
objccase NIMTeamOperationTypeUpdate:
{
id attachment = [content attachment];
if ([attachment isKindOfClass:[NIMUpdateTeamInfoAttachment class]]) {
NIMUpdateTeamInfoAttachment *teamAttachment = (NIMUpdateTeamInfoAttachment *)attachment;
formatedMessage = [NSString stringWithFormat:@"%@Updated%@Information".nim_localized,source,teamName];
//If only a single project item is updated, the updated item will be shown.
if ([teamAttachment.values count] == 1) {
NIMTeamUpdateTag tag = [[[teamAttachment.values allKeys] firstObject] integerValue];
switch (tag) {
case NIMTeamUpdateTagName:
formatedMessage = [NSString stringWithFormat:@"%@Updated%@Name".nim_localized,source,teamName];
break;
case NIMTeamUpdateTagIntro:
formatedMessage = [NSString stringWithFormat:@"%@Updated%@Introduction".nim_localized,source,teamName];
break;
case NIMTeamUpdateTagAnouncement:
formatedMessage = [NSString stringWithFormat:@"%@Updated%@Announcement".nim_localized,source,teamName];
break;
case NIMTeamUpdateTagJoinMode:
formatedMessage = [NSString stringWithFormat:@"%@Updated%@Verification Mode".nim_localized,source,teamName];
break;
case NIMTeamUpdateTagAvatar:
formatedMessage = [NSString stringWithFormat:@"%@Updated%@Avatar".nim_localized,source,teamName];
break;
case NIMTeamUpdateTagInviteMode:
formatedMessage = [NSString stringWithFormat:@"%@Updated permission for inviting other users".nim_localized,source];
break;
case NIMTeamUpdateTagBeInviteMode:
formatedMessage = [NSString stringWithFormat:@"%@Updated permission for verifying ID of invited user".nim_localized,source];
break;
case NIMTeamUpdateTagUpdateInfoMode:
formatedMessage = [NSString stringWithFormat:@"%@Updated permission for updateing team profile".nim_localized,source];
break;
case NIMTeamUpdateTagMuteMode:{
NSString *muteState = teamAttachment.values.allValues.firstObject;
BOOL muted = [muteState isEqualToString:@"0"] ? NO : YES;
formatedMessage = muted? [NSString stringWithFormat:@"%@All members are muted".nim_localized,source]: [NSString stringWithFormat:@"%@All members are demuted".nim_localized,source];
break;
}
default:
break;
}
}
}
if (formatedMessage == nil){
formatedMessage = [NSString stringWithFormat:@"%@Updated%@Information".nim_localized,source,teamName];
}
}
break;
Mute Notification
SDK provides an API for modification of team message notification, and the upper level may affect the notification action by setting the option. When notify is set as NIMTeamNotifyStateNone, no APNS will be available for pushing team messages; in the event of NIMTeamNotifyStateOnlyManager, only the administrator's team message notification will be available. The upper level may decide the APP performance when online messages are received by the attribute (ringing, etc.).
objc@protocol NIMTeamManager <NSObject>
/**
* Update mute status of a team
*
* @param notify - Tip status
* @param teamId - Team ID
* @param completion - Callback that is returned after completion
*/
- (void)updateNotifyState:(NIMTeamNotifyState)state
inTeam:(NSString *)teamId
completion:(nullable NIMTeamHandler)completion;
@end
Parameter List
Parameter | Type | Description |
---|---|---|
notify | NIMTeamNotifyState | Notify state |
teamId | NSString | Team ID |
completion | NIMTeamHandler | Callback after completion |
NIMTeamNotifyState enum list
Value | Description |
---|---|
NIMTeamNotifyStateAll | Accept any team message notification |
NIMTeamNotifyStateNone | Reject any team message notification |
NIMTeamNotifyStateOnlyManager | Only accept manager's team message notification |
Query API
objc@protocol NIMTeamManager <NSObject>
/**
* Query mute status of a team
*
* @param teamId - Team ID
*
* @return - Status of team tip
*/
- (NIMTeamNotifyState)notifyStateForNewMsg:(NSString *)teamId;
@end
Search team
SDK supports the team search by keywords:
objc@protocol NIMTeamManager <NSObject>
/**
* Retrieve team
*
* @param option - Retrieval options
*
* @param completion - Callback that is returned after completion
*/
- (void)searchTeamWithOption:(NIMTeamSearchOption *)option
completion:(NIMTeamSearchHandler)completion;
@end
NIMTeamSearchOption Parameter Introduction:
Type | Parameter | Description |
---|---|---|
NIMTeamSearchContentOption | searchContentOption | Search the content matching area |
BOOL | ignoreingCase | Ignore case, YES in default |
NSString | searchContent | Search content |
NIMTeamSearchContentOption Enum introduction:
objctypedef NS_OPTIONS(NSInteger, NIMTeamSearchContentOption ) {
// Retrieve team name
NIMTeamSearchContentOptiontName = 1 < < 0,
// Retrieve team ID
NIMTeamSearchContentOptiontId = 1 < < 1,
// Retrieve team name and team ID
NIMTeamSearchContentOptionTeamAll = NIMTeamSearchContentOptiontName | NIMTeamSearchContentOptiontId,
};