SuperTeam Features
Update time: 2021/12/03 09:08:40
Overview
the superteam feature enables large-scale team chats. The maximum number of members in a superteam is 5000. A superteam cannot support all the management features of the advanced team.
Superteam supports team owner, the administrator, and ordinary members.
Superteam methods:
Return | Method | Description |
---|---|---|
String | getAnnouncement() | Get team announcements. |
long | getCreateTime() | Get team creation time. |
String | getCreator() | Get the owner account. |
String | getExtension() | Get the extension configuration. |
String | getExtServer() | Get extension configuration for server. |
String | getIcon() | Get team profile picture. |
String | getId() | Get the team ID. |
String | getIntroduce() | Get team introduction. |
int | getMemberCount() | Get total team member count. |
int | getMemberLimit() | Get team member limit. |
TeamAllMuteModeEnum | getMuteMode() | Get team mute mode. |
String | getName() | Get team name. |
TeamBeInvite ModeEnum |
getTeamBeInviteMode() | Get team invitation mode, approval method of invitee. |
TeamExtension UpdateModeEnum |
getTeamExtensionUpdateMode() | Get update mode of Team profile extension field, i.e. "who can update user-defined properties of team (extension field)". |
TeamInviteModeEnum | getTeamInviteMode() | Get team invitation mode, i.e. "who can invite others to the team". |
TeamUpdateModeEnum | getTeamUpdateMode() | Get Team profile update mode, i.e. "who can update team profile". |
TeamTypeEnum | getType() | Get group type. |
VerifyTypeEnum | getVerifyType() | Get verification type when the user sends a team application. |
boolean | isAllMute() | Determine that all members are muted. |
TeamAllMuteModeEnum | getMuteMode() | Get mute mode of all members. |
boolean | isMyTeam() | Determine that the user is in the team. |
TeamMessageNotifyTypeEnum | getMessageNotifyType() | Get tip type after the current account receives team message. |
void | setExtension(extension) | Set team extension configuration. |
Messaging
Superteam chat is the same as one-to-one chat and team chat in sending and receiving messages. The only difference is SessionTypeEnum
. In addition, the message sending service changes to superteamService
and message receiving service changes to superteamServiceObserver
. See "Send and receive message".
Recalling messages
Superteam allows you to recall messages.
java/**
* Message recall, pushing allowed
* @param message The message that you want to recall.
* @param customApnsText push text Not pushed if null
* @param pushPayload push payload, limit json, length 2048
* @param shouldNotifyBeCount Whether the revocation notice is included into the unread count.
*/
InvocationFuture<java.lang.Void> recallMessage(IMMessage message,
java.lang.String customApnsText,
java.util.Map<java.lang.String,java.lang.Object> pushPayload,
boolean shouldNotifyBeCount);
- Example
java// Recall a message
NIMClient.getService(superteamService.class).recallMessage(message);
Creating a superteam
Superteam should be created using API at the server. No interface is provided at the client for the creation.
Getting a team
Getting all teams Locally
The SDK provides the interface used to get a list of teams that you have joined.
- API prototype
Asynchronous interface:
java/**
* Get the list of teams you have joined
*
* @return InvocationFuture you can set the callback feature. If successful, the parameter is the list of teams you have joined
*/
InvocationFuture<List<Superteam>> queryTeamList();
Synchronous interface
java/**
* Get the list of teams you have joined.
*
* @return List of teams you have joined
*/
public List<Superteam> queryTeamListBlock();
- Example
Asynchronous request example:
javaNIMClient.getService(superteamService).queryTeamList().setCallback(new RequestCallback<List<Team>>() {
@Override
public void onSuccess(List<Superteam> teams) {
// Get the list successfully. teams are all the teams you have joined
}
@Override
public void onFailed(int i) {
// Fail to get the list. See i parameter for specific error code
}
@Override
public void onException(Throwable throwable) {
// Get the list abnormally
}
});
Synchronous request example:
java// Get the teams that you have joined
List<Superteam> teams = NIMClient.getService(superteamService).queryTeamListBlock();
Getting a specified team locally
Asynchronous interface:
java/**
* Query the team profile, or go to the server if the Team profile is unavailable locally.
* If you are not in this team, this interface may return outdated information, if you need the latest information, please call the searchTeam(String teamId) interface
* @param teamId - Team ID
*/
InvocationFuture<Superteam> queryTeam(java.lang.String teamId);
Synchronous interface:
java/**
* Query the team profile, only local query
* @param teamId - Team ID
*/
Superteam queryTeamBlock(java.lang.String teamId);
Get multiple specified teams at a time
java/**
* Query Team profile at a time based on team ID list
* @param tidList team ID list
*/
// Asynchronous interface
InvocationFuture<java.util.List<Superteam>> queryTeamListById(java.util.List<java.lang.String> tidList);
// Synchronous interface
java.util.List<Superteam> queryTeamListByIdBlock(java.util.List<java.lang.String> tidList);
Getting a specified team from the cloud
java/**
* Query the Team profile from the server
* @param teamId - Team ID
*/
InvocationFuture<Superteam> searchTeam(java.lang.String teamId);
Dismiss teams
Superteam should be dismissed using API at the server. No interface is provided at the client for the dissolution.
Team member management
Joining a team
Requesting membership of a team
If a user applies for joining a team, a team message will be returned when the user joins a team, or waits for verification.
- API prototype
java/**
* Users apply to join a team.
*
* @param tid The team ID
* @param postscript, length ≤ 5000
* @return InvocationFuture you can set the callback feature. If successful, the parameter is the team profile
*/
InvocationFuture<Superteam> applyJoinTeam(String tid, String postscript);
- Parameters
Parameter | Description |
---|---|
tid | Team ID |
postcript | Postscript with a size of not larger than 5,000 bytes |
- Example
javaNIMClient.getService(superteamService.class).applyJoinTeam(teamId, postscript).setCallback(new RequestCallback<Superteam>() {
@Override
public void onSuccess(Superteam team) {
// Send a request to join a team successfully
}
@Override
public void onFailed(int code) {
// Only successful application
if(code == ResponseCode.RES_TEAM_APPLY_SUCCESS){
Toast.makeText(superteamMsgActivity.this, "Waiting for validation", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(superteamMsgActivity.this, "Application failed, code=" + code, Toast.LENGTH_LONG).show();
}
}
@Override
public void onException(Throwable throwable) {
Log.e(TAG, "apply join team failed:" + throwable);
}
});
- Error codes
Error code | Description |
---|---|
808 | Application is sent. |
809 | The user has joined the team. |
Verifying requests
After the user sends an application, all administrators will receive a system notification of the SystemMessageType#superteamApply
type. For more information, see System notification. The administrator can approve or reject the application.
- Approve the application
Only the administrator and owner have the permissions to approve the application. If the application is approved, all members (including the applicant) will receive a notification of the notification
type and an attachment of MemberChangeAttachment
. For more information, see Sending and receiving messages.
- API prototype
java/**
* Approve user's application for joining a team <br>
* Only administrator and owner have this permission
*
* @param teamId team ID
* @param account user ID for applying into a team
* @return InvocationFuture you can set the callback feature
*/
InvocationFuture<Void> passApply(String teamId, String account);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
account | Applicant ID |
- Example
javaNIMClient.getService(superteamService.class).passApply(tid, account).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
Toast.makeText(superteamMsgActivity.this, "application approved", Toast.LENGTH_LONG).show();
}
@Override
public void onFailed(int i) {
Toast.makeText(superteamMsgActivity.this, "application failed, code=" + i, Toast.LENGTH_LONG).show();
}
@Override
public void onException(Throwable throwable) {
Log.e(TAG, "pass apply failed:" + throwable);
}
});
- Reject the application
Only the administrator and owner have the permissions to reject an application. If the team application is rejected, the applicant will receive a system notification with the type of SystemMessageType#RejectTeamApply
. See "System notification" for parameter description.
- API prototype
java/**
* Reject the user's application for joining a team <br>
* Only administrator and owner have this permission
*
* @param teamId team ID
* @param account user ID for applying into a team
* @param reason, length ≤ 5000
* @return InvocationFuture you can set the callback feature
*/
InvocationFuture<Void> rejectApply(String teamId, String account, String reason);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
account | Applicant ID |
reason | Reason for rejecting the application. The parameter is optional with a size of not larger than 5,000 bytes |
- Example
javaNIMClient.getService(superteamService.class).rejectApply(tid, account, reason).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
// Rejected successfully
}
@Override
public void onFailed(int i) {
// Rejection failed
}
@Override
public void onException(Throwable throwable) {
Log.e(TAG, "reject apply failed:" + throwable);
}
});
Notes: If any administrator executes any operation, other administrators cannot repeat the operation.
Inviting to join a team
All members can invite users to join the team. If the number of team members reaches the upper limit, the accounts of the users that are invited will be returned.
- API prototype
java/**
* Invite
*
* @param teamId team ID
* @param accounts list of to-be-added team member accounts
* @param postscript, length ≤ 5000
* @return InvocationFuture you can set the callback feature to monitor the operation results
*/
InvocationFuture<List<String>> addMembers(String teamId, List<String> accounts, String postscript);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
accounts | List of member accounts to be invited to a team |
postcript | Postscript with a size of not larger than 5,000 bytes |
- Example
javaNIMClient.getService(superteamService).addMembers(teamId, accounts, postcrip)
.setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
// Return onSuccess, which indicates that invitation does not need the other party's consent, and the other party has joined the team successfully
}
@Override
public void onFailed(int code) {
// Return onFailed
}
@Override
public void onException(Throwable exception) {
...
}
});
When a user receives the first team message after joining a team, all team members (including the user) will receive a team message, with the attachment type of MemberChangeAttachment. If notification type is NotificationType#SUPER_TEAM_INVITE
, extension field configured by server can be acquired using MemberChangeAttachment#getExtension.
Verifying invitation requests
After receiving the invitation to the team, the user can check the invitation in the system notification and then accept or reject the invitation. After accepting the invitation, the user can indeed join the team. If the user rejects the invitation, the administrator who sends the invitation will receive a system notification with the type of `SystemMessageType#superteamApplyReject.
- Accept the team invitation
java/**
* Accept the invitation to join in a team
*
* @param teamId team ID
* @param inviter The account of an inviter
* @return InvocationFuture you can set the callback feature
*/
InvocationFuture<Void> acceptInvite(String teamId, String inviter);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
inviter | The account of an inviter |
- Example
javaNIMClient.getService(superteamService.class).acceptInvite(teamId, inviter).setCallback(...);
- Reject the invitation
java/**
* Notice of rejecting someone's invitation to join in a team
*
* @param teamId team ID
* @param inviter The account of an inviter
* @param reason, length ≤ 5000
* @return InvocationFuture you can set the callback feature
*/
InvocationFuture<Void> declineInvite(String teamId, String inviter, String reason);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
inviter | The account of an inviter |
reason | Reject reason, optional with a size of not larger than 5,000 bytes |
- Example
javaNIMClient.getService(superteamService.class).declineInvite(teamId, inviter, "").setCallback(callback);
Removing a member from a team
Only the owner can kick members out of the team, and all team members (including the members kicked out of the team) will receive a notification message IMMessage with the type of NotificationType#SUPER_TEAM_KICK
and the attachment type of MemberChangeAttachment
. The extension field configured by the server can be acquired using MemberChangeAttachment#getExtension.
- API prototype
java/**
* Remove members, only the team owner has this permission
*
* @return InvocationFuture you can set the callback feature to monitor the operation results
*/
InvocationFuture<Void> removeMember(String teamId, String member);
/**
* Remove members at a time, only the team owner has this permission
*
* @param teamId team ID
* @param members list of kicked team member accounts
* @return InvocationFuture you can set the callback feature to monitor the operation results
*/
InvocationFuture<Void> removeMembers(String teamId, List<String> members);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
member | The ID of the member kicked out of the team |
- Example
java// teamId indicates team ID, and account is account of the kicked member
NIMClient.getService(SupersuperteamService.class).removeMember(teamId, account).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
// Successful
}
@Override
public void onFailed(int code) {
// Failed
}
@Override
public void onException(Throwable exception) {
// Error
}
});
Leave a team
The owner of the team can leave the team. If the owner leaves, then there is not an owner in the team. Other team members can leave the team. When a member leaves the team, all members (including the member that leave the team will receive a notification of NotificationType#SUPER_TEAM_LEAVE
type and the attachment of MemberChangeAttachment
type.
- API prototype
java/**
* Quit a team
*
* @param teamId team ID
* @return InvocationFuture you can set the callback feature to monitor the operation results
*/
InvocationFuture<Void> quitTeam(String teamId);
- Example
javaNIMClient.getService(superteamService.class).quitTeam(teamId).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
// Quit a team successfully
}
@Override
public void onFailed(int code) {
// Fail to quit a team
}
@Override
public void onException(Throwable exception) {
// Error
}
});
Getting team members
Getting the list of team members
The data of team members is large, and the list of team members is not required except for joining the corresponding interface. Therefore, the SDK will not synchronize the data of team members on login, but determine that synchronization is required based on the principle of capture on demand when the upper layer actively calls to acquire the list of members in a specified team.
SDK local storage for team member profile: When a member leaves the team or is removed from the team, the local database will keep his information and configure with an invalid token. The information about this member can be queried using queryTeamMember, but isMyTeam will return false.
- API prototype
java/**
Get the list of team member profile of specified team.<br>
* You may just read the cached data from the local database, or synchronize the new data from the server, so it may take a long time.
*
* @param teamId team ID
* @return InvocationFuture you can set the callback feature. If successful, the parameter is the team member profile list
*/
InvocationFuture<List<SuperteamMember>> queryMemberList(String teamId);
- Example
javaNIMClient.getService(superteamService.class).queryMemberList(teamId).setCallback(new RequestCallbackWrapper<List<SuperteamMember>>() {
@Override
public void onResult(int code, final List<SuperteamMember> members, Throwable exception) {
...
}
});
Getting a specified team member
If information about local team members expires, the SDK will get the latest information from the server.
- API prototype
Asynchronous interface:
java/**
* Query the team member profile If the local team member profile has expired, please go to the server to get the latest information.
*
* @param teamId team ID
* @param account team member account
* @return InvocationFuture you can set the callback feature. If successful, the parameter is the team member profile
*/
InvocationFuture<SuperteamMember> queryTeamMember(String teamId, String account);
Synchronous interface (for querying local Team profile only):
java/**
* Query the team member profile (Synchronous edition) Only query local team profile
*
* @param teamId team ID
* @param account team member account
* @return team member profile
*/
SuperteamMember queryTeamMemberBlock(String teamId, String account);
- Example
Asynchronous interface example:
javaNIMClient.getService(superteamService.class).queryTeamMember(teamId, account).setCallback(new RequestCallbackWrapper<SuperteamMember>() {
@Override
public void onResult(int code, SuperteamMember member, Throwable exception) {
...
}
});
Synchronous interface example:
javaSuperteamMember member = NIMClient.getService(superteamService.class).queryTeamMemberBlock(teamId, account);
Getting team members by page
java/**
* Get the list of team member profile of specified team by page.<br>
* You may just read the cached data from the local database, or synchronize the new data from the server, so it may take a long time.
*
* @param teamId team ID
* @param offset
* @param limit get the number, up to 200 each time
* @return InvocationFuture you can set the callback feature. If successful, the parameter is the team member profile list
*/
InvocationFuture<List<SuperteamMember>> queryMemberListByPage(String teamId, int offset, int limit);
Modifying member profiles
Modifying member profiles in a team
Only the team owner and administrator can update profile names of other members in a team.
The team owner can update the profile names of all members in the team. The administrator can only update the profile names of ordinary members in the team.
- API prototype
java/**
* The team administrator can change the profile names of other members in the team. <br>
* Only team administrator and owner have this permission
*
* @param teamId team ID
* @param account to-be-changed team member account
* @param nick New team profile name
* @return InvocationFuture you can set the callback feature to monitor the operation results
*/
InvocationFuture<Void> updateMemberNick(String teamId, String account, String nick);
- Example
javaNIMClient.getService(superteamService.class).updateMemberNick(teamId, account, nick).setCallback(
new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
// The profile names of the team members in the team have been successfully changed
}
@Override
public void onFailed(int code) {
// Fail to change the profile names of the team members in the team
}
@Override
public void onException(Throwable exception) {
// Error
}
}
);
Modifying the user profile
Modify the display name of the user profile in a team.
- API prototype
java/**
* Change own team profile name
*
* @param teamId team ID
* @param nick New team profile name
* @return InvocationFuture you can set the callback feature to monitor the operation results
*/
InvocationFuture<Void> updateMyTeamNick(String teamId, String nick);
- Example
java// test is changed team profile name
NIMClient.getService(superteamService.class).updateMyTeamNick(teamId, "test")
Update the extension field in the team.
- API prototype
java/**
* Change own team member extension field (user-defined attribute, up to 32 characters)
*
* @param teamId team ID
* @param extension new extension field (user-defined attribute)
* @return InvocationFuture you can set the callback feature to monitor the operation results
*/
InvocationFuture<Void> updateMyMemberExtension(String teamId, String extension);
- Example
javaString extension = "1213";
NIMClient.getService(superteamService.class).updateMyMemberExtension(teamId, extension)
Listening for team member changes
The inter-process asynchronous call is required for acquiring team member profile, so that developers must cache the information in the third-party APP, and then access the local cache to query team member profile. The SDK can inform registered observers of any change in team member profile. At this time, the third-party app can update the cache and refresh the interface.
Listening for changes of member profiles
- API prototype
java/**
* Observer notification of changing team member profile
* The upper-level app can update the cache through this interface if the cache of team member profile is managed.
* @param observer, the parameter is the list of updated team member profile
* @param register true indicates registered, and true indicates unregistered
*/
public void observeMemberUpdate(Observer<List<SuperteamMember>> observer, boolean register);
- Example
java// Observer notification of changing team member profile New members are added to the team, and you will receive this notification in case of change in member profile.
// The returned parameter is the list of updated team member profile.
Observer<List<SuperteamMember>> memberUpdateObserver = new Observer<List<SuperteamMember>>() {
@Override
public void onEvent(List<SuperteamMember> members) {
}
};
// Register or unregister the observer
NIMClient.getService(superteamServiceObserver.class).observeMemberUpdate(memberUpdateObserver, register);
Listening for changes of removing team members
- API prototype
java/**
* Observer notification when a team member is removed.
* @param observer, a parameter is the removed group member
* @param register true indicates registered and true indicates unregistered
*/
public void observeMemberRemove(Observer<SuperteamMember> observer, boolean register);
- Example
java// Observer notification when a team member is removed.
private Observer<SuperteamMember> memberRemoveObserver = new Observer<SuperteamMember>() {
@Override
public void onEvent(SuperteamMember member) {
}
};
// Register or unregister the observer
NIMClient.getService(superteamServiceObserver.class).observeMemberRemove(memberRemoveObserver, register);
Team ownership transfer
The superteam owner can transfer the ownership to other team members,so that the member with the ownership becomes the new owner and the original owner will become an ordinary member. The original owner can also leave the team when transferring permission.
- API prototype
java/**
* The owner transfers the ownership of a team to another member, and the member becomes the owner after a transfer. <br>
* The original owner becomes an ordinary member. If the quit parameter is set to true, the original owner leaves the team.
*
* @param tid team ID
* @param account new user account
* @param quit quit this team or not during transfer
* @return InvocationFuture may set callback feature, with the parameter of quit value if it succeeds:<br>
* quit is false: the parameter contains only the original owner's and the current owner's (i.e. operator and account), and the permissions have been updated. <br>
* quit is true: Parameter is null.
*/
InvocationFuture<List<SuperteamMember>> transferTeam(String tid, String account, boolean quit);
- Parameters
Parameter | Description |
---|---|
tid | Team ID |
account | The account of a new owner |
quit | Determine whether to leave the team when transferring the ownership |
Return | Description |
:---------- | :---------- |
InvocationFuture | The invocation feature can be configured. If it is successful, the parameter quit is false. The parameter only includes the original owner and current owner (i.e. operator and account). The permissions have been updated. quit is true: The parameter is null. |
- Example
javaNIMClient.getService(superteamService.class).transferTeam(teamId, account, false)
.setCallback(new RequestCallback<List<SuperteamMember>>() {
@Override
public void onSuccess(List<SuperteamMember> members) {
// Team owner has been successfully changed
}
@Override
public void onFailed(int code) {
// Fail to change team owner
}
@Override
public void onException(Throwable exception) {
// Error
}
});
Adding an administrator
In a superteam, the owner can add an administrator. After the operation is executed, all members will receive a notification message IMMessage with the attachment type of MemberChangeAttachment
.
- API prototype
java/**
* The owner adds an administrator<br>
* Only the owner has the permissions.
*
* @param teamId The team ID
* @param accounts list of user accounts in which the owner will become an administrator
* @return InvocationFuture You can set the callback. If successful, the parameter is the new team administrator list.
*/
InvocationFuture<List<SuperteamMember>> addadministrators(String teamId, List<String> accounts);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
accounts | Account list of users to be promoted as administrators |
Return | Description |
:---------- | :---------- |
InvocationFuture | The invocation feature can be configured. If it is successful, the parameter will be list of promoted team members (permissions have been promoted to administrator level). |
- Example
javaNIMClient.getService(superteamService.class).addadministrators(tid, accountList).setCallback(new RequestCallback<List<SuperteamMember>>() {
@Override
public void onSuccess(List<SuperteamMember> param) {
// Add the team administrator successfully added
}
@Override
public void onFailed(int code) {
// Fail to add the team administrator
}
@Override
public void onException(Throwable exception) {
// Error
}
});
Removing an administrator
The owner can remove the administrator from the superteam. After the operation is executed, all members will receive a notification message IMMessage with the attachment type of MemberChangeAttachment
.
- API prototype
java/**
* The owner recalls administrator privileges<br>
* Only owner has this permission
*
* @param teamId team ID
* @param administrators accounts list of accounts in which the administrator will be recalld
* @return InvocationFuture you can set the callback feature. If successful, the parameter is the list of recalld team members (privileges become normal).
*/
InvocationFuture<List<SuperteamMember>> removeadministrators(String teamId, List<String> administrators);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
administrators | Account list of administrators to be dismissed |
Return | Description |
:---------- | :---------- |
InvocationFuture | The invocation feature can be configured. If it is successful, the parameter will be a list of dismissed team members (permissions have been declined to Normal level). |
- Example
javaNIMClient.getService(superteamService.class).removeadministrators(tid, accountList).setCallback(new RequestCallback<List<SuperteamMember>>() {
@Override
public void onSuccess(List<SuperteamMember> param) {
// Remove the team administrator successfully
}
@Override
public void onFailed(int code) {
// Fail to remove the team administrator
}
@Override
public void onException(Throwable exception) {
// Error
}
});
Muting
Muting specified members
The API allows you to mute and unmute ordinary members by the administrator and owner.
- API prototype
java/**
* Mute, unmute
*
* @param teamId team ID
* @param teamId team ID
* @param accountList list of muted and unmuted accounts
* @return InvocationFuture you can set the callback feature to monitor the operation results
*/
InvocationFuture<Void> muteTeamMembers(String teamId, ArrayList<String> accountList, boolean mute);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
accountList | unmuted account list |
mute | true: mute. "false: unmute. |
- Example
java// Mute a member
NIMClient.getService(superteamService.class).muteTeamMembers(tid, accountList, true).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
// Mute successful
}
@Override
public void onFailed(int code) {
// Mute failed
}
@Override
public void onException(Throwable exception) {
// Error
}
});
Muting all team members
Mute the team. Only the owner or administrator has permission. The team update interface will be invoked after a successful mute operation. The effective approaches include Team#getMuteMode and Team#isAllMute.
- API prototype
java/**
* Mute and unmute the team, effective for ordinary members, only team owner and administrator have this permission
*
* @param teamId team ID
* @param accountList list of muted and unmuted accounts
* @return InvocationFuture you can set the callback feature to monitor the operation results
*/
InvocationFuture<Void> muteAllTeamMember(String teamId, boolean mute);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
mute | true: to mute. false: to unmute. |
- Example
javaNIMClient.getService(superteamService.class).muteAllTeamMember(tid, true).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
// Mute successful
}
@Override
public void onFailed(int code) {
// Mute failed
}
@Override
public void onException(Throwable exception) {
// Error
}
});
Querying muted team members
The operation returns muted users only. Please query team mute status using Team#getMuteMode
and Team#isAllMute
.
- API prototype
java/**
* Query the list of muted team members
* Only return the user who has called {@link superteamService#muteTeamMembers(String, ArrayList, boolean)} mute.
*
* @param teamId team ID
* @return team member profile list
*/
List<SuperteamMember> queryMutedTeamMembers(String teamId);
- Example
java// memberList indicates the list of muted members
List<SuperteamMember> memberList = NIMClient.getService(superteamService.class).queryMutedTeamMembers(teamId);
Team profile management
Editing the team profile
See TeamFieldEnum
for updatable attributes. Notes: Extension field of team server Ext_Server_Only
can be updated at the server side only.
For information about updated value and corresponding data type, see TeamFieldEnum
. For example, Name(ITeamService.TinfoTag.NAME, String.class) indicates that data type of value is String. VerifyType(ITeamService.TinfoTag.JOIN_MODE, VerifyTypeEnum.class) indicates that data type of value is VerifyTypeEnum.
TeamFieldEnum attribute | Description | Data type |
---|---|---|
Announcement | Team announcement | String |
Ext_Server_Only | Team extension field (updated at server only) | String |
Extension | Team extension field (user-defined information at client) | String |
ICON | Team profile picture | String |
Introduce | Team introduction | String |
Name | Team name | String |
After the update, all members will receive a notification message IMMessage with attachment type SUPER_TEAM_UPDATE_T_INFO
. If the observer for Team profile change is registered, the observer will also receive a notification. See Monitor team changes.
Edit a team profile
- API prototype
java/**
* Update team profile
*
* @return InvocationFuture you can set the callback feature to monitor the operation results
*/
InvocationFuture<Void> updateTeam(String teamId, TeamFieldEnum field, Serializable value);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
field | Domain to be updated |
value | New value of the domain to be updated. The value type must be consistent with fieldType defined in the field. |
- Example
The team announcement is taken as an example.
javaString announcement = "This is the updated team announcement";
NIMClient.getService(superteamService.class).updateTeam(teamId, TeamFieldEnum.Announcement, announcement).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
// Successful
}
@Override
public void onFailed(int code) {
// Failed
}
@Override
public void onException(Throwable exception) {
// Error
}
});
- For uploading a teamprofile picture to CommsEase server, see profile picture resource processing.
Edit multiple team profiles
- API prototype
java/**
* Team profiles can be updated at a time, and the values of multiple fields can be updated.
*
* @return InvocationFuture You can set the callback feature to monitor the operation results
*/
InvocationFuture<Void> updateTeamFields(String teamId, Map<TeamFieldEnum, Serializable> fields);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
fields | New information about all fields to be updated. The value type must be consistent with fieldType defined in the field. |
- Example
java// Update the name, introduction, and announcement
Map<TeamFieldEnum, Serializable> fieldsMap = new HashMap<>();
fieldsMap.put(TeamFieldEnum.Name, "new name");
fieldsMap.put(TeamFieldEnum.Introduce, "new introduction");
fieldsMap.put(TeamFieldEnum.Announcement, "new announcement");
NIMClient.getService(superteamService.class).updateTeamFields(teamId,
fieldsMap).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void aVoid) {
// Success
}
@Override
public void onFailed(int i) {
// Failure
}
@Override
public void onException(Throwable throwable) {
// Error
}
});
Listening for team changes
The inter-process asynchronous call is required for acquiring team profile, so that developers must cache Team profile in the third-party APP, and then access the local cache to query team profile. SDK can inform registered observers of any change in team profile. At this time, the third-party app can update the cache and refresh the interface.
Listening for changes of team profiles
- API prototype
java/**
* Observer notification of changing Team profile Notifications of creating and updating the team are delivered through this interface
* @param observer, the parameter is the list of updated team profile
* @param register true indicates registered, and true indicates unregistered
*/
public void observeTeamUpdate(Observer<List<Superteam>> observer, boolean register);
- Example
java// Create Team profile change observer
Observer<List<Superteam>> teamUpdateObserver = new Observer<List<Superteam>>() {
@Override
public void onEvent(List<Superteam> teams) {
}
};
// Register or unregister the observer
NIMClient.getService(superteamServiceObserver.class).observeTeamUpdate(teamUpdateObserver, register);
Listen for changes of removing team
After successful operation, Team#isMyTeam will return "false".
- API prototype
java/**
* Observer notification of removing team This notification will be received when you quit a team, or when the team is dismissed, or when you are kicked out of the team
* @param observer, The isMyTeam interface of the team returns false when the parameter is the removed team profile
* @param register true indicates registered, and true indicates unregistered
*/
public void observeTeamRemove(Observer<Superteam> observer, boolean register);
- Example
java// Create the observer of removing the team. This notification will be received when you quit a team, or when you are kicked out of the team, or when the team is dismissed.
Observer<Superteam> teamRemoveObserver = new Observer<Superteam>() {
@Override
public void onEvent(Superteam team) {
// Since the interface may still need to display information such as the team name, the Team object will be returned in the parameters.
// The isMyTeam interface of this object returns false.
}
};
// Register or unregister the observer
NIMClient.getService(superteamServiceObserver.class).observeTeamRemove(teamRemoveObserver, register);
Team notifications
The message type of team notification is MsgTypeEnum.notification
. When the user is added to the team successfully, for any change about the team, including the operation of joining the team, the CommsEase server will send a team notification.
Operation events about superteam include:
Enumeration | Description |
---|---|
SUPER_TEAM_ADD_administrator | Superteam adds administrator. |
SUPER_TEAM_APPLY_PASS | Superteam passes team application. |
SUPER_TEAM_CHANGE_OWNER | Superteam changes owner. |
SUPER_TEAM_DISMISS | Superteam is dismissed. |
SUPER_TEAM_INVITE | Superteam invites members. |
SUPER_TEAM_INVITE_ACCEPT | Superteam approves team invitation. |
SUPER_TEAM_KICK | Superteam kicks members out of the team. |
SUPER_TEAM_LEAVE | Superteam members leave the team. |
SUPER_TEAM_MUTE_TLIST | Superteam mutes team members. |
SUPER_TEAM_REMOVE_administrator | Remove a superteam administrator |
SUPER_TEAM_UPDATE_T_INFO | Superteam updates team profile. |
For more information, see Team notification message.
Do Not Disturb
The message notification alert type can be configured for a specified team, including "all reminded" by default and "no alert" It cannot configure administrator message alert only.
- API prototype
java/**
* Set the specified team message notification type, view {@link com.netease.nimlib.sdk.team.constant.TeamMessageNotifyTypeEnum}
*
* @param teamId team ID
* @param notifyType notification type enumeration
* @return InvocationFuture you can set the callback feature to monitor the operation results
*/
InvocationFuture<Void> muteTeam(String teamId, TeamMessageNotifyTypeEnum notifyType);
- Parameters
Parameter | Description |
---|---|
teamId | Team ID |
TeamMessageNotifyTypeEnum | Notification type enum. Only "all reminded" and "no alert" are valid parameters. |
- Example
java// Take "no tip" as an example
TeamMessageNotifyTypeEnum type = TeamMessageNotifyTypeEnum.Mute;
NIMClient.getService(superteamService.class).muteTeam(teamId, type).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
// Successful
}
@Override
public void onFailed(int code) {
// Failed
}
@Override
public void onException(Throwable exception) {
// Error
}
});
The alert configuration can be acquired using getMessageNotifyType
interface of superteamService
.
Team search
Users can query ID list of specified teams.
- API prototype
java/**
* Reversely query the team ID by team name
*
* @param name team name
* @return team IDs
*/
InvocationFuture<List<String>> searchTeamIdByName(String name);
- Example
javaNIMClient.getService(superteamService.class).searchTeamIdByName("Superteam").setCallback(new RequestCallbackWrapper<List<String>>() {
@Override
public void onResult(int code, List<String> result, Throwable exception) {
if (code == ResponseCode.RES_SUCCESS) {
// Successful
} else {
// Failed. See the code for error code
}
if (exception != null) {
// error
}
}
});
Users can search all teams with matched keywords from the local clients:
java/**
* Reversely query the team ID by team name
*
* @param name The team name.
* @return the team ID.
*/
InvocationFuture<java.util.List<Team>> searchTeamsByKeyword(java.lang.String keyword);