new connection(options) → {Class}
Class connection, Used to initialize the SDK
Example
const connt new connection({appKey: 'yourAppKey', isHttpDNS: true, https: true, autoReconnectNumMax: 5, delivery: false})
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Connection instance
- Type
- Class
Methods
acceptInvitation(to)
Accepting friend request
Example
connection.acceptInvitation('user1')
Parameters:
Name | Type | Description |
---|---|---|
to |
String | The user ID of the other party |
Returns:
Void
addContact(to, message)
add friend
Example
connection.addContact('user1', 'I am Bob')
Parameters:
Name | Type | Description |
---|---|---|
to |
String | The user ID of the other party |
message |
String | Validation message (not required) |
Returns:
Void
addToBlackList(options)
Add friends to your blacklist
Example
connection.addToBlackList({name: 'user1'}) | addToBlackList({name: ['user1', 'user2']})
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Void
addUsersToChatRoom()
Add chat room members
Example
connection.addUsersToChatRoom({chatRoomId: "chatRoomId", users:['user1', 'user2']})
Parameters:
Name | Type | Description |
---|---|---|
opt.chatRoomId |
string | Chat room id |
opt.users |
Array.<string> | User ID array |
opt.success |
function | |
opt.error |
function |
Returns:
Promise
addUsersToChatRoomWhitelist(opt)
Add group whitelist member, Operation authority: Group admin or above
Example
connection.addUsersToGroupWhitelist({groupId: 'groupId'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
addUsersToGroupWhitelist(opt)
Add group whitelist member, Members of the white list can continue to speak after the group bans. Operation authority: Group admin or above, Users added to the whitelist will receive type: 'addusertogroupwhitelist' in the callback of onPresence
Example
connection.addUsersToGroupWhitelist({groupId: 'groupId'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
agreeInviteIntoGroup(opt)
Agree to group invitation. Other people invite you to join the group, you can call this API to agree. The inviter will receive type: 'invite_accept' in the callback of onPresence, After joining successfully, group members will receive type: 'memberjoinpublicgroupsuccess' in the callback of onPresence
Example
connection.agreeInviteIntoGroup({invitee: 'myUserId', groupId: 'groupId'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
agreeJoinGroup(opt)
Allow users to join the group. Group owner or administrator permissions are required. Users who join the group will receive type: 'joinpublicgroupsuccess' in the callback of onPresence
Example
connection.agreeJoinGroup({applicant: 'user1', groupId: 'groupId'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
blockGroup(opt)
- Since:
- 1.4.11
Block group messages, Only valid for mobile terminal
Example
connection.blockGroup({groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
changeOwner(opt)
To transfer a group, you need the permission of the group owner. Group members will receive type: 'changeowner' in the onpresence callback
Example
connection.changeOwner({groupId: 'groupId', newOwner: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object |
Properties
|
Returns:
Promise
chatRoomBlockMulti(opt)
Batch add users to the chat room blacklist, Administrator rights required
Example
connection.chatRoomBlockMulti({usernames: ['user1', 'user2'], chatRoomId: 'chatRoomId'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
chatRoomBlockSingle(opt)
Add single user to chat room blacklist, Administrator rights required
Example
connection.chatRoomBlockSingle({chatRoomId: 'chatRoomId', username: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
close()
Disconnect
Example
connection.close()
Returns:
void
createChatRoom(options)
Create a chat room
Example
connection.createChatRoom({name: 'myChatRoom', description: 'this is my chatroom', maxusers: 200, members; ['user1']}):Promise
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
createGroupNew(opt)
- Since:
- 1.4.11
Create group
Example
connection.createGroupNew({
data: {
groupname: 'groupname',
desc: 'this is my group',
members: ['user1', 'user2'],
public: true,
approval: false,
allowinvites: true,
inviteNeedConfirm: false
}
})
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
declineInvitation(to)
Reject Friend Request
Example
connection.declineInvitation('user1')
Parameters:
Name | Type | Description |
---|---|---|
to |
String | The user ID of the other party |
Returns:
Void
deleteChatRoomSharedFile(options)
Delete chat room shared files
Example
connection.deleteChatRoomSharedFile({roomId: 'roomId', fileId: 'fileId'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
deleteContact(to)
Delete friend
Example
connection.deleteContact('user1')
Parameters:
Name | Type | Description |
---|---|---|
to |
String | The user ID of the other party |
Returns:
Void
deleteGroupSharedFile(options)
Delete group shared files
Example
connection.deleteGroupSharedFile({groupId: 'groupId', fileId: 'fileId'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
destroyChatRoom(options)
Deletes the chat room
Example
connection.destroyChatRoom({chatRoomId: 'chatRoomId'}):Promise
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
disableSendChatRoomMsg(opt)
All chat room members are prohibited from speaking. Operation permissions: group admin or above identity
Example
connection.disableSendChatRoomMsg({chatRoomId: 'chatRoomId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
disableSendGroupMsg(opt)
All group members are prohibited from speaking, Operation permissions: group admin or above identity, Group members will receive type: 'muteGroup' in the onPresence callback.
Example
connection.disableSendGroupMsg({groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
dissolveGroup(opt)
To dissolve a group, you need the permission of the group owner. Group members will receive type: 'deletegroupchat' in the callback of onPrenscence
Example
connection.dissolveGroup({groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
downloadChatRoomSharedFile(options)
Download the chat room to share files
Example
connection.downloadChatRoomSharedFile({roomId: 'roomId', fileId: 'fileId', onFileDownloadComplete: onFileDownloadComplete, onFileDownloadError: onFileDownloadError})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Void
downloadGroupSharedFile(options)
Download the group shared file
Example
connection.downloadGroupSharedFile({groupId: 'groupId', fileId: 'fileId', onFileDownloadComplete: onFileDownloadComplete, onFileDownloadError: onFileDownloadError})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Void
enableSendChatRoomMsg(opt)
Remove chat room bans. Operation permissions: chat room admin or above identity
Example
connection.enableSendChatRoomMsg({chatRoomId: 'chatRoomId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
enableSendGroupMsg(opt)
Remove group bans. Operation permissions: group admin or above identity, Group members will receive type: 'rmgroupmute' in the callback of onpresence
Example
connection.enableSendGroupMsg({groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
fetchChatRoomAnnouncement(options)
Get chat announcement
Example
connection.fetchChatRoomAnnouncement({roomId: 'roomId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
fetchChatRoomSharedFileList(options)
Gets a list of shared files in the chat room
Example
connection.fetchChatRoomSharedFileList({roomId: 'roomId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
fetchGroupAnnouncement(options)
Get group announcement
Example
connection.fetchGroupAnnouncement({groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
fetchGroupSharedFileList(options)
Gets a list of group shared files
Example
connection.fetchGroupSharedFileList({groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
fetchHistoryMessages(options)
Get historical messages
Example
connection.fetchHistoryMessages({queue:'user1', count: 20}):Promise
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Returns:
Promise
fetchUserInfoById(userId)
Query user information
Example
connection.fetchUserInfoById('user1') | fetchUserInfoById(['user1', 'user2'])
Parameters:
Name | Type | Description |
---|---|---|
userId |
String | Array | User id |
Returns:
Promise
getBlacklist(options)
Get friends blacklist
Example
connection.getBlacklist()
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
getChatRoomAdmin(opt)
Get all administrators in chat room
Example
connection.getChatRoomAdmin({chatRoomId: 'chatRoomId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
getChatRoomBlacklistNew(opt)
Get chat room blacklist
Example
connection.getChatRoomBlacklistNew({chatRoomId: 'chatRoomId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
getChatRoomDetails(options)
Gets the chat room details
Example
connection.getChatRoomDetails({chatRoomId: 'chatRoomId'}):Promise
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
getChatRoomMuted(opt)
Get all members banned in the chat room
Example
connection.getChatRoomMuted({chatRoomId: 'chatRoomId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
getChatRooms(options)
Get chat room list (paging)
Example
connection.getChatRooms({pagenum: 1, pagesize: 20}):Promise
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Returns:
Promise
getChatRoomWhitelist(opt)
Get white chat room white list, Operation authority: admin or above
Example
connection.getChatRoomWhitelist({chatRoomId: 'chatRoomId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
getGroup(opt)
- Since:
- 1.4.11
Lists all the groups a user has joined
Example
connection.getGroup()
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
getGroupAdmin(opt)
- Since:
- 1.4.11
Get all administrators in the group
Example
connection.getGroupAdmin({groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
getGroupBlacklistNew(opt)
Get group blacklist
Example
connection.getGroupBlacklistNew({groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
getGroupInfo(opt)
- Since:
- 1.4.11
Get group details
Example
connection.getGroupInfo({groupId: groupId})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
getGroupMsgReadUser(options)
Query which users have read group message [Value-added function] needs to be opened separately
Example
connection.getGroupMsgReadUser({groupId: 'groupId', msgId: 'msgId'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
getGroupWhitelist(opt)
Get group white list, Operation authority: admin or above
Example
connection.getGroupWhitelist({groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
getMuted(opt)
Get all banned members of the group
Example
connection.getMuted({groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
getRoster(options)
Get contacts
Example
connection.getRoster()
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
getSessionList()
Get the session list
Example
connection.getSessionList()
Parameters:
Name | Type | Description |
---|---|---|
options.success |
function | 成功之后的回调,默认为空 |
options.error |
function | 失败之后的回调,默认为空 |
Returns:
Promise
getUniqueId() → {Number}
Randomly generate an ID for the message ID
Example
const msgid = connection.getUniqueId()
Returns:
id
- Type
- Number
groupBlockMulti(opt)
Batch add users to the group blacklist, Administrator rights required,Users added to the blacklist will receive type: 'removedFromGroup' in the onPresence callback.
Example
connection.groupBlockMulti({usernames: ['user1', 'user2'], groupId: 'groupId'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
groupBlockSingle(opt)
Add a single user to the group blacklist, Group owner or administrator permissions are required, Users added to the blacklist will receive type: 'removedFromGroup' in the onPresence callback.
Example
connection.groupBlockSingle({groupId: 'groupId', username: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
inviteToGroup(opt)
Invite group members. The invited user will receive type: 'invite' in the callback of onPresence
Example
connection.inviteToGroup({groupId: 'groupId', users: ['user1', 'user2']})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
isGroupWhiteUser(opt)
Query whether group members are white list users, Operation permission: app admin can query all users; App users can query themselves
Example
connection.isGroupWhiteUser({groupId: 'groupId', userName: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
joinChatRoom(options)
Join chat room, After joining successfully, others will receive type: 'memberjoinchatroomsuccess' in the onPresence callback
Example
connection.joinChatRoom({roomId: 'roomId'})
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
||||||
opt.message |
stirng | Reason, optional (not enabled in chat room) | ||||||
options.success |
function | |||||||
options.error |
function |
Returns:
Promise
joinGroup(opt)
- Since:
- 1.4.11
Apply for group membership, The group owner and administrator receive type: 'joingroupnotifications' in the onPresence callback
Example
connection.joinGroup({groupId: 'groupId', message: 'I want to join the group'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
listChatRoomMember(opt)
List all chat room members (paginated)
Example
connection.listChatRoomMember({pageNum: 1, pageSize: 20, chatRoomId: 'chatRoomId'})
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
listen(options)
Register listener function
Example
connection.listen({onOpened: onOpened, ...})
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Void
listGroupMember(opt)
Lists all members of the group (paginated)
Example
connection.listGroupMember({pageNum: 1, pageSize: 20, groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
listGroups(opt)
- Since:
- 1.4.11
Get public groups (paginated)
Example
connection.listGroups({limit: 20, cursor: null})
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
modifyChatRoom(options)
Modify chat room details
Example
connection.modifyChatRoom({chatRoomId: 'chatRoomId', chatRoomName: 'chatRoomName', description:'description', maxusers: 5000})
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
modifyGroup(opt)
Modify group information,Administrator rights required
Example
connection.modifyGroup({groupId: 'groupId', groupName: 'groupName', description:'description'})
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
mute(opt)
- Since:
- 1.4.11
Group user is not allowed to speak,Group owner or administrator permissions are required,Forbidden users and other users will receive type: 'addmute' in the onPresence callback
Example
connection.mute({username: 'user1', muteDuration: '-1000', groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
muteChatRoomMember(opt)
- Since:
- 1.4.11
Chat room users are prohibited from speaking, Administrator rights required, Forbidden users and other users will receive type: 'addmute' in the onPresence callback
Example
connection.muteChatRoomMember({username: 'user1', muteDuration: -1000, chatRoomId: 'chatRoomId'})
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
open(options)
Login
Example
connection.open({user: 'user1', pwd: '123456', appKey: 'yourAppKey'})
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Void
quitChatRoom(options)
Exit chat room, others will receive type: 'leaveChatRoom' in the onPresence callback
Example
connection.quitChatRoom({roomId: 'roomId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
quitGroup(opt)
Leave the group, group members will receive type: 'leavegroup' in the callback of onPresence
Example
connection.quitGroup({groupId: 'groupId'})
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
recallMessage(option)
Recall a message
Example
connection.recallMessage({mid: 'messageId', to: 'user1', type: 'chat', success: success, fail: fail})
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
option |
Object | -
Properties
|
Returns:
Void
registerUser(options)
Register new user
Example
registerUser({username: 'user1', password: '123456', nickname: 'Tom'})
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
rejectInviteIntoGroup(opt)
Refuse group invitation, Other user invite you to join the group, you can call this API to refuse
Example
connection.rejectInviteIntoGroup({invitee: 'myUserId', groupId: 'groupId'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
rejectJoinGroup(opt)
Refuse user to join the group, Group owner or administrator permissions are required
Example
connection.rejectJoinGroup({applicant: 'user1', groupId: 'groupId', reason: 'I do not like you'})
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
removeAdmin(opt)
To cancel the group administrator, you need the permission of the group master. The user whose administrator is canceled will receive type: 'removeadmin' in the callback of onPresence
Example
connection.removeAdmin({gorupId: 'gorupId', username: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
removeChatRoomAdmin(opt)
To cancel the chat room administrator, you need the permission of APP admin. The user whose administrator is canceled will receive type: 'removeadmin' in the callback of onPresence
Example
connection.removeChatRoomAdmin({chatRoomId: 'chatRoomId', username: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
removeChatRoomBlockMulti(opt)
Batch remove users from chat room blacklist, Administrator rights required
Example
connection.removeChatRoomBlockMulti({chatRoomId: 'chatRoomId', usernames: ['user1', 'user2']})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
removeChatRoomBlockSingle(opt)
Remove individual user from chat room blacklist,Administrator rights required
Example
connection.removeChatRoomBlockSingle({chatRoomId: 'chatRoomId', username: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
removeFromBlackList(options)
Remove friends from your blacklist
Example
connection.removeFromBlackList({name: 'user1'})
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Void
removeGroupBlockMulti(opt)
Batch to remove users from group blacklists, Group owner or administrator permissions are required, Users who have been removed from the blacklist will receive type: 'allow' in the onPresence callback
Example
connection.removeGroupBlockMulti({groupId: 'groupId', usernames: ['user1', 'user2']})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
removeGroupBlockSingle(opt)
Remove single user from group blacklist, Administrator rights required, Users who have been removed from the blacklist will receive type: 'allow' in the onPresence callback
Example
connection.removeGroupBlockSingle({groupId: 'groupId'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
removeMultiChatRoomMember(opt)
Delete multiple chat room members
Example
connection.removeMultiChatRoomMember({chatRoomId: 'chatRoomId', users: ['user1', 'user2']})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
removeMultiGroupMember(opt)
Delete multiple group members. Group owner or administrator permissions are required. The removed users will receive type: 'removedfromgroup' in the callback of onPresence, and other group members will receive type: 'leavegroup' in the callback of onPresence
Example
connection.removeMultiGroupMember({groupId: 'groupId', users: ['user1', 'user2']})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
removeMute(opt)
- Since:
- 1.4.11
Remove the ban on group member, Group owner or administrator permissions are required. Users who have been released and other users will receive type: 'removemute' in the callback of onPresence
Example
connection.removeMute({groupId: 'groupId', username: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
removeMuteChatRoomMember(opt)
- Since:
- 1.4.11
Remove the ban on chat room member, Administrator rights required, Unbanned users and other users will receive type: 'removeMute' in the onPresence callback
Example
connection.removeMuteChatRoomMember({chatRoomId: 'chatRoomId', username: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
removeSingleChatRoomMember(opt)
Delete individual chat room members
Example
connection.removeSingleChatRoomMember({chatRoomId: 'chatRoomId', username: 'username'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
removeSingleGroupMember()
Delete individual group member. Group owner or administrator permissions are required. The removed user will receive type: 'removedfromgroup' in the callback of onPresence, and other group members will receive type: 'leavegroup' in the callback of onPresence
Example
connection.removeSingleGroupMember({groupId: 'groupId', username: 'user1'})
Parameters:
Name | Type | Description |
---|---|---|
opt.groupId |
string | Group id |
opt.username |
string | User id |
opt.success |
function | |
opt.error |
function |
Returns:
Promise
rmUsersFromChatRoomWhitelist(opt)
Remove chatroom whitelist members, Operation permissions: ADMIN and above identity, Deleted white list of users will be received in onPresence callback type: 'rmUserFromChatRoomWhiteList'
Example
connection.rmUsersFromChatRoomWhitelist({chatRoomId: 'chatRoomId', userName: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
rmUsersFromGroupWhitelist(opt)
Remove group whitelist members, Operation permissions: group admin or above identity, The user whose whitelist is removed will receive type:'rmUserFromGroupWhiteList' in the onPresence callback.
Example
connection.rmUsersFromGroupWhitelist({groupId: 'groupId', userName: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
send(messageSource)
Send message
Example
let deliverMessage = new WebIM.message('delivery', msgId);
deliverMessage.set({
id: msgId,
to: msg.from
});
connection.send(deliverMessage.body);
Parameters:
Name | Type | Description |
---|---|---|
messageSource |
Object | Generated by Class Message |
Returns:
Void
setAdmin(opt)
Set up group administrator, need group owner authority. Users who are set as administrators will receive type: 'addadmin' in the onPresence callback
Example
connection.setAdmin({groupId: 'groupId', username: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
setChatRoomAdmin(opt)
Setting up chat room administrator needs app admin permission. Users who are set as administrators will receive type: 'addadmin' in the onPresence callback
Example
connection.setChatRoomAdmin({chatRoomId: 'chatRoomId', username: 'user1'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object | -
Properties
|
Returns:
Promise
updateChatRoomAnnouncement(options)
Update chat room announcement
Example
connection.updateChatRoomAnnouncement({roomId: 'roomId', announcement: 'hello'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
updateCurrentUserNick(nick)
When registering, you can set a nickname, which is used to display when pushing messages. You can call the following API to modify the nickname
Example
connection.updateCurrentUserNick('Tom')
Parameters:
Name | Type | Description |
---|---|---|
nick |
String | 昵称 |
Returns:
Promise
updateGroupAnnouncement(options)
Update group announcement
Example
connection.updateGroupAnnouncement({groupId: 'groupId', announcement: 'hello'})
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
updateOwnUserInfo(options)
Update own information
Example
connection.updateOwnUserInfo({nickname: 'Tom', avatarurl: 'avatarurl', mail: 'abc@gmail,com', ext: JSON.stringify({hobby: 'football'})})
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise
uploadChatRoomSharedFile(options)
Upload chat rooms to share files
Example
connection.uploadChatRoomSharedFile({roomId: 'roomId', file: 'file object', onFileUploadProgress: onFileUploadProgress, onFileUploadComplete: onFileUploadComplete,onFileUploadError:onFileUploadError,onFileUploadCanceled:onFileUploadCanceled})
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Void
uploadGroupSharedFile(options)
Upload group shared files
Example
connection.uploadGroupSharedFile({groupId: 'groupId', file: 'file object', onFileUploadProgress: onFileUploadProgress, onFileUploadComplete: onFileUploadComplete,onFileUploadError:onFileUploadError,onFileUploadCanceled:onFileUploadCanceled})
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Void
uploadToken(options)
If you use the SDK on a native client and integrate third-party push functionality, you can call this method to upload the Token to the server
Example
connection.uploadToken({deviceId: 'deviceId', deviceToken: 'deviceToken', notifierName: 'notifierName'})
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
Promise