Team

Update time: 2021/12/06 08:45:47

Overview

CommsEase SDK provides two team features: ordinary team and advanced team. The advanced team has more operation permissions, and The APIs are kept consistent under common operations. We recommend selecting either team type to develop your app. In principle, ordinary team and advanced team can not be interchanged, since their types have been confirmed at creation. After version SDK 2.4.0, an advanced team has all features of an ordinary team. We recommend selecting advanced team for development.

  • ordinary team - The ordinary team mentioned in development manual is equivalent to discussion group in Demo. Without operation authority, ordinary team applies to the scenario of quickly creating group session. Each ordinary team can only have one manager. The manager can add or remove team member and ordinary team members can only invite other users to the team. New members may be added without the consent of the others.
  • Advanced team - The advanced team has more restrictions in permissions (including team owner, manager, and team members).

Initialization parameters

Sample codes

javascriptvar nim = NIM.getInstance({
  onteams: onTeams,
  onsynccreateteam: onCreateTeam,
  onteammembers: onTeamMembers,
  //onsyncteammembersdone: onSyncTeamMembersDone,
  onupdateteammember: onUpdateTeamMember,
  shouldCountNotifyUnread: function (msg) {
    // Add filter based on msg attribute
    if (msg.something === someting) {
    return true
    }
  }
});
function onTeams(teams) {
  console.log('receive team list', teams);
  data.teams = nim.mergeTeams(data.teams, teams);
  onInvalidTeams(teams.invalid);
}
function onInvalidTeams(teams) {
  data.teams = nim.cutTeams(data.teams, teams);
  data.invalidTeams = nim.mergeTeams(data.invalidTeams, teams);
  refreshTeamsUI();
}
function onCreateTeam(team) {
  console.log('you created a team', team);
  data.teams = nim.mergeTeams(data.teams, team);
  refreshTeamsUI();
  onTeamMembers({
    teamId: team.teamId,
    members: owner
  });
}
function refreshTeamsUI() {
  // Refresh The API
}
function onTeamMembers(obj) {
  console.log('team id', teamId, 'team members', members);
  var teamId = obj.teamId;
  var members = obj.members;
  data.teamMembers = data.teamMembers || {};
  data.teamMembers[teamId] = nim.mergeTeamMembers(data.teamMembers[teamId], members);
  data.teamMembers[teamId] = nim.cutTeamMembers(data.teamMembers[teamId], members.invalid);
  refreshTeamMembersUI();
}
// function onSyncTeamMembersDone() {
//     console.log('synchronization of team member list completed');
// }
function onUpdateTeamMember(teamMember) {
  console.log('team member information is updated', teamMember);
  onTeamMembers({
    teamId: teamMember.teamId,
    members: teamMember
  });
}
function refreshTeamMembersUI() {
  // Refresh The API
}

Parameter description

  • onteams: It is the callback for synchronizing Team list, the array of teams will be input.
    • In teams, the attribute invalid contains exited teams.
    • It is an increment callback, nim.mergeTeams and nim.cutTeams can be invoked to merge data.
  • onsynccreateteam: If a team is created at other client by the current login account, this callback can be returned, Team object will be input.
  • onteammembers: It is a callback for synchronizing team members. A team corresponds to a callback, the array of team members will be input.
  • onsyncteammembersdone, Deprecated!: If members of all teams are synchronized, the callback will be invoked.
  • onupdateteammember: It is a callback after updating information of team members, the object Team members will be input. But the information is not complete and only contains updated fields. If the current login user updates his team attribute at other devicess, the callback will be returned.
  • onCreateTeam: It is a callback for creating a team. The API receives a parameter, including information of team and team owner.
  • onUpdateTeam: It is a callback for updating a team. The API receives a parameter, including updated team profile.
  • onAddTeamMembers: It is a callback for joining in a team for new members. The API receives a parameter, including information of team and team members.
  • onRemoveTeamMembers: It is a callback for leaving a team for some members. The API receives a parameter, including team profile and accounts of team members.
  • onUpdateTeamManagers: It is a callback for updating team administrator. The API receives a parameter, including information of team and team administrator.
  • onDismissTeam: It is a callback for dismissing a team. The API receives a parameter, including ID of a dismissed team.
  • onTransferTeam: It is a callback for transferring a team. The API receives a parameter, including information of team, previous and new team owner.
  • onUpdateTeamMembersMute: It is a callback for updating mute status of team members. The API receives a parameter, including information of team and mute status.
  • shouldCountNotifyUnread: It is a callback feature that determines whether team message tip is added to unread count. If "true" is returned, team message tip is included in unread count, otherwise, it is not included.

Team object

The team object contains fields shown as below:

  • teamId: Team ID
  • appId: ID of app covering the team
  • type: Type of team
  • name: Team name
  • avatar: Team avatar
  • intro: Team introduction
  • announcement: Team announcement
  • joinMode: Method of joining a team, only limited to advanced team
  • beInviteMode: Mode of being invited to a team, only limited to advanced team
  • inviteMode: Mode of team invitation, only limited to advanced team
  • updateTeamMode: Permission for updating team profile, only limited to advanced team
  • updateCustomMode: Permission for updating custom field of team profile, only limited to advanced team
  • owner: Team owner
  • level: Limit of team members
  • memberNum: The number of team members
  • memberUpdateTime: Final update time of team members
  • createTime: Creation time of team
  • updateTime: Final update time of team
  • custom: It is the third-party extension field, which can be extended independently by the developers. We recommend packing it into JSON character string.
  • serverCustom: It is the extension field of third-party server, which can be extended independently by developers. We recommend packing it into JSON character string.
  • valid: It determines validity. The team is invalid after being dismissed.
  • validToCurrentUser: It determines that whether the team is valid for current user. If it is invalid, the user is removed.
  • mute: It determines whether to mute. The team members cannot send any message under mute status.
  • muteType: Type of mute
    • none: None is muted.
    • ordinary: ordinary members have been muted, i.e. ordinary team members cannot send messages.
    • all: All members are muted, i.e. all members cannot send messages.

Team types

The field type under Team object is used to indicate team types. The detailed types are described as below:

  • 'ordinary' (ordinary team)
  • 'advanced' (Advanced team)

Method of joining a team

There are several methods of joining a team shown as below:

  • 'noVerify' (Verification is not required.)
  • 'needVerify' (Verification is required.)
  • 'rejectAll' (Any user is not allowed to join.)

Mode of inviting a team

There are several modes of inviting a team shown as below:

  • 'needVerify' (Approval of inviter is required.)
  • 'noVerify' (Approval of inviter is not required.)

Mode of team invitation

There are several modes of team invitation shown as below:

  • 'manager' (Only manager/team owner can invite other users to team)
  • 'all' (All members can invite other users to team)

Permission for updating team profile

There are several permissions for updating team profile shown as below:

  • 'manager' (Only manager/team owner can update team profile)
  • 'all' (All team members can update team profile)

Permission for updating custom field of team profile

There are several permissions for updating custom field of team profile shown as below:

  • 'manager' (Only manager/team owner can update team profile)
  • 'all' (All team members can update team profile)

Team member object

The team member object contains fields shown as below:

  • teamId: Team ID
  • account: Account
  • type: Type of team member
  • nickInTeam: Nickname in team
  • active: When a user is invited to an ordinary team, the user cannot see the team because the status is not activated. When a member sends a message, the user can see the team because the status is activated automatically.
  • joinTime: Join time
  • updateTime: Update time

Group member types

  • 'ordinary' (ordinary member)
  • 'owner': (Team owner)
  • 'manager' (Manager)

Create a team

  • For ordinary team, it is not available to set the Method of joining a team.
  • For advanced team, the Method of joining a team is set to 'needVerify' by default.
  • For advanced team, the Mode of being invited into a team is set to 'needVerify' by default.
  • For advanced team, the Mode of team invitation is set to 'manager' by default.
  • For advanced team, the Permission for updating team profile is set to 'manager' by default.
  • For advanced team, the Permission for updating custom field of team profile is set to 'manager' by default.
  • The creator of an ordinary team can see all members, but the invited member can see the team only when a member sends message in the team. The invited member will receive a Team notification message of 'addTeamMembers' type and then other team messages.
  • If an advanced team is invited, all team members will receive a System notification of 'teamInvite' type and can be seen in the team only after accepting invitation.
    • After accepting invitation, all team members will receive a Team notification message of 'acceptTeamInvite' type.
    • If a member rejects invitation, the team owner will receive a System notification of 'rejectTeamInvite' type.
  • level: (Optional) The maximum number of team members and also the limit of team members configured in current app. The designated limit of team members cannot exceed the limit of team members configured in current app; otherwise, the creation will fail, and related error code will be returned.
  • ps: It is postscript (optional). Developers can also extend the content with JSON character string
javascript// Create ordinary team
nim.createTeam({
  type: 'ordinary'
  name: "ordinary team"
  avatar: 'avatar'
  accounts: ['a1', 'a2'],
  level: 50,
  ps: 'I created an ordinary team',
  done: createTeamDone
});
// Create advanced team
nim.createTeam({
  type: 'advanced'
  name: 'Advanced team',
  avatar: 'avatar'
  accounts: ['a1', 'a2'],
  intro: 'Team introduction',
  announcement: 'Team announcement',
  joinMode: 'needVerify',
  beInviteMode: 'needVerify',
  inviteMode 'manager'
  updateTeamMode 'manager'
  updateCustomMode 'manager'
  level: 50,
  ps: 'I created an advanced team',
  custom: 'Team extension field, we recommend to encapsulate into JSON character string',
  done: createTeamDone
});
function createTeamDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('create ' + obj.team.type + 'team' + (!error?'succeeded':'failed));
  if (!error) {
    onCreateTeam(obj.team, obj.owner);
  }
}

Send team messages

When sending message in a team, you only need to replace scene at above-mentioned each "Send message" API with 'team' and replace to with Team ID.

Receive team messages

Refer to above-mentioned Receive message.

Update a team

javascriptnim.updateTeam({
  teamId: '123',
  name: 'Team name',
  avatar: 'avatar'
  intro: 'Team introduction',
  announcement: 'Team announcement',
  joinMode: 'needVerify',
  custom: 'Custom field',
  done: updateTeamDone
});
function updateTeamDone(error, team) {
  console.log(error);
  console.log(team);
  console.log('update team' + (!error?'succeeded':'failed'));
}

Invite a user to team

  • ordinary team
  • After the operation "Invite a user to team", all team members will receive a Team notification message of 'addTeamMembers' type. For such team notification message, the field from is account of the team inviter; the field to is the corresponding team ID; the field team under attach is the corresponding Team object; the field accounts under attach is the list of invited accounts; the field members under attach is the list of invited team members.
  • After owner and adiministor of a advanced team invite a user to join in their team (with Create a team or Invite a user to team), the invited user will receive a System notification of 'teamInvite' type System Notification. For such system notification, the field from is account of inviter; the field to is the corresponding team ID; and the field team under attach is the Team that is invited to join in. The invited user can accept or reject invitation.
    • If the invited user selects to "Accept invitation", all team members will receive a Team notification message of 'acceptTeamInvite' type. For such team notification message, the field from is account that accepts team invitation; the field to is the corresponding team ID; the field team under attach is the corresponding Team object; the field members under attach is the list of team members receiving team invitation.
    • If the invited user selects to "Reject invitation", the inviter will receive a System notification of 'rejectTeamInvite' type. For such system notification, the field from is account rejecting team invitation and the field to is the corresponding team ID.
  • teamId: Team ID
  • accounts: List of accounts that cannot be added to a team due to limitation in team quantity.
  • ps: It is postscript (optional). Developers can also extend the content with JSON character string
  • custom: It is custom extension field (optional) with max. 512 characters. Developers can also extend the content with JSON character string.
javascriptnim.addTeamMembers({
  teamId: '123',
  accounts: ['a3', 'a4'],
  ps: 'Jon our team’,
  custom: '',
  done: addTeamMembersDone
});
function addTeamMembersDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('send team invitation' + (!error?'succeeded':'failed'));
}

Remove a team member

  • After the operation "Kick out team member", all team members will receive a Team notification message of 'removeTeamMembers' type. For such team notification message, the field from is account of the team administrator who kicks members out of the team; the field to is the corresponding team ID; the field team under attach is the corresponding Team object; the field accounts under attach is the list of removed accounts.
javascriptnim.removeTeamMembers({
  teamId: '123',
  accounts: ['a3', 'a4'],
  done: removeTeamMembersDone
});
function removeTeamMembersDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('remove members' + (!error?'succeeded':'failed'));
}

Accept a team invitation

  • After team owner and adiministor of an advanced team invite a user to join their team (with Create a team or Invite a user to team), the invited user will receive a System notification of 'teamInvite' type. For such system notification, the field from is account of inviter; the field to is the corresponding team ID; and the field team under attach is the Team that is invited to join in. The invited user can accept or reject invitation.
    • If the invited user selects to "Accept invitation", all team members will receive a Team notification message of 'acceptTeamInvite' type. For such team notification message, the field from is account that accepts team invitation; the field to is the corresponding team ID; the field team under attach is the corresponding Team object; the field members under attach is the list of team members receiving team invitation.
    • If the invited user selects to "Reject invitation", the inviter will receive a System notification of 'rejectTeamInvite' type. For such system notification, the field from is account rejecting team invitation and the field to is the corresponding team ID.
  • The parameter from is account of inviter.
javascript// assumed sysMsg is system notification by calling back `onsysmsg`
nim.acceptTeamInvite({
  idServer: sysMsg.idServer,
  teamId: '123',
  from: 'zyy1',
  done: acceptTeamInviteDone
});
function acceptTeamInviteDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('accept team invitation' + (!error?'succeeded':'failed'));
}

Reject team invitation

  • After team owner and adiministor of an advanced team invite a user to join their team (with Create a team or Invite a user to team), the invited user will receive a System notification of 'teamInvite' type. For such system notification, the field from is account of inviter; the field to is the corresponding team ID; and the field team under attach is the Team that is invited to join in. The invited user can accept or reject invitation.
    • If the invited user selects to "Accept invitation", all team members will receive a Team notification messages of 'acceptTeamInvite' type. For such team notification message, the field from is account that accepts team invitation; the field to is the corresponding team ID; the field team under attach is the corresponding Team object; the field members under attach is the list of team members receiving team invitation.
    • If the invited user selects to "Reject invitation", the inviter will receive a System notification of 'rejectTeamInvite' type. For such system notification, the field from is account rejecting team invitation and the field to is the corresponding team ID.
  • The parameter from is account of inviter.
  • ps: It is postscript (optional). Developers can also extend the content with JSON character string
javascript// assumed sysMsg is system notification by calling back `onsysmsg`
nim.rejectTeamInvite({
  idServer: sysMsg.idServer,
  teamId: '123',
  from: 'zyy1',
  ps: 'No',
  done: rejectTeamInviteDone
});
function rejectTeamInviteDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('reject team invitation' + (!error?'succeeded':'failed'));
}

Apply for joining a team

  • A user can Apply for joining advanced team, owner and adiministor of the target team will receive a System notification of 'applyTeam' type. For such system notification, the field from is account of the applicant and field to is the corresponding team ID. After receiving the application for joining team, owner and adiministor of the advanced team can accept or reject the application.
    • If they "Accept team application", all team members will receive a Team notification message of 'passTeamApply' type. For such team notification message, the field from is account that accepts team application; the field to is the corresponding team ID; the field team under attach is the corresponding Team object; the field account under attach is account of the applicant; the field members under attach is the list of team members who are approved for team application.
    • If they "Reject a team application", the applicant will receive a System notification of 'rejectTeamApply' type. For such system notification, the field from is account that rejects team application; the field to is the corresponding team ID; the field team under attach is the corresponding Team.
  • ps: It is postscript (optional). Developers can also extend the content with JSON character string
javascriptnim.applyTeam({
  teamId: '123',
  ps: 'Add',
  done: applyTeamDone
});
function applyTeamDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('apply to join a team' + (!error?'succeeded':'failed'));
}

Approve team application

  • A user can Apply for joining advanced team, owner and adiministor of the target team will receive a System notification of 'applyTeam' type. For such system notification, the field from is account of the applicant and field to is the corresponding team ID. After receiving the application for joining team, owner and adiministor of the advanced team can accept or reject the application.
    • If they "Accept team application", all team members will receive a Team notification message of 'passTeamApply' type. For such team notification message, the field from is account that accepts team application; the field to is the corresponding team ID; the field team under attach is the corresponding Team object; the field account under attach is account of the applicant; the field members under attach is the list of team members who are approved for team application.
    • If they "Reject a team application", the applicant will receive a System notification of 'rejectTeamApply' type. For such system notification, the field from is account that rejects team application; the field to is the corresponding team ID; the field team under attach is the corresponding Team.
  • The parameter from is account of applicant, of which name is changed from account in v1.3.0 to from.
javascript// assumed sysMsg is system notification by calling back `onsysmsg`
nim.passTeamApply({
  idServer: sysMsg.idServer,
  teamId: '123',
  from: 'a2',
  done: passTeamApplyDone
});
function passTeamApplyDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('pass team invitation' + (!error?'succeeded':'failed'));
}

Reject joining a team

  • A user can Apply for joining advanced team, owner and adiministor of the target team will receive a System notification of 'applyTeam' type. For such system notification, the field from is account of the applicant and field to is the corresponding team ID. After receiving the application for joining team, owner and adiministor of the advanced team can accept or reject the application.
    • If they "Accept team application", all team members will receive a Team notification message of 'passTeamApply' type. For such team notification message, the field from is account that accepts team application; the field to is the corresponding team ID; the field team under attach is the corresponding Team object; the field account under attach is account of the applicant; the field members under attach is the list of team members who are approved for team application.
    • If they "Reject a team application", the applicant will receive a System notification of 'rejectTeamApply' type. For such system notification, the field from is account that rejects team application; the field to is the corresponding team ID; the field team under attach is the corresponding Team.
  • The parameter from is account of applicant, of which name is changed from account in v1.3.0 to from.
  • ps: It is postscript (optional). Developers can also extend the content with JSON character string
javascript// assumed sysMsg is system notification by calling back `onsysmsg`
nim.rejectTeamApply({
  idServer: sysMsg.idServer,
  teamId: '123',
  from: 'a2',
  ps: 'No',
  done: rejectTeamApplyDone
});
function rejectTeamApplyDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('reject application' + (!error?'succeeded':'failed'));
}

Add a team administrator

  • After the operation "Add team administrator", all Team members will receive a Team notification message of 'addTeamManagers' type. For such team notification message, the field from is account of the member who adds team administrator; the field to is the corresponding team ID; the field accounts under attach is the list of accounts added as administrators; the field members under attach is the list of team members added as administrators.
javascriptnim.addTeamManagers({
  teamId: '123',
  accounts: ['a2', 'a3'],
  done: addTeamManagersDone
});
function addTeamManagersDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('add team administrator' + (!error?'succeeded':'failed'));
}

Remove a team administrator

  • After the operation "Remove team administrator", all Team members will receive a Team notification message of 'removeTeamManagers' type. For such team notification message, the field from is account of the administrator who removes team administrator; the field to is the corresponding team ID; the field accounts under attach is the list of accounts of removed administrators; the field members under attach is the list of members in the team where manager is removed.
javascriptnim.removeTeamManagers({
  teamId: '123',
  accounts: ['a2', 'a3'],
  done: removeTeamManagersDone
});
function removeTeamManagersDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('remove team administrator' + (!error?'succeeded':'failed'));
}

Leave a team

javascriptnim.leaveTeam({
  teamId: '123',
  done: leaveTeamDone
});
function leaveTeamDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('actively leave team' + (!error?'succeeded':'failed'));
}

Transfer a team

  • After the operation "Transfer a team", all Team members will receive a Team notification message of 'transferTeam' type. For such team notification message, the field from is account of the member who transfers team; the field to is corresponding team ID; the field team under attach is corresponding Team object; the field account under attach is account of the new owner; the field members under attach is the list of team members (including original and new owner).
  • If a member transfers and then leaves the team, it is equivalent to invoke The API "Actively leave team" to leave the team, and all Team members will receive a Team notification message of 'leaveTeam' type.
javascriptnim.transferTeam({
  teamId: '123',
  account: 'zyy2',
  leave: false,
  done: transferOwnerDone
});
function transferOwnerDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('change team owner + (!error?'succeeded':'failed'));
}

Dismiss a team

  • After the operation "Dismiss a team", all Team members will receive a Team notification message of 'dismissTeam' type. For such team notification message, the field from is account of member who dismisses the team; the field to is corresponding team ID.
javascriptnim.dismissTeam({
  teamId: '123',
  done: dismissTeamDone
});
function dismissTeamDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('dismiss team' + (!error?'succeeded':'failed'));
}

Update my team attribute

The attributes that can be updated now include:

  • nickInTeam: It means member nickname in team
    • If a member updates his nickname in team, all other online Team members will receive the callback onupdateteammember that is input at the operation "Initialize SDK".
  • muteTeam: It sets to close message tip of the team. true means to close tip, but SDK will still receive the team message because SDK just records the configuration and the third-party APP determines to execute the configured operation. After configuration, The API Need team message tip can be invoked to query whether team notification tip is required.
  • muteNotiType: It is added in v4.3.0 and extended with muteTeam attribute which is not available for old version. If both muteTeam and muteNotiType are defined, muteNotiType is preferred. 0 is to accept tip; 1 is to close tip; 2 is to accept manager tip only.
  • custom: It is the third-party extension field, which can be extended independently by the developers. We recommend packing it into JSON character string.
javascriptnim.updateInfoInTeam({
  teamId: '123',
  // This parameter is optional
  // nickInTeam: 'Team nickname',
  // Team mute, this parameter is optional
  // muteTeam: true,
  muteNotiType 1,
  // Third-party extension field
  // custom: '{}'
  done: updateInfoInTeamDone
});
function updateInfoInTeamDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('modify my team attribute' + (!error?'succeeded':'failed'));
}

Update nicknames of other members in team

javascriptnim.updateNickInTeam({
  teamId: '123',
  account: 'a2',
  nickInTeam 'Team nickname',
  done: updateNickInTeamDone
});
function updateNickInTeamDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('modify my team attribute' + (!error?'succeeded':'failed'));
}

Update mute status of team members

  • After the operation "Update mute status of team members", all Team members will receive a Team notification message of 'updateTeamMute' type. For such team notification message, the field from is operator; the field to is the corresponding team ID; the field team under attach is the corresponding Team object; the field account under attach is muted account; the field members under attach is the list of muted team members.
javascriptnim.updateMuteStateInTeam({
  teamId: '123',
  account: 'a',
  mute true,
  done: updateMuteStateInTeamDone
})
function updateMuteStateInTeamDone(error, obj) {
  console.log('update team member mute status' + (!error?'succeeded':'failed'), error, obj);
}

Get the list of muted team members

javascriptnim.getMutedTeamMembers({
  teamId: teamId,
  done: getMutedTeamMembersDone
})
function getMutedTeamMembersDone (error, obj) {
  console.log('get a list of muted team members' + (!error?'succeeded':'failed'))
  console.log(obj);
}

Mute all team members

  • Only the team owner has the permission of global mute for a team. Once the team is muted, them all team members are muted.
  • Parameters of request:
    • teamId: ID of team to be muted
    • type: Type of mute
      • none: Dismiss mute
      • ordinary: ordinary team members are muted.
      • all: All members (including manager) are muted. It cannot be invoked from client and can be invoked with server api only.
  • Update status:
    • The two fields in returned team attributes are provided for developers to make determination:
      • team.mute is true/false. It determines whether a team is muted.
      • team.muteType Type of team mute none/ordinary/all
javascript  nim.muteTeamAll({
    teamId: teamId,
    type: 'none',
    done: muteTeamAllDone
  })
  function muteTeamAllDone (error, obj) {
    console.log('Mute team:' + (!error?'succeeded':'failed'))
    console.log(obj);
  }

Get team

  • Developers can invoke The API to get team profile.
javascriptnim.getTeam({
  teamId: '123',
  done: getTeamDone
});
function getTeamDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('get team' + (!error?'succeeded':'failed'));
}

Get list of teams

  • If developers set syncTeams to false at the operation "Initialize SDK", then they cannot receive the callback onteams, but can invoke this API to get the list of Teams.
javascriptnim.getTeams({
  done: getTeamsDone
});
function getTeamsDone(error, teams) {
  console.log(error);
  console.log(teams);
  console.log('get team list' + (!error?'succeeded':'failed'));
  if (!error) {
    onTeams(teams);
  }
}

Get team members

javascriptnim.getTeamMembers({
  teamId: '123',
  done: getTeamMembersDone
});
function getTeamMembersDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('get team members' + (!error?'succeeded':'failed'));
  if (!error) {
    onTeamMembers(obj);
  }
}

Get information of team members by team ID and member account

  • You can designate a certain member of a team and get the latest information of team members. This API makes a filtration based on The API Get team members.
javascriptnim.getTeamMemberByTeamIdAndAccount({
  teamId: '123',
  account: 'abc',
  done: getTeamMemberDone
});
function getTeamMemberDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('get team members' + (!error?'succeeded':'failed'));
  if (!error) {
    onTeamMember(obj);
  }
}

Get inviter accid of team members

  • Parameters of request:
    • teamId Team ID
    • accounts: It is the list of accounts of team members for querying inviter accid. At most 200 members can be queried for once. If the number of team members is lower than and equal to 200, it is an optional parameter. All members are queried by default if it is not filled in. If the number of team members is larger than 200, The API shall be invoked repeatedly to query the list of members by batch.
    • done is the callback feature of results, of which returned data type of "Object"; "key" and "value" are team member accid and inviter accid, respectively.
javascriptnim.getTeamMemberInvitorAccid({
  teamId: '123',
  account: ['abc', 'def'],
  done: getTeamMemberInvitorAccidDone
});
function getTeamMemberInvitorAccidDone(error, obj) {
  console.log(error);
  console.log(obj);
  console.log('get team member inviter' + (!error?'succeeded':'failed'));
}

Need team message tip

  • You can query that team message tip is needed with this API.
  • If it is successful, the second parameter of above callback feature is "map". "key" is team ID and "value" is Boolean value which indicates the need of team message tip (0 is to accept top; 1 is to close tip; 2 is to receive manager tip only).
  • If it is partially successful, the second parameter of above callback feature is also "map"; the third parameter is ID array of failed team; the first parameter is cause of failure.
  • The API Update my team attribute is invoked to disable or enable message tip of a team.
  • The team message tip at web client will not be changed by configured team message tip. The detailed code for disabling and enabling team message tip shall be designed and added by users based on app scene and service logics.
javascriptnim.notifyForNewTeamMsg({
  teamIds: ['123'],
  done: notifyForNewTeamMsgDone
})
function notifyForNewTeamMsgDone(error, map) {
  console.log(error);
  console.log(map);
  console.log('query whether team message notification is required' + (!error?'succeeded':'failed'));
}

Read tip for team message

  • For team message configured with the field needMsgReceipt (i.e. "Need acknowledged receipt"), when the client is online, related read tip can be returned from the receiver, with tip format as below:
javascript  {
    teamMsgReceipts: [
      {
        account: "cs3",
        idClient: "5b77d3ff7eb06af5567f56647518694b",
        idServer: "68953284018340",
        read: "1",
        teamId: "1027484",
        unread: "1"
      }
    ]
  • The acknowledged receipt service is required to send message. Please refer to Type of message
javascript  NIM.getInstance({...})
    // ...
    onTeamMsgReceipt, onTeamMsgReceipt:
  })
  function onTeamMsgReceipt (obj) {
    console.log(obj);
  }

Mark team message as read

  • If a team message is configured with the field needMsgReceipt when being sent, the receiver can return acknowledged receipt for the message
  • The acknowledged receipt of multiple teams and messages can be sent with The API. Notes: The limit of elements in parameter teamMsgReceipts is 50.
  • Parameters of request:
    • teamMsgReceipts: It is the list of message configurations requiring receipt
    • teamMsgReceipt.teamId Team ID
    • teamMsgReceipt.idServer: serverid of message
    • done Callback function
  • Results of callback:
    • error: It is the first parameter. If it is null, this means it is successful
    • obj: It is the second parameter which is sent for verification
    • content: It is the third parameter
      • content.teamMsgReceipts: List of failed accounts
javascript  nim.sendTeamMsgReceipt({
    teamMsgReceipts: [{
      teamId: '1027484',
      idServer: '68953284018302'
    }],
    done: sendTeamMsgReceiptDone
  })
  function sendTeamMsgReceiptDone (error, obj, content) {
    console.log('mark team message as read' + (!error?'succeeded':'failed'));
  }

Query read and unread count of team messages

  • If a team message is configured with the field needMsgReceipt when being sent, the receiver can return acknowledged receipt for the message
  • You can query read and unread count of team messages and send multiple team message configurations with The API. Notes: The limit of elements in parameter teamMsgReceipts is 50.
  • Parameters of request:
    • teamMsgReceipts: It is the list of message configurations requiring receipt
    • teamMsgReceipt.teamId Team ID
    • teamMsgReceipt.idServer: serverid of message
    • done Callback function
  • Results of callback:
    • error: It is the first parameter. If it is null, this means it is successful
    • obj: It is the second parameter which is sent for verification
    • content: It is the third parameter for querying results
      • If it is the result of multiple team messages, array sequence teamMsgReceipts of the field is consistent with queried configuration
javascript  nim.getTeamMsgReads({
    teamMsgReceipts: [{
      teamId: '1027484',
      idServer: '68953284018302'
    }],
    done: getTeamMsgReadsDone
  })
  function getTeamMsgReadsDone (error, obj, content) {
    console.log('get team message read + (!error?'succeeded':'failed'));
    /* content.teamMsgReceipts
      [ {
        idClient: "c7575fca32bf142787986e752fdeff6a"
        idServer: "68527276949899"
        read: "0"
        teamId: "1021136"
        unread: "187"
      } ]
    */

Query list of unread accounts for team message

  • If a team message is configured with the field needMsgReceipt when being sent, the receiver can return acknowledged receipt for the message
  • You can query the list of unread accounts for team message with The API and then send configurations
  • Parameters of request:
    • teamMsgReceipt: It is the message configuration requiring receipt
    • teamMsgReceipt.teamId Team ID
    • teamMsgReceipt.idServer: serverid of message
    • done Callback function
  • Results of callback:
    • error: It is the first parameter. If it is null, this means it is successful
    • obj: It is the second parameter which is sent for verification
    • content: It is the third parameter, i.e. list of accounts
      • idClient: idClient of message
      • readAccounts: List of read accounts
      • unreadAccounts: List of unread accounts
javascript  nim.getTeamMsgReadAccounts({
    teamMsgReceipt {
      teamId: '1027484',
      idServer: '68953284018302'
    },
    done: getTeamMsgReadAccountsDone
  })
  function getTeamMsgReadAccountsDone (error, obj, content) {
    console.log('get team message read + (!error?'succeeded':'failed'));
    /* content.teamMsgReceipt
      idClient: "c7575fca32bf142787986e752fdeff6a",
      readAccounts Array[],
      unreadAccounts Array[]
    */
Was this page helpful?
Yes
No
  • Overview
  • Initialization parameters
  • Team object
  • Team types
  • Method of joining a team
  • Mode of inviting a team
  • Mode of team invitation
  • Permission for updating team profile
  • Permission for updating custom field of team profile
  • Team member object
  • Group member types
  • Create a team
  • Send team messages
  • Receive team messages
  • Update a team
  • Invite a user to team
  • Remove a team member
  • Accept a team invitation
  • Reject team invitation
  • Apply for joining a team
  • Approve team application
  • Reject joining a team
  • Add a team administrator
  • Remove a team administrator
  • Leave a team
  • Transfer a team
  • Dismiss a team
  • Update my team attribute
  • Update nicknames of other members in team
  • Update mute status of team members
  • Get the list of muted team members
  • Mute all team members
  • Get team
  • Get list of teams
  • Get team members
  • Get information of team members by team ID and member account
  • Get inviter accid of team members
  • Need team message tip
  • Read tip for team message
  • Mark team message as read
  • Query read and unread count of team messages
  • Query list of unread accounts for team message