The following are the parameters of NIM.getInstance. Here are only some callback functions. For the complete list of parameters for initialization, see nim/types.NIMGetInstanceOptions.
Parameter |
Description |
---|---|
appKey | [required] The AppKey of the application |
account | [required] CommsEase IM account (accid), the unique identifier of a user. |
token | [required] The login credential of the IM account This login credential will only be used for verification when users log in to the IM server (establishing a persistent connection between SDK and CommsEase server). |
onconnect | Callback invoked when the SDK establishing a persistent connection with the CommsEase server. |
onwillreconnect | Callback invoked for reconnection between SDK and CommsEase server |
ondisconnect | Callback invoked for disconnection between SDK and CommsEase server |
onsyncdone | Callback invoked when synchronization during initialization is complete. |
onerror | Callback invoked when an error occurs during initialization. |
onloginportschange | Callback invoked when the login status across devices changes |
onsessions | Callback invoked when the list of conversations is synchronized during initialization. |
onupdatesessions | Callback invoked when multiple conversations are updated online. |
onStickTopSessions | Callback invoked to return the pinned conversations during synchronization in initialization and online. |
onroamingmsgs | Callback invoked when messages for sync are synchronized during initialization |
onofflinemsgs | Callback invoked when offline messages are synchronized during initialization |
onmsg | Callback invoked when a message is received for multi-device synchronization or online. |
onofflinesysmsgs | Callback invoked when offline system notifications are received during initialization |
onroamingsysmsgs | Callback invoked when system notifications for sync are received during initialization. |
onDeleteMsgSelf | Callback invoked when a message is deleted for the current user during multi-device synchronization |
onbroadcastmsgs | Callback invoked when offline broadcast messages are synchronized during initialization |
onbroadcastmsg | Callback invoked when broadcast messages are received. |
onTeamMsgReceipt | Callback invoked when read receipts for group messages are received. |
onsysmsg | Callback invoked when system notifications are received online. |
onupdatesysmsg | Callback invoked when system notifications are updated online |
oncustomsysmsg | Callback invoked when custom system notifications are received online |
onofflinecustomsysmsgs | Callback invoked when offline custom system notifications are received during initialization. |
onsysmsgunread | Callback invoked when the unread count of system notifications is received during initialization. |
onupdatesysmsgunread | Callback invoked when the unread count of system notifications is updated online. |
onpushevents | Callback for subscription event Users can receive push notifications from CommsEase server using this callback for subscribed events online or during initialization. |
onQuickComment | Callback invoked when a notification for a quick comment is received. |
onDeleteQuickComment | Callback invoked when a quick comment is delete. |
onPinMsgChange | Callback invoked when the status of pinned messages changes. |
onClearServerHistoryMsgs | Callback invoked when the message history is cleared. |
onSyncUpdateServerSession | Callback invoked when the list of conversations on the server is synced. |
onblacklist | Callback invoked when the blocklist is synced. |
onsyncmarkinblacklist | Callback invoked when the blocklist is synced. |
onmutelist | Callback invoked when the list of muted members is synced. |
onsyncmarkinmutelist | Callback invoked when a member is muted. |
onfriends | Callback invoked when the list of friends is synced. |
onsyncfriendaction | Callback invoked when the you perform an action for friends. Friend operations include adding a friend, sending a friend request, accepting a friend request, rejecting a friend request, deleting a friend, and updating a friend's alias. |
onmyinfo | Callback invoked when your profile is synced. |
onupdatemyinfo | Callback invoked when your profile is updated. |
onSuperTeams | Callback invoked when the list of supergroups are received. |
onSyncCreateSuperTeam | Callback invoked when a supergroup is created. |
onUpdateSuperTeam | Callback invoked when a supergroup is updated. |
onDismissSuperTeam | Callback invoked when a supergroup is deleted. |
onTransferSuperTeam | Callback invoked when a supergroup is transferred. |
onUpdateSuperTeamMember | Callback invoked when the profile of a member in a supergroup is updated. |
onAddSuperTeamMembers | Callback invoked when a new member is added to a supergroup. |
onRemoveSuperTeamMembers | Callback invoked when a member in a supergroup is removed. |
onUpdateSuperTeamManagers | Callback invoked when the administrators in a supegroup are updated. |
onUpdateSuperTeamMembersMute | Callback invoked when an administrator in a supergroup is muted. |
onteams | Callback invoked when the list of groups is synced. |
onsynccreateteam | Callback invoked when the logged-in account creates a group on another devices. |
onCreateTeam | Callback invoked when a group is created |
onUpdateTeam | Callback invoked when a group is updated. |
onDismissTeam | Callback invoked when a group is deleted. |
onTransferTeam | Callback invoked when a group is transferred. |
onupdateteammember | Callback invoked when the profile of a group member is updated. |
onAddTeamMembers | Callback invoked when a member joins a group. |
onRemoveTeamMembers | Callback invoked when a group member is removed. |
onUpdateTeamManagers | Callback invoked when the administrators in a group are updated. |
onUpdateTeamMembersMute | Callback invoked when a group member is muted. |
NIM SDK entry point used to establish persistent connections, login, disconnect from the CommsEase server, destroy the IM instance, implement device exclusion and more. For a complete list of APIs, see NIMInterface
Method | Description |
---|---|
logout | log out |
disconnect | disconnect from the CommsEase server |
connect | establish a persisten connection and log in |
destroy | destroy the instance. |
kick | kick logged in accounts on other devices |
setOptions | Options for initialization |
Messaging APIs, such as sending a text message, sending a file message, unsending a message, read receipt. For the complete list of APIs, see MessageInterface
Method | Description |
---|---|
sendText | Send a text message. |
sendFile | Send a file message. |
sendCustomMsg | Send a custom message. |
sendGeo | Send a location message. |
sendTipMsg | Send an alert. |
resendMsg | Resend a message. |
forwardMsg | Forward a message. |
sendMsgReceipt | Send a read receipt for a private message. |
sendTeamMsgReceipt | Send a read receipt for a group message (advanced group). |
getTeamMsgReads | Get the number of read and unread group messages. |
getTeamMsgReadAccounts | Get the accounts that have read a group message. |
recallMsg | Unsend a message. |
deleteMsgSelf | Delete a message for the current user. |
deleteMsgSelfBatch | Delete multiple messages for the current user. |
Message history APIs, including query message history. For the complete list of APIs, see MessageLogInterface
Method | Description |
---|---|
getHistoryMsgs | Get the message history on the server. |
clearServerHistoryMsgsWithSync | Delete the message history and messages for sync of a specified conversation on the server. |
msgFtsInServer | Full text search for message history on the server. The returned messages are categoried by conversation. |
msgFtsInServerByTiming | Full text search for message history on the server by time. Returned messages are sorted by time. |
getLocalMsgs | Get the message history from the local database. |
getLocalMsgsByIdClients | Get the messages with idClients. |
updateLocalMsg | Update the local messages. Only localCustom local custom extension fields are allowed to be updated. |
getLocalMsgsByIdClients | Get the local messages. Only localCustom local custom extension fields are allowed to be updated. |
deleteLocalMsg | Delete a local message. |
deleteLocalMsgs | Delete multiple local messages. |
deleteLocalMsgsBySession | Delete local messages by conversation. |
deleteAllLocalMsgs | Delete all local messages. |
saveMsgsToLocal | Save messages to the local database. |
Event subscription and pulishing APIs, such as subscribing to an event, publishing an event. For the complete list of APIs, see EventInterface
Method | Description |
---|---|
publishEvent | Publish an event. |
subscribeEvent | Subscribe to an event |
unSubscribeEventsByAccounts | Unsubscribe from an event by account |
querySubscribeEventsByAccounts | Get the subscription of the specified event by account |
unSubscribeEventsByType | Unsubscribe from all the specified events by type |
querySubscribeEventsByAccounts | Get the subscription of the specified event by account |
querySubscribeEventsByType | Get the subscription of the specified event by type. |
Friend APIs, such as get, add, apply, or delete a friendsc. For the complete list of APIs, see FriendInterface
Method | Description |
---|---|
getFriends | Get Friends |
addFriend | Add as friend without verification. |
applyFriend | Send a friend request. |
passFriendApply | Accept a friend request. |
rejectFriendApply | Reject a friend request. |
deleteFriend | Delete a friend. |
updateFriend | Update friends |
isMyFriend | Check if the user is included in the friend list. |
Pass-through protocol. For the complete list of APIs, see PassThroughInterface
Method | Description |
---|---|
httpRequestProxy | Pass-through protocol |
APIs for messaging extension, such as thread message. For complete APIs, see MessageExtendInterface
Method | Description |
---|---|
getThreadMsgs | Get the list of messages in a thread. |
getMsgsByIdServer | Get messages by message Ids in a thread chat. |
addQuickComment | Add a quick comment. |
deleteQuickComment | Remove a quick comment. |
getQuickComments | Get multiple quick comments at a time. |
addCollect | Add a message to bookmarks. |
deleteCollects | Delete bookmarks. The number of deleted bookmarks is returned. |
updateCollect | Update bookmarks, only custom fields can be updated. |
getCollects | Get the bookmarks |
addMsgPin | Add a PIN tag to a message |
updateMsgPin | Update the PIN message |
deleteMsgPin | Remove the PIN tag from a message |
getMsgPins | Get the PIN messages in a conversation. |
Conversation APIs, such as querying conversations, querying a specific conversation. For information about the complete APIs, see SessionInterface
Method | Description |
---|---|
getLocalSession | Get the conversation in the local database by sessionId |
getLocalSessions | Get the paginated list conversations in the local database. |
insertLocalSession | Insert a conversation record into the local database |
updateLocalSession | Update a conversation in the local database |
deleteLocalSession | Delete the specified conversation in the local database. |
setCurrSession | Set the current session |
resetCurrSession | Reset the effect of "setCurrSession" |
resetSessionUnread | Reset the unread count for a conversation. |
resetSessionsUnread | Reset the unread counts for some conversations. |
resetAllSessionUnread | Reset the unread count for all conversations. |
getStickTopSessions | Get the list of pinned conversations on the server. |
addStickTopSession | Pin a conversation on the server. |
deleteStickTopSession | Unpin a conversation on the server. |
updateStickTopSession | Update the pinned conversation on the server (update the extension field of the pinned conversation. |
APIs for system notifications, such as sending custom system notifications. For a complete list of APIs, see SystemMessageInterface
Method | Description |
---|---|
sendCustomSysMsg | Send a custom system notification. |
markSysMsgRead | Send a response to mark the system notification read, and the server does not need to send this message as an offline system notification. |
getLocalSysMsgs | Get system notifications in the local database |
updateLocalSysMsg | Update system notifications in the local database |
deleteLocalSysMsg | Delete system notifications in the local database |
deleteAllLocalSysMsgs | Delete all system notifications in the local database |
APIs for group management, such as getting a group, creating a group, leaving a group, managing group members. For the complete list of APIs, see TeamInterface
Method | Description |
---|---|
getTeam | Get a group. |
getTeams | Get the list of groups. |
getTeamsById | Get multiple groups using group IDs. |
createTeam | Create a group. |
updateTeam | Update a group |
transferTeam | Transfer the ownership of a group. Only the owner has the permission to perform the action. |
dismissTeam | Delete a group. Only the group owner can perform the action. |
leaveTeam | Leave a group. |
muteTeamAll | Mute all group members |
getTeamMembers | Get the list of group members |
getMutedTeamMembers | Get the list of muted group members |
addTeamMembers | Add group members |
acceptTeamInvite | Accept the invitation to join a group |
rejectTeamInvite | Reject the invitation to join a group. |
removeTeamMembers | Remove one or more members from a group. |
addTeamManagers | Add an administrator |
removeTeamManagers | Remove an administrator |
updateInfoInTeam | Edit the profile of the current user in the group |
updateNickInTeam | Edit the nickname of a member. |
updateMuteStateInTeam | Update the mute state of a member. |
getTeamMemberByTeamIdAndAccount | Get the member by group ID and account ID. |
getTeamMemberInvitorAccid | Get the ID of the account that invited the group member. |
applyTeam | Request to join a group. |
passTeamApply | Approve the request to join a group. |
rejectTeamApply | Rejects a request to join a group. |
APIs for managing users, such as adding a user to the blocklist, muting or unmuting a user, editing the user profile. For the complete list of APIs, see UserInterface
Method | Description |
---|---|
getUser | Get the user profile |
getUsers | Get multiple user profiles, up to 150 profiles at a time. |
updateMyInfo | Update the profile of the current user |
isUserInBlackList | Check if someone is in the current user's blacklist |
getRelations | Get user-specific data (blacklist and list of muted members) |
addToBlacklist | add a user to the blocklist. |
removeFromBlacklist | Remove a user from the blocklist. |
addToMutelist | Add a user to the list of muted users. |
removeFromMutelist | Remove a user from the list of muted users. |
isUserInBlackList | Check if someone is in the current user's blacklist |
Only some APIs are listed here, for the complete API, see CloudSessionInterface
Method | Description |
---|---|
getServerSessions | Get the list of conversations on the server. |
getServerSession | Get a specified conversation on the server. |
updateServerSession | Update the conversations on the server. |
deleteServerSessions | Delete conversations on the server. |
Server-side conversation APIs, such as querying the list of conversations, querying a specific conversation. For information about the complete APIs, see CloudStorageInterface
Method | Description |
---|---|
previewFile | Upload and preview files |
getNosOriginUrl | convert shortened URL to long URL |
audioToText | Audio to Text |
stripImageMeta | Remove metadata of an image |
qualityImage | Modify image quality |
interlaceImage | interlace image |
rotateImage | Rotate an image |
blurImage | Blur an image |
cropImage | Crop images |
thumbnailImage | Generate thumbnails |
processImage | Process images |
Signaling APIs, such as creating and closing channels. For more information, see SignalingInterface
Signaling events are monitored using nim.on
. For more information, see NIMSignalingEventInterface.
Event | Description |
---|---|
signalingNotify | Receive a notification online |
signalingMutilClientSyncNotify | Receive a notification for multi-device synchronization |
signalingChannelsSyncNotify | Receive a notification for changes of members. |
signalingUnreadMessageSyncNotify | Receive a notification for unread signaling message. |
Usage:
nim.on('signalingNotify', (res) => {
console.log('receiving a notification', res)
})
Method | Description |
---|---|
signalingCallEx | Call to join an audio and video channel: Create and join a channel and invite others to join the audio and video channel |
signalingCall | 呼叫: Create and join yourself, and invite others to join the channel |
signalingCreateAndJoin | If there is no room, create and join a channel. If there is already a channel, join the channel. |
signalingCreate | Create a channel |
signalingDelay | extend the validity period of a channel |
signalingClose | Close a channel |
signalingGetChannelInfo | Query channel information by channelName |
signalingJoin | Join a channel |
signalingLeave | Leave a channel |
signalingInvite | Invite someone to join a channel |
signalingCancel | Cancel an invitation |
signalingReject | Rejecting an invitation to join a channel |
signalingAccept | Accept an invitation to join a channel |
signalingMarkMsgRead | Mark signaling message received and will not store this message as offline message. |
signalingControl | Send a custom signaling |
signalingJoinAndAccept | Join a channel and accept and invitation |
APIs for supergroup management, such as getting a supergroup, creating a supergroup, leaving a supergroup, managing group members. For the complete list of APIs, see SuperTeamInterface
Method | Description |
---|---|
getSuperTeam | Get a supergroup. |
getSuperTeams | Get a list of supergroups. |
updateSuperTeam | Update a supergroup. |
transferSuperTeam | Transfer the ownership of a supergroup. The group owner can perform the action。 |
leaveSuperTeam | Leave a supergroup. |
updateSuperTeamMute | Mute all supergroup members. |
getSuperTeamMembersByJoinTime | Get the list of all members in pagination. |
getSuperTeamMembersByAccounts | Get members by account IDs. |
getAllSuperTeamMembers | Get all members in a supergroup. If the data is large, the members are loaded serveral time by the done callback. |
getMutedSuperTeamMembers | Get the list of muted members in a supergroup. |
addSuperTeamMembers | add a new member to a supergroup. |
acceptSuperTeamInvite | Accept the invitation to join a supergroup |
rejectSuperTeamInvite | Reject the invitation to join a supergroup. |
removeSuperTeamMembers | Remove one or more members from a supergroup. |
addSuperTeamManagers | Add an administrator to a supergroup. |
removeSuperTeamManagers | Remove an administrator from a supergroup. |
updateNickInSuperTeam | Edit the nickname of a member in a supergroup. |
updateInfoInSuperTeam | Edit the profile of the current user in a supergroup. |
updateSuperTeamMembersMute | Update the mute state of a member in a supergroup. |
applySuperTeam | Request to join a supergroup. |
passSuperTeamApply | (Administrator) approve the request to join a supergroup. |
rejectSuperTeamApply | (Administrator) reject a request to join a supergroup |
Miscellaneous interfaces, see MiscInterface for complete API
Method | Description |
---|---|
filterClientAntispam | Moderate data on the client |
getClientAntispamLexicon | Get the keywords for moderation. |
getServerTime | Get the timestamp of the time on the server. |