accountId of the requester
idServer of the notification for invitation from an administrator.
accept an invitation to join the group TeamInterface.addTeamMembers
Group owners and administrators invite users to join the group (addTeamMembers), and the invited users will receive a system notification of type teamInvite.
The value of the from field of this system notification is the account of the inviter. The value of the to field is the group ID, the attach of this type of system notification has a field team whose value is the group to join. The invited users can accept or reject the invitation.
acceptTeamInvite, the specific content of the notification message is as follows.rejectTeamInvite, the value of the from field is the account ID of the user who rejects the invitation, and the value of the to field is the group IDIf a user accepts an invitation to join a group,
accountId of the requester
idServer of the notification for invitation from an administrator.
Add collection, and the content of the collections determined according to the business scenario. Collections are only visible to the current user.
the bookmark extension field that can contain 1024 characters
The specific data of the bookmark, the maximum number of characters is 20480
Type, you can customize the mapping relationship, must be an integer
Unique ID.
Note: When the uniqueId is passed,the server checks whether there is a collection record before for uniqueId. If it does not exist, a new collection will be added, and if it exists, the collection will be updated.
bookmarks
Add a friend without consent. The recipient will receive a system notification of type = 'addFriend', and the from field is the account ID of the requster, and the field to is the account ID of the recipient
The account to be added as a friend
Additional message in JSON string.
Add a PIN tag to a message. If successful, the onPinMsgChange callback of the multi-device login device will be triggered
The structure of pinned messages
The extension field of PIN messages
Add a quick comment
Custom text for push notifications
Comment
Note: Enter an integer, you can create custom mapping rules. For example, 1 for the like emoj, 2 for the clapping emoj.
Extension
Message to be replied
Whether message count is required (badge at the app corner). The default value is false.
whether a push notification is required. The default value is false..
Custom property of a push notification in JSON.
Title for a push notification
Comment
Quick comment
Extension
ID of the account making the comment.
time when the comment is posted.
Message, extract several fields in the NIMMessage structure, and idServer must exist.
account of a sender
The ID used by the server to distinguish messages, used to get message history and keywords for searching message history.
Note: This field may not be available. For example, the message is filtered by anti-spam.
Messaging scenario:
Timestamp
ID of a recipient, account ID or group ID
Pin a conversation The next time a user logs in, the onStickTopSessions callback returns the list of pinned conversations during initialization. all logged-in users of the current account will get notified by the onupdatesessions callback
sessionId
For example p2p-cs1, team-113879441
the extension field of pinned conversations.
Add an administrator
If administrators are added:
Add group members
List of accounts that want to join the group
Additional fields, JSON string is recommended
Additional message, the length cannot be greater than 5000 characters, you can use serialized data in JSON string.
Add an administrator
If administrators are added:
Add group members
The basic group is deprecated. Use the advanced group:
If new members are add and join the group, other group members will receive a notification and trigger onAddTeamMembers
The invited group members will not receive the notification until members in the group send a message in the group and trigger the onupdatesessions callback.
Advanced group:
List of accounts that want to join the group
Additional fields, JSON string is recommended
Additional message, the length cannot be greater than 5000 characters, you can use serialized data in JSON string.
Add to the blocklist The onblacklist callback is triggered during initialization and onsyncmarkinblacklist triggered during synchronization across devices.
Target account ID
Whether the account is included in the blocklist or the list of muted members.
true: Yes, false: No.
Details of the operation record
Target account ID
Update timestamp
Add to the list of muted members. The onmutelist callback is triggered during initialization and onsyncmarkinmutelist triggered during synchronization across devices.
Target account ID
Whether the account is included in the blocklist or the list of muted members.
true: Yes, false: No.
Details of the operation record
Target account ID
Update timestamp
Send a friend request for approval The recipient will receive a system notification of type = 'applyFriend'. The recipient can choose to passFriendApply, or rejectFriendApply
passFriendApply.rejectFriendApply.Additional message in JSON string.
A user requests to join a supergroup. SDK behaves differently depending on joinMode
Additional message
Request to join a group. SDK behaves differently depending on joinMode
Additional message
Audio to text Note that this feature is only available in NIM. Chat room has not yet implemented this feature.
apply Gaussian blurring
Gaussian blurring radius
Gaussian blur standard deviation, cannot be less than 0
Original URL to the image stored in NOS
URL of the returned image
If you delete the message history and message records for sync on the CommsEase server, the message history of the conversation in the local database will also be deleted, but the conversation in the database will be retained. You can delete the conversations in the local database by calling {@link NIMGetInstanceOptions.deleteLocalSession}.
If isSyncSelf is set to true, the account logged in on multiple devices will trigger onClearServerHistoryMsgs
Extension field
Whether to delete message history for sync. Default value: true
Specify whether to sync messages across devices. The default value is false
Messaging use case
The user you talk with。 If it is a private message, pass the account of the peer. For group chats, pass the group ID.
After logging out of IM using the disconnect method, you can call connect to log in again. After calling getInstance, a persistent connection will be established automatically without calling connect
nim.disconnect({
done: function() {
nim.connect()
}
})
Create an advanced group The basic group is deprecated. Use the advanced group.
After the function call:
List of accounts to be invited
Group announcement
Business ID for moderation configured in the CommsEase console.
Group avatar
Verification method for invitations
Extension field
Group introduction
Invitation mode
Join method
Group name
Additional message
Group type
Permissions for editing custom fields of a group profile
Permissions for editing the group profile
List of accounts to be invited
Moderation tag
Owner information
Additional message
Group
Crop an image
Height
Original URL to the image stored in NOS
Width
X coordinate, must be an integer
Y coordinate, must be an integer
URL of the returned image
Delete all local messages. This method will clear all conversations in the database at the same time.
Note: If the operating environment does not support the database, or the database is not running, the execution is successful, but no valid data will be returned or operated.
Delete all system notifications from the local database
Delete multiple collections at a time.
List of collections to be deleted, up to 100
List of bookmarks to be deleted
Number of deleted bookmarks
Delete a friend. The recipient will receive a system message of type = 'deleteFriend'. The from field of this system notification is the account that deletes the friend account and the to field is the ID of the deleted account.
Whether to delete the alias of a friend account.
Delete a local message.
lastMsg property of the conversation will automatically change to the previous message, and the onupdatesessions callback will be triggered.Delete local messages based on conversation ID, start time and end time
Timestamp of the end time for a search
session.id
Timestamp of the start time for a search
Whether the conversation is synced. The default value is true
Delete all local messages in a specific conversation
Note: If the operating environment does not support the database, or the database is not running, the execution is successful, but no valid data will be returned or operated.
Whether session.lastMsg will also be deleted. The default value is false
Whether the message is deleted by tag. The default value is false
Note: If it is true, the message is deleted physically, and the localCustom local custom extension field inserted for this message cannot be retained. If the value is false, the message is deleted by logic.
Messaging use case
The user you talk with。 If it is a private message, pass the account of the peer. For group chats, pass the group ID.
Delete the messages of the specified time range at a time.
Note: If the operating environment does not support the database, or the database is not running, the execution is successful, but no valid data will be returned or operated.
Timestamp of the end time. Use Infinity by default if unspecified.
Timestamp of start time in milliseconds, default value: 0
Callback invoked when a message is deleted. You can search for messages after this callback.
Delete the specified conversation from the local database. and optionally delete messages for sync on the server.
Deleting system notifications from the local database. If the local database is not available, or the specified notification does not exist, the execution is considered successful.
Pass teamId array.
Note: To be compatible with the legacy interfaces, only string data is allowed. An array is recommended.
Custom text for push notifications
Additional information, JSON string is recommended
Environment for messaging webhooks
message to be unsent
Additional message
Custom properties for push notifications, must be JSON string.
Remove the PIN tag from messages The onPinMsgChange callback is triggered for synchronization across devices.
The structure of pinned messages
Delete a message only for the current user. After deletion, the message remains visible to other users. If an account is logged in on multiple devices, this function will trigger the callback of onDeleteMsgSelf on other devices.
Extension field
Message to be deleted
Delete multiple messages at a time for the current user After deletion, the message remains visible to other users. If an account is logged in on multiple devices, this function will trigger the callback of onDeleteMsgSelf on other devices.
Extension field
List of messages to be deleted
URL to get the file
Full URL
Delete a quick comment
Custom text for push notifications
Comment
Note: Enter an integer, you can create custom mapping rules. For example, 1 for the like emoj, 2 for the clapping emoj.
Extension
Message to be replied
Whether message count is required (badge at the app corner). The default value is false.
whether a push notification is required. The default value is false..
Custom property of a push notification in JSON.
Title for a push notification
Comment
Quick comment
Extension
ID of the account making the comment.
time when the comment is posted.
Message, extract several fields in the NIMMessage structure, and idServer must exist.
account of a sender
The ID used by the server to distinguish messages, used to get message history and keywords for searching message history.
Note: This field may not be available. For example, the message is filtered by anti-spam.
Messaging scenario:
Timestamp
ID of a recipient, account ID or group ID
List of conversation IDs
Unpin a conversation The next time a user logs in, the onStickTopSessions callback returns the list of pinned conversations during initialization. all logged-in users of the current account will get notified by the onupdatesessions callback
sessionId
For example p2p-cs1, team-113879441
Disconnect from the server and destroy the IM instance If the instance is destroyed, you cannot call connect to reconnect to the chat room.
Note that in NIM SDK v9.9.0 and earlier versions, the ondisconnect callback function will be triggered directly after calling destroy, but the persistent connection is not actually closed. Only when the done callback is triggered, can the persistent connection be truly closed. To avoid device exclusion during reconnection, you must set reconnection and other operations in the done callback for the destroy method.
done callback
Disconnect from the server, but do not destroy the IM instance After logging in by calling connect, the data will be incrementally synchronized based on the instance status
Note that in NIM SDK v9.9.0 and earlier versions, the ondisconnect callback function will be triggered directly after calling destroy, but the persistent connection is not actually closed. Only when the done callback is triggered, can the persistent connection be truly closed. To avoid device exclusion during reconnection, you must set reconnection and other operations in the done callback for the destroy method.
done callback
Delete a group. Only the owner can delete a group.
Calls each of the listeners registered for a given event.
Return an array listing the events for which the emitter has registered listeners.
Check client-side moderation For information about client-side moderation, see Content moderation
Note: Before calling this interface, you must get the keywords for moderation by calling getClientAntispamLexicon. Otherwise, an error 404 no keywords for moderation will appear
Text for moderation
Status of a request
Text for moderation
Suggestion for hit content
Verified for pass
Result types
0: pass 1: filtered and released 2: rejected 3: hit by client-side moderation rules, handled by the server, messages for delivery contain the clientAntiSpam field.
Forward a message to another conversation
Note: This interface returns the message in the sending state, and the sent message body needs to be obtained by passing options.done.
Calling this method triggers:
message to be forwarded.
Messaging scenario
The new recipient, the peer's account or group ID
Get all supergroup members. When the amount of data is very large, it will be returned in multiple times using the done callback.
Members whose invalid field is true
group members returned from the query
Get the connection address of the chat room and return a list of available connection addresses
Chat room ID
List of addresses for chat rooms
Chat room ID
0: IPv4 addresses, 1: IPv6 addresses, 2: unlimited.
Default value: 0.
Whether an address for the WeChat environment is provided.
Get the keyword filters for moderation. You can get the keywords for moderation using this API and store the keywords in the memory.
MD5 value of the keywords file for moderation
The download URL of a keywords file for moderation
Keywords content parsed as a JSON object for moderation
Version of Keywords for moderation
Query collections
Timestamp of start time in milliseconds, default value: 0
Timestamp of the end time in milliseconds. the default value is the current server time
The ID of the last collection in the last query
Note: It is recommended to fill out from the second page, so that the server can distinguish two records with the same timestamp.
The upper limit of messages per query. 100 messages by default
Sorting order. The default value is false
If true, query in ascending order by timestamp, and limit number of records from beginTime to endTime
If false, query in descending order by timestamp, and limit number records from endTime to beginTime
Type, you can customize the mapping relationship, must be an integer. All types of messages are queried by default.
List of bookmarks
Total number of bookmarks
If you set syncFriends to false when initializing the SDK, the onfriends callback will not be triggered. In this case, this interface can obtain the friend list
Note: Since the upper limit of the number of friends after v8.9.0 becomes 10,000, the remote protocol does not allow the SDK to send 10,000 friends in one go. There are two ways to get all friends at a time:
If a database is used, this interface will return all valid friend records in the database with updateTime > options.updateTime
If a database is not used, this interface with a timestamp argument will get 3000 records of updateTime > options.timetag from the server. Please handle the pagination logic on your own.
Timestamp, default value: 0. Get 3000 friends in ascending order whose update time is greater than this timestamp.
Get the message history stored on the CommsEase server. The time range is defined by the parameters beginTime and endTime.
reverse is set to false, the endTime of the subsequent query corresponds to the time field of the last message of the previous query.reverse is set to true, the beginTime of the subsequent query corresponds to the time field of the last message of the previous queryThis API call is triggered when users opens a conversation and render the message list or "pulls down to view more messages".
Sorting order. The default value is false
false means that the returned messages are sorted in descending order by time;
true means the returned messages are sorted in ascending order by time;
Timestamp of start time in milliseconds, default value: 0
Timestamp of the end time in milliseconds. the default value: 0
The idServer of the last message in the last query. No value for the first query.
limit on the number of queries per page, the default value is 100
Specified message type. All message types if unspecified
Query sequence. The default value is false, indicating the result is displayed in descending order.
false Search limit number of history messages forward from endTime
true Search limit number of history messages backward from beginTime
Messaging use case
The user you talk with。 If it is a private message, pass the account of the peer. For group chats, pass the group ID.
Retrieve message history from the local database.
This API call is triggered when users opens a conversation and render the message list or "pulls down to view more messages".
If the runtime environment does not support the database, or the database is not running, the execution is successful, but no valid data be returned.
true means search from end, false means search from begin
Timestamp of the end time for a search
[for indexedDB only] If parameters are provided, query messages matching this keyword
Note: The query with this parameter is in the forward index mode, and the query will be quite slow when the amount of data is large. If you need to support full-text search (inverted index structure), see fts interfaces
Pagination limit
If specified, search messages in this conversation
Timestamp of the start time for a search
[indexedDB dedicated] If this parameter is provided, query these subtypes of messages
[indexedDB specific] If this parameter is provided, query this type of message
Get the local message history by the client message IDs (idClients).
If the runtime environment does not support the database, or the database is not running, the execution is successful, but no valid data be returned.
Get the session in the local database by sessionId
Query the list of conversations in the local database.
Note: The conversation list is sorted in descending order by updateTime, that is, the most recently conversations are displayed at the top.
The ID of the last conversation on the previous page, you can leave it blank for the first query.
limit on the number of queries per page, the default value is 100
Query order. The default value is false, indicating the result is displayed in descending order.
value: false. Indicates to search for local conversations starting from the most recent conversations.
true, search for local conversations from the first conversation.
Get system notifications from the local database
The idServer of the last system notification in the last query.
limit on the number of queries on one page, the default value is 100
Whether the notification is read
Query sequence
Default value: false. Indicates to search for local system notifications starting from the most recent system notifications. If it is true, search for local system notifications from the first system notification
Type
Get all PIN messages by conversation ID
session ID
Session ID
Query message history by message ID and other information, exclusive to thread chat
query parameters, several fields in the NIMMessage structure, and idServer is required.
Get the list of muted group members The function result is affected by SuperTeamInterface.updateSuperTeamMembersMute
Time when a member joined the group
Note: If this argument is used, get members who joined after this time, if not, there is no limit
Pagination limit, default value: 100, return 100 pieces of data
Query order. The default value is false
false means to query the members joined after joinTime
true means to query members joined before joinTime
Members whose invalid field is true
group members returned from the query
Get the list of muted group members The function result is affected by TeamInterface.updateMuteStateInTeam
URL to get the file
Full URL
Shortened URL to full URL
Get multiple quick comments at a time.
Message to be replied
The recent update time of a quick comment.
idClient of a message commented
idServer of a message commented
Get the blocklist and list of muted members. If you set syncRelations to false when initializing the SDK, you cannot get notified by the onblacklist and onmutelist callbacks. In this case, you can call this interface to get the blocklist and the list of muted members.
Get a specific session
Messaging scenario
Recipient.
Get the server sessions
Pagination size, default value: 100.
Maximum timestamp Form a time period with minTimestamp as a query condition.
The current timestamp by default
Minimum timestamp Form a time period with maxTimestamp as a query condition.
Default value 0 means unlimited.
Specify whether last message is needed.. Default value: true
Check if the next page exists
List of conversations
Get the timestamp for the current time on the server in milliseconds
Get the list of pinned conversations
Get the information about a supergroup by group ID
Group ID
Query the detailed information about members in the supergroup
List of account IDs
List of account IDs
List of account Ids whose invalid field is true
Returned data of members.
Retrieve the list of members by the join time.
Whether to mute the group Time when a member joined the group
Note: If this argument is used, get members who joined after this time, if not, there is no limit
Pagination limit, default value: 100, return 100 pieces of data
Query order. The default value is false
false means to query the members joined after joinTime
true means to query members joined before joinTime
Members whose invalid field is true
group members returned from the query
Get the list of supergroups If you set syncSuperTeams to false when initializing the SDK, the data returned by the onSuperTeams callback will not be received. This Interface can get the list of supergroups.
Note: If there is no local database, the SDK will get the list of supergroups from the server.
Get a group
Note: If the local database service is unavailable or the group can not be retrieved from the local datab ase, the SDK will get the group from the CommsEase server.
Retrieve the group information forcibly from the server
Group ID
Get the member by group ID and account
The key is the account ID
Get the ID of the account that invited the group member.
A list of member account IDs to be queried.
Note: The done callback fires every 200 calls.
The key is the account ID, value is the account ID of the inviter
Get the list of group members If you set syncTeamMembers to false when initializing the SDK, the data returned by the onteammembers callback will not be received. This method can get the list of group members.
Get the accounts that have read or unread a group message.
Group messages to be queried
Query the read and unread count of group messages.
List of group messages to be queried
Note that the actual return data of this callback is in the third parameter
Get groups
syncSuperTeams to false when initializing the SDK, the data returned by the onSuperTeams callback will not be received, and this Interface can get the list of groups.Note: If there is no local database, the SDK will get the list of groups from the server.
Get groups by group IDs
Note: v8.2.0 support
Returned groups from the query
Ids of groups that fails to be queried by teamIds.
Get the list of messages in a thread.
Start time in milliseconds. the default value: 0
Timestamp of the end time in milliseconds, the default value is the current time of the server
The idServer of the last message in the last query. No value for the first query.
The upper limit of messages per query. 100 messages by default
The default false means to search for message history forward from endTime, and true means to search for message history backward from beginTime
Scenario
Sender account of a message in the thread
ServerID of the root message in a thread.
Time of the root message in a thread
Recipient of a thread message
List of relevant messages
root message in a thread
Get the timestamp.
Total number of messages
Get the user profile
Account ID
Whether to get the account from the server. The default value is false
Get it from the server if it is true, and get it from the information cached in the local database if it is false.
Get user profiles. Up to 150 profiles can be retrieved at a time.
List of account IDs
Whether to get the account from the server. The default value is false
Get it from the server if it is true, and get it from the information cached in the local database if it is false.
Protocol for the pass-through mode
Insert a conversation into the local database indexdb
If the database is not enabled, a session will be inserted in the memory. It is not recommended to use this function without db. You must maintain conversation data in the memory data.
If the conversation already exists, an error will be returned
If there is a local history message for this conversation, the lastMsg of the conversation will be updated to the last message.
The onupdatesysmsgunread callback is triggered after you insert this conversation.
interlace image
Original URL to the image stored in NOS
URL of the returned image
Check if the user is included in the friend list
Note: This interface requires database support. If the local database is not enabled, the done callback will return false
Check if a user is in the blocklist
Note: This interface requires database support. If the local database is not enabled, the done callback will return false
The account ID for query
log out of other devices using the same account.
Log out the account on other devices
done callback
Leave a group
Leave a group
Return the number of listeners listening to a given event.
Return the listeners registered for a given event.
Mark the system notification read in the response sent from the server. Next time, the server does not need to store this notification as offline system message onofflinesysmsgs
The onupdatesysmsgunread callback is fired after flagging
Full-text search for message history on the server. The returned messages will be classified by session, not by time.
Search message history of all conversations stored on the CommsEase server based on the time range and keywords.
The "full-text search message" setting has been activated in the CommsEase console.
Configuration: Select the application, and select IM Basic/Pro > Settings > Global > Full-text message search.
The start time of the search, the default value 0 means unlimited
Keyword for search
Limit on the number of returned messages per conversation Default value: 5. For example, if you pass 1, each conversation returns 1 matching message.
Message subtype, which can be customized when sending messages, and the format is an integer greater than 0. Example: [1, 2]
message type, Example: ['text', 'image', 'audio', 'video', 'geo', 'notification', 'file', 'tip', 'custom']
Sorting rule for returned messages. The messages are sorted in descending order DESC by default. optional ASC ascending order.
Search condition for private chats, account for sessions (p2p-accid1), example: ['accid1', 'accid2', 'accid3']
List of message senders, Example: ['accid1', 'accid2', 'accid3']
Limit on the number of conversations The default value is 10. For example, if you pass 5, messages in 5 sessions are retrieved and returned
Search condition Group list. Search messages from these groups (team-146694936), example: ['146694936', '13897']
The end time of the search, the default value is the current time
Full-text search for messages (search by time). the returned messages are sorted in descending order by time.
Search message history of all conversations stored on the CommsEase server based on the time range and keywords.
The "full-text search message" setting has been activated in the CommsEase console.
Configuration: Select the application, and select IM Basic/Pro > Settings > Global > Full-text message search.
The start time of the search, the default value 0 means unlimited
Keyword for search
Limit on the number of returned messages per conversation Default value: 5. For example, if you pass 1, each conversation returns 1 matching message.
Message subtype, which can be customized when sending messages, and the format is an integer greater than 0. Example: [1, 2]
message type, Example: ['text', 'image', 'audio', 'video', 'geo', 'notification', 'file', 'tip', 'custom']
Sorting rule for returned messages. The messages are sorted in descending order DESC by default. optional ASC ascending order.
Search condition for private chats, account for sessions (p2p-accid1), example: ['accid1', 'accid2', 'accid3']
List of message senders, Example: ['accid1', 'accid2', 'accid3']
Search condition Group list. Search messages from these groups (team-146694936), example: ['146694936', '13897']
The end time of the search, the default value is the current time
Mute all group members
Whether to mute the group
Query the message reminder setting for each group. You can configure the message reminder setting using updateInfoInTeam
Add a listener for a given event.
Add a one-time listener for a given event.
Accept a friend request. When the function is invoked,
An administrator approves the request to join a group.
If the request is approved:
accountId of the requester
idServer of the notification for join requests.
An administrator approve the request to join a group.
If the request is approved:
accountId of the requester
idServer of the notification for join requests.
Upload and preview files. Send a file message by calling the method.
Process an image
This method receives a set of image operations, and processes the images in order of operations. The optional operations include:
For the parameters required for each operation, see the above methods. In addition to the parameters listed in the above methods, each operation needs to provide the operation types:
// Rotate after cropping
var url = 'http://nim.nos.netease.com/MTAxMTAwMg==/bmltYV8xNDc5OTNfMTQ0MzE0NTgyNDI0M184YjFkYTMwMS02NjcxLTRiYjktYTUwZC04ZTVlZjZlNzZjMzA=';
nim.processImage({
url: url,
ops: [
{
type: 'crop',
x: 100,
y: 0,
width: 250,
height: 250,
},
{
type: 'thumbnail',
mode: 'cover',
width: 80,
height: 80
}
],
done: processImageDone
});
function processImageDone(error, obj) {
console.log('Processing the image' + (!error?'success':'failure'), error, obj);
}
Operation sequence. Process images sequentially according to the order of operations. For the specific format, see the previous image processing interfaces
Similar effects
[ { type: 'crop', x: 100, y: 0, width: 250, height: 250, }, { type: 'thumbnail', mode: 'cover', width: 80, height: 80 } ]
URL of the returned image
When an event is published, subscribers will get notified by onpushevents.
Events are divided into two categories:
broadcast broadcast types
1: Online users only 2: Online and offline users
Custom event extension property
Specify whether to sync the broadcast message for the current user
Event type, only 1 is available.
The validity time of published events in seconds, 60s~7 days (604800s), and the default value is 7 days
Event status/event content, custom mapping is supported.
Note: the value must be greater than 10000 (1-9999 is the predefined value range for CommsEase, 1: online, 2: offline, 3: disconnected.
Modify the image quality
Image quality, integer, value range: 0-100
Original URL to the image stored in NOS
URL of the returned image
Get the subscription by account
Event type, only 1 is available
Event type, only 1 is available
Unsend a message.
Within the validity time after a message is sent (2 minutes by default, which can be configured in the CommsEase console), the sender can unsend the sent private message or group message.
Unsending a messages in private chats is different from group chats:
Custom text for push notifications
Additional information, JSON string is recommended
Environment for messaging webhooks
message to be unsent
Additional message
Custom properties for push notifications, must be JSON string.
Reject a friend request. When the function is invoked,
an administrator rejects a request to join a group
If a request is reject:
accountId of the requester
idServer of the notification for join requests.
Additional Information
Reject the invitation to join a group
A user rejects the invitation:
accountId of the requester
idServer of the notification for invitation from an administrator.
Additional Information
an administrator rejects a request to join a group
If a request is reject:
accountId of the requester
idServer of the notification for join requests.
Additional Information
Reject the invitation to join a group
A user rejects the invitation:
accountId of the requester
idServer of the notification for invitation from an administrator.
Additional Information
Remove all listeners, or those of the specified event.
Remove from blocklist The onblacklist callback is triggered during initialization and onsyncmarkinblacklist triggered during synchronization across devices.
Target account ID
Whether the account is included in the blocklist or the list of muted members.
true: Yes, false: No.
Details of the operation record
Target account ID
Update timestamp
Remove from the list of muted users. The onmutelist callback is triggered during initialization and onsyncmarkinmutelist triggered during synchronization across devices.
The list of muted users:
Target account ID
Whether the account is included in the blocklist or the list of muted members.
true: Yes, false: No.
Details of the operation record
Target account ID
Update timestamp
Remove the listeners of a given event.
Remove an administrator
If administrators are added:
Remove a member
List of group member accounts to be kicked out
Remove an administrator
If administrators are added:
Remove a member
List of group members to be kicked out
Reset the unread count for all conversations.
Cancels the effect of "setCurrSession". After cancellation, the unread count will change after the conversation receives new messages.
Reset the unread count for a conversation. To reset the unread count of a superTeamSessionsUnread, use SessionInterface.resetSuperTeamSessionsUnread.
Reset the unread count for some conversations. To reset the unread count of supergroups, use SessionInterface.resetSuperTeamSessionsUnread
Reset the unread count for some supergroups
Rotate an image
Rotation angle
Original URL to the image stored in NOS
URL of the returned image
Store the message to the local database
Note: If the operating environment does not support the database, or the database is not running, the execution is successful, but no valid data will be returned or operated.
Path for search. If unspecified, all fields below will be searched
Keyword for search
If the capabilities provided by the SDK don't meet your business needs, this interface can send custom message in private or group chats, such as rock-paper-scissors and dice-throwing.
This interface returns the message body in the sending state, and the sent message body needs to be obtained by passing options.done.
Calling this API can trigger:
nim.sendCustomMsg({
scene: 'p2p',
to: 'account',
//The recipient receives the message using onMsg
//if msg.type === 'custom', the recipient reads msg.content and then calls the business code
content: JSON.stringify({type: 1}),
done: function(err, msg) {
if (err) {
console.log('Failed to send the message', err)
} else {
console.log('Message sent: ', msg)
}
}
})
Send a custom system notification
Note, the difference between custom system notification (sendCustoSysmMsg) and custom message (sendCustomMsg) is as follows:
Custom content for APNS service for system notifications, only valid for recipients of iOS devices.
Whether the notification is synced using sync webhook. The default value is true
Custom content of the system message, JSON serialized string recommended.
The environment variable pointing to different types of configurations for state sync and third-party callbacks.
Whether push notifications is required . Default value: true
Whether the nickname is required for push notifications. The default value is false.
Custom content of the system notification, JSON serialized string recommended.
Scenarios are divided into private chat(p2p), group chat(team), and supergroup chat(superTeam).
Whether to send notifications only to online users. The default value is true.
true. Only sent to online users, if the receiver is not online, this notification will be discarded. It is suitable for the scene of "typing indicators"
false. If the recipient is online, the notification will be received immediately. If the recipient is not online, an system notification will be pushed after the recipient goes online.
Recipient account ID, or group ID.
Calling this API can trigger:
nim.sendFile({
scene: 'p2p',
to: 'account',
type: 'image',
fileInput: 'domId',
done: function(err, obj) {
if (err) {
console.log('Failed to send the message', err)
// Resend a message. When the file upload fails, the msg of the obj parameter has a message body, and in other cases, the obj is the message body.
setTimeout(function () {
resendMessage(obj.msg ? obj.msg : obj)
}, 3000)
} else {
console.log('Message sent: ', obj)
}
}
})
// Get the idClient for rendering before uploading
console.log(message.idClient)
// Resend the message
function resendMessage(oldMessage) {
nim.sendFile(Object.assign(oldMessage, {
scene: 'p2p',
to: 'account',
type: 'image',
fileInput: 'domId',
resend: true, // Note that this resend is set to true, so that the idClient in oldMessage can be used permanently
done: function(err, obj) {
if (err) {
console.log('Failed to send the message', err)
} else {
console.log('Message sent: ', obj)
}
}
}))
}
nim.previewFile({
type: 'image',
fileInput: fileInput,
uploadprogress: function(obj) {
console.log('file size: ' + obj.total + 'bytes');
console.log('uploaded size: ' + obj.loaded + 'bytes');
console.log('Upload progress: ' + obj.percentage);
console.log('Upload progress in percentage: ' + obj.percentageText);
},
done: function(error, file) {
console.log('Uploading the image' + (!error?'success':'failure'));
// show file to the user
if (!error) {
var msg = nim.sendFile({
scene: 'p2p',
to: 'account',
file: file,
done: sendMsgDone
});
console.log('Sending the image message , id=' + msg.idClient);
pushMsg(msg);
}
}
})
Send a geolocation message to target users, groups, or supergroups.
This interface returns the message body in the sending state, and the sent message body needs to be obtained by passing options.done.
Calling this API can trigger:
nim.sendGeo({
scene: 'p2p',
to: 'account',
//The recipient receives the message using onMsg
//if msg.type === 'geo', the recipient reads msg.geo, and then calls the business code
geo: {
lng: 116.3833,
lat: 39.9167,
title: 'Beijing'
},
done: function(err, msg) {
if (err) {
console.log('Failed to send the message', err)
} else {
console.log('Message sent: ', msg)
}
}
})
Send a read receipt in a private chat.
In the private chat, User B marks the message as read after receiving the message sent by User A.
There are two ways to receive read receipts:
Calling this API triggers the NIMGetInstanceOptions.onupdatesessions callback.
message whose read receipt to be sent
Send read receipt for group messages. If the sender is online and has registered onTeamMsgReceipt during initialization, the client will receive a notification that the group message has been read.
Note that the sender must set needMsgReceipt = true before the recipient can send the read receipt for the group message.
There are two ways to receive read receipts:
Calling this API method triggers: onTeamMsgReceipt callback
//Message sender
nim.sendText({
scene: 'team',
to: 'teamId',
text: "Hello",
// Note that this field must be set to true
needMsgReceipt: true
})
// Recipient
nim.sendTeamMsgReceipt({
teamMsgReceipts: [{
teamId: 'teamId',
idClient: 'xxxx',
idServer: 'yyyy'
}]
})
List of group messages whose read receipt to be sent
Send a message to a private chat, group channel, or supergroup channel
This interface returns the message body in the sending state, and the sent message body needs to be obtained by passing options.done.
Calling this API can trigger:
nim.sendText({
scene: 'p2p',
to: 'account',
text: 'hello',
done: function(err, msg) {
if (err) {
console.log('Failed to send the message', err)
} else {
console.log('Message sent: ', msg)
}
}
})
Send an alert a target user, group, or supergroup. Alerts are sent for notifications in a conversation. Typical use cases include welcome messages when joining a group or tips when hitting keywords for moderation in chats.
This interface returns the message body in the sending state, and the sent message body needs to be obtained by passing options.done.
Calling this API can trigger:
nim.sendTipMsg({
scene: 'p2p',
to: 'account',
//The recipient receives the message using onMsg
//if msg.type === 'tip', the recipient reads msg.tip, and then calls the business code
tip: 'tip content',
done: function(err, msg) {
if (err) {
console.log('Failed to send the message', err)
} else {
console.log('Message sent: ', msg)
}
}
})
Set "join the current conversation"
Note: This is an easy-to-use composite interface . The logic is: record the current conversation in memory, call resetSessionUnread to clear the unread count when joining the conversation, and use resetSessionUnread to clear the unread count when new messages are received onMsg.
Update the initialization parameters of the original NIM instance. The configurable parameters are the same as those of the NIM.getInstance method.
Any scenario that needs to update parameters for initialization. For example:
Accept an invitation to join a channel.
ID of the account that sends the invitation
The additional information of the operation sent to others
Whether to join the channel directly by accepting the invitation. true by default
Channel ID
Additional Information for joining a channel, The information is included in the notification sent to other members.
Whether the message is stored for offline users. The default value is false
Request ID must be specified by the inviter and is used for canceling, rejecting, or accepting invitations.
UID of the current user in the channel The value must be greater than 0. If the uid becomes invalid, the server will assign a random uid.
Join an audio and video call. Create and join a channel, and invite the peer to join the channel
Note that this is a combined interface, equivalent to calling signalingCreateAndJoin and signalingInvite.
ID of an invited member
The additional information of the operation is passed to the invited user
Channel name
Extension field
Whether the message is stored for offline users. The default value is false
Properties of a push notification
Request ID must be specified by the inviter and is used for canceling, rejecting, or accepting invitations.
Channel type, call type 1: Audio; 2: video; 3: Others
The uid of the current user in the channel. The value must be greater than 0. If the ID becomes invalid, the server will assign a random uid.
Join an audio and video call. Create and join a channel, and invite the peer to join the channel
Note that this is a combined interface with parameters for audio and video calling compared with signalingCall.
ID of an invited member
The additional information of the operation is passed to the invited user
Channel name
Extension field
The name of an RTC room. the SDK will take this parameter when joining the channel, and return the token
Parameters for requests to join an RTC room. Serialized data in JSON is recommended
The validity period of the token, indicating the expiration time of the token, in seconds, optional. The default duration is 10 minutes.
Whether the message is stored for offline users. The default value is false
Properties of a push notification
Request ID must be specified by the inviter and is used for canceling, rejecting, or accepting invitations.
Channel type, call type 1: Audio; 2: video; 3: Others
The uid of the current user in the channel. The value must be greater than 0. If the ID becomes invalid, the server will assign a random uid.
Cancel an invitation
ID of an invited member
The additional information of the operation is passed to the invited user
Channel ID
Whether the message is stored for offline users. The default value is false
Request ID must be specified by the inviter and is used for canceling, rejecting, or accepting invitations.
Close a channel
The additional information of the operation sent to others
Channel ID
Whether the message is stored for offline users. The default value is false
Send a custom signal
Target account (account id) to be notified If unspecified, all members are notified
The additional information of the operation sent to others
Channel ID
Create a channel.
Channel name
Extension field
Channel type, call type 1: Audio; 2: video; 3: Others
If the room does not exist, create and join a channel. If the channel already exists, join the channel.
Note that this is a combined interface, equivalent to calling signalingCreate and signalingJoin.
The additional information of the operation is passed to the invited user
Channel name
Extension field
Whether the message is stored for offline users. The default value is false
Channel type, call type 1: Audio; 2: video; 3: Others
The uid of the current user in the channel. The value must be greater than 0. If the ID becomes invalid, the server will assign a random uid.
Extend the expiration time of a channel
Note that SDK v9.8.0 supports automatic extension of the expiration time of a channel.
Unique channel ID
Get the channel information by channel name
Channel name
Invite a user to join the channel.
ID of an invited member
The additional information of the operation is passed to the invited user
Channel ID
Whether the message is stored for offline users. The default value is false
Properties of a push notification
Request ID must be specified by the inviter and is used for canceling, rejecting, or accepting invitations.
Join a channel
The additional information of the operation sent to others
Channel ID
Whether the message is stored for offline users. The default value is false
The uid of the current user in the channel. The value must be greater than 0. If the ID becomes invalid, the server will assign a random uid.
Join a channel and accept an invitation. This interface combines two interfaces, equivalent to joining a channel and accepting an invitation
Peer accid, required
The additional information of the operation sent to others
Channel ID
The name of an RTC room. the SDK will take when joining the channel, and return the token
Parameters for requests to join an RTC room. Serialized data in JSON is recommended
The validity period of the token, indicating the expiration time of the token, in seconds, optional. The default duration is 10 minutes.
Whether notifications are required for offline messages. The default value is false
Required, the request ID must be specified by the inviter and is used for canceling, rejecting, or Required< accepting invitations.
The uid of the current user in the channel. The value must be greater than 0. If the ID becomes invalid, the server will assign a random uid.
The additional information of the operation sent to others
Channel ID
Whether the message is stored for offline users. The default value is false
Mark the message read. The message will not be received as offline messages.
ID of a signaling message that needs to be marked.
Reject an invitation to join a channel.
ID of the account that sends the invitation
The additional information of the operation sent to others
Channel ID
Whether the message is stored for offline users. The default value is false
Request ID must be specified by the inviter and is used for canceling, rejecting, or accepting invitations.
Remove the metadata of an image
Subscribes to events published by specified users Whether it is a built-in online status event or a custom event, you must subscribe to the event using this API.
List of subscription accounts
Subscription validity period, in seconds
Whether to synchronize the latest events immediately after subscribing
Event type, only 1 is available
Generate the thumbnails of an image
'cover': The original image is scaled in proportion, one side of the thumbnail is equal to the requested size, and the other side is larger than the requested size, that is, the thumbnail can just cover the rectangle with the size of width*height'contain': The original image is proportional to the thumbnail, one side of the thumbnail is equal to the requested size, and the other side is larger than the requested size, that is, a rectangle with a size of width*height can just cover the thumbnail'crop': First get the thumbnail based on the original image proportionally so that one side is equal to the requested size and the other side is larger than the requested size, and then crop the side larger than the requested size so that the final image size is exactly equal to the requested size (Note: the crop mode does not support thumbnails to GIFs)'crop' mode, parameters axis.x or axis.y can be used to control the position of the last cropping step.Coordinates for cropping
C coordinate, must be an integer
Y coordinate, must be an integer
Height of an thumbnail
Original URL to the image stored in NOS
Width of an thumbnail
URL of the returned image
Transfer the ownership of a supergroup. The group owner can perform the action
Whether to leave the group while transferring the ownership of the group
Transfer the ownership of a group, the group owner can perform the action
Whether to leave the group while transferring the ownership of the group
Unsubscribe from events by account
Event type, only 1 is available
Unsubscribe from all specific events.
Event type, only 1 is available
Update collections, only custom fields can be updated.
Collection object. Only the custom field can be updated, and you can use the new custom field into this object.
Note: If you want to delete the custom field, unspecify the custom field.
Update the alias and extension fields for friends. The logged in clients get notified by onsyncfriendaction.
Alias
Extension field
Edit the profile of the current user
Extension field
Alert strategy
"0": turn on alerts "1": turn off alerts "2": turn on alerts for notifications from administrators
Nickname in a group
Note: After updating the nickname, all other online group members will get notified byonupdateteammember.
Edit the profile of the current user in the group
Extension field
Alert strategy
"0": turn on alerts "1": turn off alerts "2": turn on alerts for notifications from administrators
Nickname in a group
Note: After updating the nickname, all other online group members will get notified byonupdateteammember.
Update local messages. Only localCustom local custom extension fields are allowed to be updated.
If the runtime environment does not support the database, or the database is not running, the execution is successful, but no valid data will be returned.
local custom extension field
Update conversations in the local database
Update system notifications in the local database
idServer of a system message.
Custom field
status
Update PIN messages. The onPinMsgChange callback is triggered for synchronization across devices.
Note: Only extension fields can be updated
The structure of pinned messages
The extension field of PIN messages
Update the mute state of a member
Whether to mute the member
Update the profile of the current user. The onmyinfo callback is triggered during initialization and onupdatemyinfo triggered during synchronization across devices.
Business ID for moderation
avatar
date of birth
Extension field
Gender
Nickname
Signature
Phone number
Edit the nickname of a member
All online group members get notified by onUpdateSuperTeamMember and onUpdateSuperTeam
Nickname in a group
Note: After updating the nickname, all other online group members will get notified byonupdateteammember.
Edit the nickname of a member
All online group members get notified by onupdateteammember and onUpdateTeam
Nickname in a group
Note: After updating the nickname, all other online group members will get notified byonupdateteammember.
Extension field. Visible for the current user.
Messaging scenario
Recipient.
Update the pinned conversations (only the extension fields can be updated). all logged-in users of the current account will get notified by the onupdatesessions callback
sessionId
For example p2p-cs1, team-113879441
the extension field of pinned conversations.
Update the supergroup profile
Group announcement
Business ID for moderation configured in the CommsEase console.
Group avatar
Verification method for invitations
Extension field
Group introduction
Invitation mode
Join method
Group name
Group ID
Permissions for editing custom fields of a group profile
Permissions for editing the group profile
Update the mute state of a member
All group members (except the sender) trigger onmsg:
All group members get notified by onupdatesessions
All group members get notified by onUpdateSuperTeamMembersMute
Whether to mute the group
Mute all supergroup members
Whether to mute the group
Update the group profile.
Group announcement
Business ID for moderation configured in the CommsEase console.
Group avatar
Verification method for invitations
Extension field
Group introduction
Invitation mode
Join method
Group name
Group ID
Permissions for editing custom fields of a group profile
Permissions for editing the group profile
accept an invitation to join the group SuperTeamInterface.addSuperTeamMembers
Group owners and administrators invite users to join the group ({@link TeamInterface.addSuperTeamMembers | addSuperTeamMembers}), and the invited users will receive a system notification of type
superTeamInvite.acceptSuperTeamInvite, the specific content of the notification message is as follows.rejectSuperTeamInvite, the value of thefromfield is the account ID of the user who rejects the invitation, and the value of thetofield is thegroup IDIf a user accepts an invitation to join a group,
Associated function