diff --git a/agora-chat/develop/ip_allowlist.mdx b/agora-chat/develop/ip_allowlist.mdx new file mode 100644 index 000000000..a99ad5f58 --- /dev/null +++ b/agora-chat/develop/ip_allowlist.mdx @@ -0,0 +1,13 @@ +--- +title: 'TCP/TLS IP allowlist' +sidebar_position: 7 +type: docs +description: > + Describes the TCP/TLS IP allowlist function +--- + +import IpAllowlist from '@docs/shared/chat-sdk/reference/_ip_allowlist.mdx'; + +export const toc = [{}]; + + \ No newline at end of file diff --git a/agora-chat/develop/ip_whitelist.mdx b/agora-chat/develop/ip_whitelist.mdx index 30ba21f04..db326668c 100644 --- a/agora-chat/develop/ip_whitelist.mdx +++ b/agora-chat/develop/ip_whitelist.mdx @@ -1,13 +1,13 @@ --- -title: 'IP whitelist' +title: 'RESTful API IP whitelist' sidebar_position: 6 type: docs description: > - Describes the IP whitelist function + Describes the RESTful API IP whitelist function --- import IpWhitelist from '@docs/shared/chat-sdk/reference/_ip_whitelist.mdx'; export const toc = [{}]; - \ No newline at end of file + diff --git a/agora-chat/develop/proxy.mdx b/agora-chat/develop/proxy.mdx new file mode 100644 index 000000000..f8cdb1d4a --- /dev/null +++ b/agora-chat/develop/proxy.mdx @@ -0,0 +1,13 @@ +--- +title: 'Cross-border dedicated proxy' +sidebar_position: 7 +type: docs +description: > + Describes the cross-border dedicated proxy function +--- + +import CrossBorderProxy from '@docs/shared/chat-sdk/develop/_cross_border_proxy.mdx'; + +export const toc = [{}]; + + \ No newline at end of file diff --git a/assets/images/chat/callback_addr_list.png b/assets/images/chat/callback_addr_list.png new file mode 100644 index 000000000..2f188b242 Binary files /dev/null and b/assets/images/chat/callback_addr_list.png differ diff --git a/assets/images/chat/callback_secret.png b/assets/images/chat/callback_secret.png new file mode 100644 index 000000000..b8d65dd8d Binary files /dev/null and b/assets/images/chat/callback_secret.png differ diff --git a/shared/chat-sdk/client-api/chat-group/manage-chat-groups/project-implementation/android.mdx b/shared/chat-sdk/client-api/chat-group/manage-chat-groups/project-implementation/android.mdx index f9910f455..d388f368f 100644 --- a/shared/chat-sdk/client-api/chat-group/manage-chat-groups/project-implementation/android.mdx +++ b/shared/chat-sdk/client-api/chat-group/manage-chat-groups/project-implementation/android.mdx @@ -51,27 +51,35 @@ ChatClient.getInstance().groupManager().leaveGroup(groupId); ### Retrieve the member list of a chat group -To retrieve the member list of a chat group, choose the method based on the group size: +- When a group has less than 200 members, you can call the `getGroupFromServer` method to retrieve the group member list that contains the group owner, admins, and regular members. -- If the members of a chat group are greater than or equal to 200, list members of the chat group by page. -- If the members of a chat group are less than 200, call `getGroupFromServer` to retrieve the member list of the chat group. - -Refer to the following sample code to retrieve the member list of a chat group: +```java +// If `true` is passed to the second parameter, the SDK returns the group member list that contains up to 200 group members. +// It is a synchronous method and may block the current thread. +Group group = ChatClient.getInstance().groupManager().getGroupFromServer(groupId, true); +List memberList = group.getMembers();// gets regular members. +memberList.addAll(group.getAdminList());// gets group admins. +memberList.add(group.getOwner());// gets the group owner. +``` +- When a group has more than 200 members, you can first call the `getGroupFromServer` method to get the group member list that contains the group owner and admins and then call the `fetchGroupMembers` method to obtain the list of regular group members. ```java -// List members of a chat group by page. -List memberList = new ArrayList<>; +// If `true` is passed to the second parameter, the SDK returns the group member list that contains up to 200 group members. +// It is a synchronous method and may block the current thread. +Group group = ChatClient.getInstance().groupManager().getGroupFromServer(groupId, true); + +List memberList = new ArrayList<>(); CursorResult result = null; final int pageSize = 20; do { + // It is a synchronous method and may block the current thread. The asynchronous method is asyncFetchGroupMembers(String, String, int, ValueCallBack). result = ChatClient.getInstance().groupManager().fetchGroupMembers(groupId, result != null? result.getCursor(): "", pageSize); memberList.addAll(result.getData()); -} while (!TextUtils.isnull(result.getCursor()) && result.getData().size() == pageSize); +} while (!TextUtils.isEmpty(result.getCursor()) && result.getData().size() == pageSize); -// Call getGroupFromServer to retrieve the member list of a chat group. -Group group = ChatClient.getInstance().groupManager().getGroupFromServer(groupId, true); -List memberList = group.getMembers(); + memberList.addAll(group.getAdminList());// gets group admins. + memberList.add(group.getOwner());// gets the group owner. ``` ### Block and unblock a chat group diff --git a/shared/chat-sdk/client-api/chat-group/manage-chat-groups/project-implementation/ios.mdx b/shared/chat-sdk/client-api/chat-group/manage-chat-groups/project-implementation/ios.mdx index 41b1d2138..2bd2319a6 100644 --- a/shared/chat-sdk/client-api/chat-group/manage-chat-groups/project-implementation/ios.mdx +++ b/shared/chat-sdk/client-api/chat-group/manage-chat-groups/project-implementation/ios.mdx @@ -67,35 +67,39 @@ do { ### Retrieve the member list of a chat group -To retrieve the member list of a chat group, choose the method based on the size of the chat group: +- When a group has less than 200 members, you can call the `getGroupSpecificationFromServerWithId` method to retrieve the group member list that contains the group owner, admins, and regular members. -- If the number of chat group members is greater than or equal to 200, list members of the chat group by page. -- If the number of chat group members is less than 200, call `getGroupSpecificationFromServerWithId` to retrieve the member list of the chat group. +```objc +// If `true` is passed to the second parameter, the SDK returns the group member list that contains up to 200 group members. +// It is a synchronous method. The asynchronous method is [AgoraChatGroupManager getGroupSpecificationFromServerWithId:fetchMembers:completion:]. +AgoraChatGroup *group = [[AgoraChatClient sharedClient].groupManager + getGroupSpecificationFromServerWithId:@"groupID" + fetchMembers:YES + error:nil]; +NSArray *memberList = group.memberList; +``` -Refer to the following sample code to retrieve the member list of a chat group: +- When a group has more than 200 members, you can first call the `getGroupSpecificationFromServerWithId` method to get the group member list that contains the group owner and admins and then call the `getGroupMemberListFromServerWithId` method to obtain the list of regular group members. ```objc -// List members of a chat group by page. +AgoraChatGroup *group = [[AgoraChatClient sharedClient].groupManager + getGroupSpecificationFromServerWithId:@"groupID" + fetchMembers:NO + error:nil]; NSMutableArray *memberList = [[NSMutableArray alloc]init]; NSInteger pageSize = 50; NSString *cursor = nil; AgoraChatCursorResult *result = [[AgoraChatCursorResult alloc]init]; do { - result = [[AgoraChatClient sharedClient].groupManager - getGroupMemberListFromServerWithId:@"groupID" - cursor:cursor - pageSize:pageSize - error:nil]; - [memberList addObjectsFromArray:result.list]; - cursor = result.cursor; + // It is a synchronous method. The asynchronous method is [AgoraChatGroupManager getGroupMemberListFromServerWithId:cursor:pageSize:completion:]. + result = [[AgoraChatClient sharedClient].groupManager + getGroupMemberListFromServerWithId:@"groupID" + cursor:cursor + pageSize:pageSize + error:nil]; + [memberList addObjectsFromArray:result.list]; + cursor = result.cursor; } while (result && result.list < pageSize); - -// Call getGroupSpecificationFromServerWithId to retrieve the member list of a chat group. -AgoraChatGroup *group = [[AgoraChatClient sharedClient].groupManager - getGroupSpecificationFromServerWithId:@"groupID" - fetchMembers:YES - error:nil]; -NSArray *memeberList = [group.memberList]; ``` ### Block and unblock a chat group diff --git a/shared/chat-sdk/client-api/chat-group/manage-group-members/project-implementation/android.mdx b/shared/chat-sdk/client-api/chat-group/manage-group-members/project-implementation/android.mdx index e168cb860..b0a3b8700 100644 --- a/shared/chat-sdk/client-api/chat-group/manage-group-members/project-implementation/android.mdx +++ b/shared/chat-sdk/client-api/chat-group/manage-group-members/project-implementation/android.mdx @@ -83,6 +83,7 @@ Refer to the following sample code to manage the chat group mute list: ```java // The chat group owner and admins can call muteGroupMember to add the specified member to the chat group mute list. The muted member and all the other chat group admins or owner receive the onMuteListAdded callback. +// If you pass `-1` to `duration`, members are muted permanently. ChatClient.getInstance().groupManager().muteGroupMembers(groupId, muteMembers, duration); // The chat group owner and admins can call unmuteGroupMember to remove the specified user from the chat group mute list. The unmuted member and all the other chat group admins or owner receive the onMuteListRemoved callback. diff --git a/shared/chat-sdk/client-api/chat-room/_manage-chatrooms.mdx b/shared/chat-sdk/client-api/chat-room/_manage-chatrooms.mdx index fff7acc9d..77ec181e7 100644 --- a/shared/chat-sdk/client-api/chat-room/_manage-chatrooms.mdx +++ b/shared/chat-sdk/client-api/chat-room/_manage-chatrooms.mdx @@ -4,7 +4,7 @@ import ProjectImplement from '@docs/shared/chat-sdk/client-api/chat-room/manage- Chat rooms enable real-time messaging among multiple users. -Chat rooms do not have a strict membership, and members do not retain any permanent relationship with each other. Once a chat room member goes offline, this member does not receive any push messages from the chat room and automatically leaves the chat room after 5 minutes. Chat rooms are widely applied in live broadcast use cases such as stream chat in Twitch. +Chat rooms do not have a strict membership, and members do not retain any permanent relationship with each other. Once going offline, chat room members cannot receive any messages from the chat room and automatically leave the chat room after 2 minutes. Chat rooms are widely applied in live broadcast use cases such as stream chat in Twitch. This page shows how to use the Chat SDK to create and manage a chat room in your app. diff --git a/shared/chat-sdk/client-api/chat-room/manage-chatrooms/project-implementation/ios.mdx b/shared/chat-sdk/client-api/chat-room/manage-chatrooms/project-implementation/ios.mdx index 2ac661699..51466d863 100644 --- a/shared/chat-sdk/client-api/chat-room/manage-chatrooms/project-implementation/ios.mdx +++ b/shared/chat-sdk/client-api/chat-room/manage-chatrooms/project-implementation/ios.mdx @@ -9,8 +9,7 @@ Only the chat room owner can disband a chat room. Once a chat room is disbanded, ```objc // The super admin can call createChatroomWithSubject to create a chat room. AgoraChatError *error = nil; -AgoraChatroom *retChatroom = [[AgoraChatClient sharedClient].roomManager createChatroomWithSubject:@"aSubject" description:@"aDescription" invitees:@[@"user1",@[user2]]message:@"aMessage" maxMembersCount:aMaxMembersCount error:&error]; - +AgoraChatroom *retChatroom = [[AgoraChatClient sharedClient].roomManager createChatroomWithSubject:@"aSubject" description:@"aDescription" invitees:@[@"user1",@"user2"]message:@"aMessage" maxMembersCount:aMaxMembersCount error:&error]; // The chat room owner can call destroyChatroom to disband a chat room. AgoraChatError *error = nil; [[AgoraChatClient sharedClient].roomManager destroyChatroom:self.chatroom.chatroomId error:&error]; @@ -30,7 +29,7 @@ AgoraChatError *error = nil; // All chat room members can call leaveChatroom to leave the specified chat room. AgoraChatError *error = nil; -[AgoraChatClient sharedClient].roomManager leaveChatroom:@"aChatroomId" error:&error]; +[[AgoraChatClient sharedClient].roomManager leaveChatroom:@"aChatroomId" error:&error]; ``` diff --git a/shared/chat-sdk/client-api/chat-room/manage-chatrooms/project-implementation/web.mdx b/shared/chat-sdk/client-api/chat-room/manage-chatrooms/project-implementation/web.mdx index df440ff44..cc6571f5d 100644 --- a/shared/chat-sdk/client-api/chat-room/manage-chatrooms/project-implementation/web.mdx +++ b/shared/chat-sdk/client-api/chat-room/manage-chatrooms/project-implementation/web.mdx @@ -70,7 +70,7 @@ To monitor the chat room events, you can call `addEventHandler` to listen for th ```javascript conn.addEventHandler("eventName", { - onGroupEvent: function(msg){ + onChatroomEvent: function(msg){ switch(msg.operation){ // Occurs when all the chat room members are unmuted. case 'unmuteAllMembers': diff --git a/shared/chat-sdk/client-api/contacts/project-implementation/android.mdx b/shared/chat-sdk/client-api/contacts/project-implementation/android.mdx index 1e13fc7b1..68616f887 100644 --- a/shared/chat-sdk/client-api/contacts/project-implementation/android.mdx +++ b/shared/chat-sdk/client-api/contacts/project-implementation/android.mdx @@ -84,6 +84,8 @@ You can add a specified user to your block list. Once you do that, you can still Call `addUserToBlackList` to add the specified user to the block list. +You can add any other users to the block list, regardless of whether they are on the contact list or not. Contacts are still displayed on the contact list even if they are added to the block list. After adding users to the block list, you can still send messages to them, but will not receive messages from them as they cannot send messages or friend requests to you. + ```java // The effect of true and false is the same. I can send messages to users on the blacklist, but I cannot receive them when they send me messages. ChatClient.getInstance().contactManager().addUserToBlackList(username,true); diff --git a/shared/chat-sdk/client-api/contacts/project-implementation/flutter.mdx b/shared/chat-sdk/client-api/contacts/project-implementation/flutter.mdx index 841e24efd..473b51e8a 100644 --- a/shared/chat-sdk/client-api/contacts/project-implementation/flutter.mdx +++ b/shared/chat-sdk/client-api/contacts/project-implementation/flutter.mdx @@ -124,9 +124,9 @@ try { ### Add a user to the block list -Call `addUserToBlockList` to add the specified user to the block list. Once you add a user to the block list, you can no longer receive messages from this user. +Call `addUserToBlockList` to add the specified user to the block list. -
Users can add any other chat user to their block list, regardless of whether this other user is a contact or not. A contact added to the block list remains in the contact list.
+You can add any other users to the block list, regardless of whether they are on the contact list or not. Contacts are still displayed on the contact list even if they are added to the block list. After adding users to the block list, you can still send messages to them, but will not receive messages from them as they cannot send messages or friend requests to you. ```dart // The user ID diff --git a/shared/chat-sdk/client-api/contacts/project-implementation/ios.mdx b/shared/chat-sdk/client-api/contacts/project-implementation/ios.mdx index 24deb853c..bf5a7fa38 100644 --- a/shared/chat-sdk/client-api/contacts/project-implementation/ios.mdx +++ b/shared/chat-sdk/client-api/contacts/project-implementation/ios.mdx @@ -30,32 +30,28 @@ Call `addContact` to add the specified user as a contact: Use `ContactListener` to add the following callback events. When a user receives a contact invitation, you can accept or decline the invitation. ```objc -/* - * Adds a contact manager delegate - */ +// Adds a contact manager delegate [[AgoraChatClient sharedClient].contactManager addDelegate:self delegateQueue:nil]; -/* - * Removes the contact manager delegate - */ +//Removes the contact manager delegate [[AgoraChatClient sharedClient].contactManager removeDelegate:self]; -``` -```objc -/* - * Occurs when a contact invitation is received. - * - * @param aUsername The username that sends the contact invitation. - * @param aMessage The invitation message. - */ - (void)friendRequestDidReceiveFromUser:(NSString *)aUsername message:(NSString *)aMessage { } - +// The peer user accepts the contact invitation. +- (void)friendRequestDidApproveByUser:(NSString *)aUsername +{ } +// The peer user declines the contact invitation. +- (void)friendRequestDidDeclineByUser:(NSString *)aUsername +{ } +// The contact is deleted. +- (void)friendshipDidRemoveByUser:(NSString *)aUsername +{ } ``` #### Accept or decline the contact invitation -After receiving `friendRequestDidReceiveFromUser`, call `approveFriendRequestFromUser` or `declineFriendRequestFromUser` to accept or decline the invitation. +After receiving `friendRequestDidReceiveFromUser`, call `approveFriendRequestFromUser` or `declineFriendRequestFromUser` to accept or decline the invitation. The peer user receives the `friendRequestDidApprove` or `friendRequestDidDecline` callback. ```objc /* @@ -160,9 +156,7 @@ NSArray *userlist = [[AgoraChatClient sharedClient].contactManager getContacts]; ### Manage the block list -You can add a specified user to your block list. Once you do that, you can still send chat messages to that user, but you cannot receive messages from them. - -
Users can add any other chat user to their block list, regardless of whether this other user is a contact or not. A contact added to the block list remains in the contact list.
+You can add any other users to the block list, regardless of whether they are on the contact list or not. Contacts are still displayed on the contact list even if they are added to the block list. After adding users to the block list, you can still send messages to them, but will not receive messages from them as they cannot send messages or friend requests to you. #### Add a user to the block list diff --git a/shared/chat-sdk/client-api/contacts/project-implementation/react-native.mdx b/shared/chat-sdk/client-api/contacts/project-implementation/react-native.mdx index 05e1d0862..2f31ae9d4 100644 --- a/shared/chat-sdk/client-api/contacts/project-implementation/react-native.mdx +++ b/shared/chat-sdk/client-api/contacts/project-implementation/react-native.mdx @@ -108,9 +108,9 @@ ChatClient.getInstance() ### Add a user to the block list -Call `addUserToBlockList` to add the specified user to the block list. Once you add a user to the block list, you can no longer receive messages from this user. +Call `addUserToBlockList` to add the specified user to the block list. -
Users can add any other chat user to their block list, regardless of whether this other user is a contact or not. A contact added to the block list remains in the contact list.
+You can add any other users to the block list, regardless of whether they are on the contact list or not. Contacts are still displayed on the contact list even if they are added to the block list. After adding users to the block list, you can still send messages to them, but will not receive messages from them as they cannot send messages or friend requests to you. ```typescript // Specify the user ID to be added to the block list. diff --git a/shared/chat-sdk/client-api/contacts/project-implementation/unity.mdx b/shared/chat-sdk/client-api/contacts/project-implementation/unity.mdx index a297f69b3..f18760c8a 100644 --- a/shared/chat-sdk/client-api/contacts/project-implementation/unity.mdx +++ b/shared/chat-sdk/client-api/contacts/project-implementation/unity.mdx @@ -114,9 +114,7 @@ Listlist = SDKClient.Instance.ContactManager.GetAllContactsFromDB(); ### Manage the block list -You can add a specified user to your block list. Once you do that, you can still send chat messages to that user, but you cannot receive messages from them. - -
Users can add any other chat user to their block list, regardless of whether this other user is a contact or not. A contact added to the block list remains in the contact list.
+ou can add any other users to the block list, regardless of whether they are on the contact list or not. Contacts are still displayed on the contact list even if they are added to the block list. After adding users to the block list, you can still send messages to them, but will not receive messages from them as they cannot send messages or friend requests to you. #### Add a user to the block list diff --git a/shared/chat-sdk/client-api/contacts/project-implementation/web.mdx b/shared/chat-sdk/client-api/contacts/project-implementation/web.mdx index 08e924844..f74994406 100644 --- a/shared/chat-sdk/client-api/contacts/project-implementation/web.mdx +++ b/shared/chat-sdk/client-api/contacts/project-implementation/web.mdx @@ -71,9 +71,7 @@ WebIM.conn.getContacts().then( (res) => { ### Manage the block list -You can add a specified user to your block list. Once you do that, you can still send chat messages to that user, but you cannot receive messages from them. - -
Users can add any other chat user to their block list, regardless of whether this other user is a contact or not. A contact added to the block list remains in the contact list.
+You can add any other users to the block list, regardless of whether they are on the contact list or not. Contacts are still displayed on the contact list even if they are added to the block list. After adding users to the block list, you can still send messages to them, but will not receive messages from them as they cannot send messages or friend requests to you. #### Add a user to the block list diff --git a/shared/chat-sdk/client-api/contacts/project-implementation/windows.mdx b/shared/chat-sdk/client-api/contacts/project-implementation/windows.mdx index 7de853e61..fda6cdc51 100644 --- a/shared/chat-sdk/client-api/contacts/project-implementation/windows.mdx +++ b/shared/chat-sdk/client-api/contacts/project-implementation/windows.mdx @@ -114,9 +114,7 @@ Listlist = SDKClient.Instance.ContactManager.GetAllContactsFromDB(); ### Manage the block list -You can add a specified user to your block list. Once you do that, you can still send chat messages to that user, but you cannot receive messages from them. - -
Users can add any other chat user to their block list, regardless of whether this other user is a contact or not. A contact added to the block list remains in the contact list.
+You can add any other users to the block list, regardless of whether they are on the contact list or not. Contacts are still displayed on the contact list even if they are added to the block list. After adding users to the block list, you can still send messages to them, but will not receive messages from them as they cannot send messages or friend requests to you. #### Add a user to the block list diff --git a/shared/chat-sdk/client-api/messages/_translate-messages.mdx b/shared/chat-sdk/client-api/messages/_translate-messages.mdx index 27efd2222..e9ec614dd 100644 --- a/shared/chat-sdk/client-api/messages/_translate-messages.mdx +++ b/shared/chat-sdk/client-api/messages/_translate-messages.mdx @@ -15,7 +15,7 @@ Before proceeding, ensure that your development environment meets the following - Your project integrates a version of the Chat SDK later than v1.0.3 and has implemented the basic real-time chat functionalities. - You understand the API call frequency limit as described in [Limitations](/agora-chat/reference/limitations). -- Because this feature is enabled by the Microsoft Azure Translation API, ensure that you understand the supported target languages as described in [Language support](https://docs.microsoft.com/en-us/azure). +- Because this feature is enabled by the Microsoft Azure Translation API, ensure that you understand the supported target languages as described in [Language support](https://learn.microsoft.com/en-us/azure/ai-services/translator/language-support). - Translation is not enabled by default. To use this feature, you need to subscribe to the **Pro** or **Enterprise** [pricing plan](/agora-chat/reference/pricing-plan-details) and enable it in [Agora Console](https://console.agora.io/).
Add-on fees are incurred if you use this feature. See [Pricing](/agora-chat/reference/pricing#optional-add-on-fee) for details.
diff --git a/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/android.mdx b/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/android.mdx index e04ea9800..94981105b 100644 --- a/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/android.mdx +++ b/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/android.mdx @@ -13,7 +13,7 @@ Map conversations = ChatClient.getInstance().chatManager() Refer to the following code sample to retrieve the messages in the specified conversation: ```java -Conversation conversation = ChatClient.getInstance().chatManager().getConversation(username); +Conversation conversation = ChatClient.getInstance().chatManager().getConversation(conversationId); // Gets all the messages in the current conversation. List messages = conversation.getAllMessages(); // Only one message is loaded during SDK initialization. Call loadMoreMsgFromDB to retrieve more messages. @@ -25,7 +25,7 @@ List messages = conversation.loadMoreMsgFromDB(startMsgId, pagesize Refer to the following code example to retrieve the count of unread messages: ```java -Conversation conversation = ChatClient.getInstance().chatManager().getConversation(username); +Conversation conversation = ChatClient.getInstance().chatManager().getConversation(conversationId); conversation.getUnreadMsgCount(); ``` @@ -42,7 +42,7 @@ ChatClient.getInstance().chatManager().getUnreadMessageCount(); Refer to the following code example to mark the specified messages as read: ```java -Conversation conversation = ChatClient.getInstance().chatManager().getConversation(username); +Conversation conversation = ChatClient.getInstance().chatManager().getConversation(conversationId); // Mark all the messages in the current conversation as read. conversation.markAllMessagesAsRead(); // Mark the specified message as read. @@ -59,9 +59,9 @@ To delete them on the local device, call `deleteConversation` and `removeMessage ```java // true indicates to keep the historical messages while deleting the conversation. To remove the historical messages as well, set it as true. -ChatClient.getInstance().chatManager().deleteConversation(username, true); +ChatClient.getInstance().chatManager().deleteConversation(conversationId, deleteMessages); // Delete the specified message in the current conversation. -Conversation conversation = ChatClient.getInstance().chatManager().getConversation(username); +Conversation conversation = ChatClient.getInstance().chatManager().getConversation(conversationId); conversation.removeMessage(deleteMsg.msgId); ``` @@ -101,10 +101,10 @@ If you want to insert a message to the current conversation without actually sen ```java // Insert a message to the specified conversation. -Conversation conversation = ChatClient.getInstance().chatManager().getConversation(username); +Conversation conversation = ChatClient.getInstance().chatManager().getConversation(conversationId); conversation.insertMessage(message); // Insert a message. -ChatClient.getInstance().chatManager().saveMessage(message); +// ChatClient.getInstance().chatManager().saveMessage(message); ``` \ No newline at end of file diff --git a/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/flutter.mdx b/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/flutter.mdx index dd2013d78..fe19d2a74 100644 --- a/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/flutter.mdx +++ b/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/flutter.mdx @@ -21,18 +21,14 @@ try { You can retrieve the messages in the specified conversation from the local database by specifying the conversation ID and chat type: ```dart -// The conversation ID. -String convId = "convId"; -// Whether to create a conversation if the specified one does not exist. If you set it as true, the SDK returns a conversation object. -bool createIfNeed = true; -// The conversation type. -ChatConversationType conversationType = ChatConversationType.Chat; -// Call getConversation to get the specified conversation. -ChatConversation? conversation = - await ChatClient.getInstance.chatManager.getConversation( - convId, - conversationType, - true, +// Retrieves the conversation ID +ChatConversation? conversation = await ChatClient.getInstance.chatManager + .getConversation(conversationId, type: ChatConversationType.Chat); +// Only one message is loaded during SDK initialization. Call loadMessages to retrieve more messages. +List messages = await conversation!.loadMessages( + startMsgId: startMsgId, + loadCount: count, + direction: ChatSearchDirection.Up, ); ``` diff --git a/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/ios.mdx b/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/ios.mdx index b64033fa0..fdad54c9e 100644 --- a/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/ios.mdx +++ b/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/ios.mdx @@ -14,7 +14,7 @@ Refer to the following code sample to retrieve the messages in the specified con ```objc // Retrieves the conversation ID -AgoraConversation *conversation = [[AgoraChatClient sharedClient].chatManager getConversation:conversationId type:type createIfNotExist:YES]; +AgoraChatConversation *conversation = [[AgoraChatClient sharedClient].chatManager getConversation:conversationId type:type createIfNotExist:YES]; // Only one message is loaded during SDK initialization. Call loadMessagesStartFromId to retrieve more messages. NSArray *messages = [conversation loadMessagesStartFromId:startMsgId count:count searchDirection:MessageSearchDirectionUp]; ``` @@ -25,7 +25,7 @@ Refer to the following code example to retrieve the count of unread messages: ```objc // Retrieves the ID of the specified conversation. -AgoraConversation *conversation = [[AgoraChatClient sharedClient].chatManager getConversation:conversationId type:type createIfNotExist:YES]; +AgoraChatConversation *conversation = [[AgoraChatClient sharedClient].chatManager getConversation:conversationId type:type createIfNotExist:YES]; // Retrieves the count of unread messages. NSInteger unreadCount = conversation.unreadMessagesCount; ``` @@ -38,7 +38,7 @@ Refer to the following code example to retrieve the count of all unread messages ```objc NSArray *conversations = [[AgoraChatClient sharedClient].chatManager getAllConversations]; NSInteger unreadCount = 0; -for (AgoraConversation *conversation in conversations) { +for (AgoraChatConversation *conversation in conversations) { unreadCount += conversation.unreadMessagesCount; } ``` @@ -49,11 +49,11 @@ for (AgoraConversation *conversation in conversations) { Refer to the following code example to mark the specified messages as read: ```objc -AgoraConversation *conversation = [[AgoraChatClient sharedClient].chatManager getConversation:conversationId type:type createIfNotExist:YES]; +AgoraChatConversation *conversation = [[AgoraChatClient sharedClient].chatManager getConversation:conversationId type:type createIfNotExist:YES]; // Marks all messages of the specified conversation as read. [conversation markAllMessagesAsRead:nil]; // Marks the specified message as read. -[onversation markMessageAsReadWithId:messageId error:nil]; +[conversation markMessageAsReadWithId:messageId error:nil]; ``` ### Delete conversations and historical messages @@ -69,7 +69,7 @@ To delete them on the local device, call `deleteConversation` and `removeMessage NSArray *conversations = @{@"conversationID1",@"conversationID2"}; [[AgoraChatClient sharedClient].chatManager deleteConversations:conversations isDeleteMessages:YES completion:nil]; // Deletes the specified message of the current conversation. -AgoraConversation *conversation = [[AgoraChatClient sharedClient].chatManager getConversation:conversationId type:type createIfNotExist:YES]; +AgoraChatConversation *conversation = [[AgoraChatClient sharedClient].chatManager getConversation:conversationId type:type createIfNotExist:YES]; [conversation deleteMessageWithId:.messageId error:nil]; ``` @@ -102,7 +102,7 @@ If you want to insert a message to the current conversation without actually sen ```objc // Inserts a message to the specified conversation. -AgoraConversation *conversation = [[AgoraChatClient sharedClient].chatManager getConversation:conversationId type:type createIfNotExist:YES]; +AgoraChatConversation *conversation = [[AgoraChatClient sharedClient].chatManager getConversation:conversationId type:type createIfNotExist:YES]; [conversation insertMessage:message error:nil]; ``` diff --git a/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/react-native.mdx b/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/react-native.mdx index 61c58d76d..ce215821a 100644 --- a/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/react-native.mdx +++ b/shared/chat-sdk/client-api/messages/manage-messages/project-implementation/react-native.mdx @@ -20,7 +20,7 @@ ChatClient.getInstance() You can retrieve the messages in the specified conversation from the local database by specifying the conversation ID and chat type: ```typescript -// Sepcify the conversation ID. +// Specify the conversation ID. const convId = "convId"; // Whether to create a conversation if the specified one does not exist. If you set it as true, this method always returns a conversation object. const createIfNeed = true; @@ -29,8 +29,8 @@ const convType = ChatConversationType.PeerChat; // Call getConversation to retrieve the specified conversation. ChatClient.getInstance() .chatManager.getConversation(convId, convType, createIfNeed) - .then((message) => { - console.log("Getting conversations succeeds", message); + .then((conversation) => { + console.log("Getting conversations succeeds", conversation); }) .catch((reason) => { console.log("Getting conversations fails.", reason); diff --git a/shared/chat-sdk/client-api/messages/manage-messages/understand/android.mdx b/shared/chat-sdk/client-api/messages/manage-messages/understand/android.mdx index be67fa2ad..7a6c20381 100644 --- a/shared/chat-sdk/client-api/messages/manage-messages/understand/android.mdx +++ b/shared/chat-sdk/client-api/messages/manage-messages/understand/android.mdx @@ -2,7 +2,7 @@ SQLCipher is used to encrypt the database that stores local messages. The Chat SDK uses `ChatManager` to manage local messages. Followings are the core methods: -- `loadAllConversations`: Loads the conversation list on the local device. +- `getAllConversations`: Loads the conversation list on the local device. - `deleteConversation`: Deletes the specified conversation locally. - `deleteConversationFromServer`: Delete a conversation from the server. - `Conversation.getUnreadMsgCount`: Retrieves the count of unread messages in the specified conversation. diff --git a/shared/chat-sdk/client-api/messages/message-receipts/project-implementation/android.mdx b/shared/chat-sdk/client-api/messages/message-receipts/project-implementation/android.mdx index fd174d020..60ccd7495 100644 --- a/shared/chat-sdk/client-api/messages/message-receipts/project-implementation/android.mdx +++ b/shared/chat-sdk/client-api/messages/message-receipts/project-implementation/android.mdx @@ -7,7 +7,10 @@ To send a message delivery receipt, take the following steps: 1. The message sender sets `setRequireDeliveryAck` in `ChatOptions` as `true` before sending the message: ```java - options.setRequireDeliveryAck(true); + ChatOptions chatOptions = new ChatOptions(); + chatOptions.setRequireDeliveryAck(true); + ... + ChatClient.getInstance().init(mContext, chatOptions); ``` 2. Once the recipient receives the message, the SDK triggers `onMessageDelivered` on the message sender's client, notifying the message sender that the message has been delivered to the recipient. @@ -19,11 +22,15 @@ To send a message delivery receipt, take the following steps: @Override public void onMessageReceived(List messages) { } - // Occurs when the message deliery receipt is received + // Occurs when the message delivery receipt is received @Override public void onMessageDelivered(List message) { } }; + // Register a message listener. + ChatClient.getInstance().chatManager().addMessageListener(msgListener); + // Remove the message listener when it is not used. + ChatClient.getInstance().chatManager().removeMessageListener(msgListener); ``` ### Conversation and message read receipts @@ -74,9 +81,9 @@ In one-to-one chats, the SDK supports sending both the conversation read receipt 1. Send a conversation read receipt when the recipient enters the conversation. ```java - // The message receiver calls ackMessageRead to send the conversation read receipt. + // The message receiver calls ackConversationRead to send the conversation read receipt. try { - ChatClient.getInstance().chatManager().ackMessageRead(conversationId); + ChatClient.getInstance().chatManager().ackConversationRead(conversationId); }catch (ChatException e) { e.printStackTrace(); } @@ -143,11 +150,11 @@ Follow the steps to implement chat message read receipts. ```java // Set setIsNeedGroupAck as true when sending the group message - ChatMessage message = ChatMessage.createTxtSendMessage(content, to); + ChatMessage message = ChatMessage.createTextSendMessage(content, to); message.setIsNeedGroupAck(true); ``` -2. After the group member reads the chat group message, call `sendAckMessage` from the group member's client to send a message read receipt: +2. After the group member reads the chat group message, call `ackGroupMessageRead` from the group member's client to send a message read receipt: ```java // Send the group message read receipt. @@ -198,7 +205,15 @@ Follow the steps to implement chat message read receipts. * @param startAckId The receipt ID from which you want to fetch. If you set it as null, the SDK fetches from the latest receipt. * @return The message receipt list and a cursor. */ - public void asyncFetchGroupReadAcks(final String msgId, final int pageSize,final String startAckId, final ValueCallBack> callBack) {} + ChatClient.getInstance().chatManager().asyncFetchGroupReadAcks(msgId, pageSize, startAckId, new ValueCallBack>() { + @Override + public void onSuccess(CursorResult value) {// Succeeded in getting the details of the read receipt. + } + @Override + public void onError(int error, String errorMsg) { + // Failed to get the details of the read receipt. + } + }); ``` \ No newline at end of file diff --git a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/android.mdx b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/android.mdx index cf8102677..5c972bc0c 100644 --- a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/android.mdx +++ b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/android.mdx @@ -45,7 +45,7 @@ ChatClient.getInstance().chatManager().asyncFetchHistoryMessage(conversationId, ### Delete historical messages from the server unidirectionally -Call `removeMessagesFromServer` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. Other chat users can still get the messages from the server. +Call `removeMessagesFromServer` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. The deleted messages are automatically removed from your local device. Other chat users can still get the messages from the server. ```java Conversation conversation = ChatClient.getInstance().chatManager().getConversation(username); @@ -70,9 +70,9 @@ conversation.removeMessagesFromServer(msgIdList, new CallBack() { }); ``` -### Delete conversations and related messages from the server +### Delete conversations and related messages from the server unidirectionally -Call `deleteConversationFromServer` to delete conversations and their historical messages from the server. After the conversations are deleted from the server, you and other users can no longer get them from the server. If the historical messages are deleted with the conversations, all users can no longer get the messages from the server. +Call `deleteConversationFromServer` to delete conversations and their historical messages unidirectionally from the server. After the conversations and messages are deleted from the server, you can no longer get them from the server. The deleted conversations still exist on your local device, but the messages are automatically removed from the device. Other chat users can still get the conversations and their historical messages from the server. ```java ChatClient.getInstance().chatManager().deleteConversationFromServer(conversationId, conversationType, isDeleteServerMessage, new CallBack() { diff --git a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/flutter.mdx b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/flutter.mdx index 8ed004019..79df7f9c7 100644 --- a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/flutter.mdx +++ b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/flutter.mdx @@ -47,7 +47,7 @@ try { ### Delete historical messages from the server unidirectionally -Call `deleteRemoteMessagesBefore` or `deleteRemoteMessagesWithIds` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. Other chat users can still get the messages from the server. +Call `deleteRemoteMessagesBefore` or `deleteRemoteMessagesWithIds` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. The deleted messages are automatically removed from your local device. Other chat users can still get the messages from the server. ```dart try { @@ -68,9 +68,9 @@ try { } on ChatError catch (e) {} ``` -### Delete conversations and related messages from the server +### Delete conversations and related messages from the server unidirectionally -Call `deleteRemoteConversation` to delete conversations and their historical messages from the server. After the conversations are deleted from the server, you and other users can no longer get them from the server. If the historical messages are deleted with the conversations, all users can no longer get the messages from the server. +Call `deleteRemoteConversation` to delete conversations and their historical messages unidirectionally from the server. After the conversations and messages are deleted from the server, you can no longer get them from the server. The deleted conversations still exist on the local device, but the messages are automatically removed from your local device. Other chat users can still get the conversations and their historical messages from the server. ```dart try { diff --git a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/ios.mdx b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/ios.mdx index 8891b59b0..5223cf51c 100644 --- a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/ios.mdx +++ b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/ios.mdx @@ -31,7 +31,7 @@ To ensure data reliability, we recommend retrieving less than 50 historical mess ### Delete historical messages from the server unidirectionally -Call `removeMessagesFromServerWithTimeStamp` or `removeMessagesFromServerMessageIds` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. Other chat users can still get the messages from the server. +Call `removeMessagesFromServerWithTimeStamp` or `removeMessagesFromServerMessageIds` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. The deleted messages are automatically removed from your local device. Other chat users can still get the messages from the server. ```objective-c // Delete messages by timestamp @@ -45,9 +45,9 @@ AgoraChatConversation* conversation = [AgoraChatClient.sharedClient.chatManager }]; ``` -### Delete conversations and related messages from the server +### Delete conversations and related messages from the server unidirectionally -Call `deleteServerConversation` to delete conversations and their historical messages from the server. After the conversations are deleted from the server, you and other users can no longer get them from the server. If the historical messages are deleted with the conversations, all users can no longer get the messages from the server. +Call `deleteServerConversation` to delete conversations and their historical messages unidirectionally from the server. After the conversations and messages are deleted from the server, you can no longer get them from the server. The deleted conversations still exist on the local device, but the messages are automatically removed from the device. Other chat users can still get the conversations and their historical messages from the server. ```objective-c [AgoraChatClient.sharedClient.chatManager deleteServerConversation:@"conversationId1" conversationType:AgoraChatConversationTypeChat isDeleteServerMessages:YES completion:^(NSString *aConversationId, AgoraChatError *aError) { diff --git a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/react-native.mdx b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/react-native.mdx index 585751831..b40d0a013 100644 --- a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/react-native.mdx +++ b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/react-native.mdx @@ -50,7 +50,7 @@ ChatClient.getInstance() ### Delete historical messages from the server unidirectionally -Call `removeMessagesFromServerWithTimestamp` or `removeMessagesFromServerWithMsgIds` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. Other chat users can still get the messages from the server. +Call `removeMessagesFromServerWithTimestamp` or `removeMessagesFromServerWithMsgIds` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. The deleted messages are automatically removed from your local device. Other chat users can still get the messages from the server. ```typescript // Delete messages by message ID @@ -77,9 +77,9 @@ ChatClient.getInstance() }); ``` -### Delete conversations and related messages from the server +### Delete conversations and related messages from the server unidirectionally -Call `removeConversationFromServer` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. Other chat users can still get the messages from the server. +Call `removeConversationFromServer` to delete conversations and their historical messages unidirectionally from the server. After the conversations and messages are deleted from the server, you can no longer get them from the server. The deleted conversations still exist on the local device, but the messages are automatically removed from the device. Other chat users can still get the conversations and their historical messages from the server. ```typescript // convId: conversation ID diff --git a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/unity.mdx b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/unity.mdx index 0620ddf9b..3f426b626 100644 --- a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/unity.mdx +++ b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/unity.mdx @@ -40,7 +40,7 @@ SDKClient.Instance.ChatManager.FetchHistoryMessagesFromServer(conversationId, ty ### Delete historical messages from the server unidirectionally -Call `RemoveMessagesFromServer` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. Other chat users can still get the messages from the server. +Call `RemoveMessagesFromServer` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. The deleted messages are automatically removed from your local device. Other chat users can still get the messages from the server. ```csharp SDKClient.Instance.ChatManager.RemoveMessagesFromServer(convId, ctype, time, new CallBack( @@ -61,9 +61,9 @@ SDKClient.Instance.ChatManager.RemoveMessagesFromServer(convId, ctype, msgList, )); ``` -### Delete conversations and related messages from the server +### Delete conversations and related messages from the server unidirectionally -Call `DeleteConversationFromServer` to delete conversations and their historical messages from the server. After the conversations are deleted from the server, you and other users can no longer get them from the server. If the historical messages are deleted with the conversations, all users can no longer get the messages from the server. +Call `DeleteConversationFromServer` to delete conversations and their historical messages unidirectionally from the server. After the conversations and messages are deleted from the server, you can no longer get them from the server. The deleted conversations still exist on your local device, but the messages are automatically removed from the device. Other chat users can still get the conversations and their historical messages from the server. ```csharp SDKClient.Instance.ChatManager.DeleteConversationFromServer(conversationId, conversationType, isDeleteServerMessages, new CallBack( diff --git a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/web.mdx b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/web.mdx index f68f030fa..b38bb2a49 100644 --- a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/web.mdx +++ b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/web.mdx @@ -47,7 +47,7 @@ WebIM.conn.getHistoryMessages(options).then((res)=>{ ### Delete historical messages from the server unidirectionally -Call `removeHistoryMessages` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. Other chat users can still get the messages from the server. +Call `removeHistoryMessages` to delete historical messages one way from the server. You can remove a maximum of 20 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. Other chat users can still get the messages from the server. ```javascript // Delete messages by timestamp @@ -56,9 +56,9 @@ connection.removeHistoryMessages({targetId: 'userId', chatType: 'singleChat', be connection.removeHistoryMessages({targetId: 'userId', chatType: 'singleChat', messageIds: ['messageId']}) ``` -### Delete conversations and related messages from the server +### Delete conversations and related messages from the server unidirectionally -Call `deleteConversation` to delete conversations and related messages from the server. +Call `deleteConversation` to delete conversations and related messages unidirectionally from the server. Other chat users can still get the conversations and their historical messages from the server. ```javascript let options = { diff --git a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/windows.mdx b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/windows.mdx index 5ca9c36aa..3e7471a55 100644 --- a/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/windows.mdx +++ b/shared/chat-sdk/client-api/messages/retrieve-messages/project-implementation/windows.mdx @@ -40,7 +40,7 @@ SDKClient.Instance.ChatManager.FetchHistoryMessagesFromServer(conversationId, ty ### Delete historical messages from the server unidirectionally -Call `RemoveMessagesFromServer` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. Other chat users can still get the messages from the server. +Call `RemoveMessagesFromServer` to delete historical messages one way from the server. You can remove a maximum of 50 messages from the server each time. Once the messages are deleted, you can no longer retrieve them from the server. The deleted messages are automatically removed from your local device. Other chat users can still get the messages from the server. ```csharp SDKClient.Instance.ChatManager.RemoveMessagesFromServer(convId, ctype, time, new CallBack( @@ -61,9 +61,9 @@ SDKClient.Instance.ChatManager.RemoveMessagesFromServer(convId, ctype, msgList, )); ``` -### Delete conversations and related messages from the server +### Delete conversations and related messages from the server unidirectionally -Call `DeleteConversationFromServer` to delete conversations and their historical messages from the server. After the conversations are deleted from the server, you and other users can no longer get them from the server. If the historical messages are deleted with the conversations, all users can no longer get the messages from the server. +Call `DeleteConversationFromServer` to delete conversations and their historical messages unidirectionally from the server. After the conversations and messages are deleted from the server, you can no longer get them from the server. The deleted conversations still exist on your local device, but the messages are automatically removed from the device. Other chat users can still get the conversations and their historical messages from the server. ```csharp SDKClient.Instance.ChatManager.DeleteConversationFromServer(conversationId, conversationType, isDeleteServerMessages, new CallBack( diff --git a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/android.mdx b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/android.mdx index cd055828c..285fb02df 100644 --- a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/android.mdx +++ b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/android.mdx @@ -5,17 +5,19 @@ Use the `ChatMessage` class to create a text message, and send the message. ```java -// Call createTextSendMessage to create a text message. Set content as the content of the text message, and toChatUsernames the user ID of the message recipient. -ChatMessage message = ChatMessage.createTxtSendMessage(content, toChatUsername); -// Set the message type using the MessageType attribute in Message. -// You can set `MessageType` as `Chat`, `Group`, or `Room`, which indicates whether to send the message to a peer user, a chat group, or a chat room. -message.setChatType(ChatType.GroupChat); - // Send the message +// Call createTextSendMessage to create a text message. +// Set `content` as the content of the text message. +// Set `conversationId` to the user ID of the peer user in one-to-one chat, group ID in group chat, and chat room ID in room chat. +ChatMessage message = ChatMessage.createTextSendMessage(content, conversationId); +// Set `ChatType` as `Chat`, `GroupChat`, or `ChatRoom` for one-to-one chat, group chat, or room chat. +message.setChatType(ChatMessage.GroupChat); + // Send the message. ChatClient.getInstance().chatManager().sendMessage(message); ``` ```java -// Calls setMessageStatusCallback to set the callback instance to get the status of messaging sending. You can update the status of messages in this callback, for example, adding a tip when the message sending fails. +// Call setMessageStatusCallback to set the callback instance to get the status of messaging sending. +// You can update the status of messages in this callback, for example, adding a tip when the message sending fails. message.setMessageStatusCallback(new CallBack() { @Override public void onSuccess() { @@ -41,7 +43,7 @@ Even high-priorities messages can be dropped when the server load goes too high. You can set the priority for all types of messages in the chat room. ```java -ChatMessage message = ChatMessage.createTextSendMessage(content, toChatUsername); +ChatMessage message = ChatMessage.createTextSendMessage(content, conversationId); message.setChatType(ChatMessage.ChatType.ChatRoom); // Set the message priority. The default value is `Normal`, indicating the normal priority. message.setPriority(ChatMessage.ChatRoomMessagePriority.PriorityHigh); @@ -52,16 +54,19 @@ sendMessage(message); You can use `MessageListener` to listen for message events. You can add multiple `MessageListener`s to listen for multiple events. When you no longer listen for an event, ensure that you remove the listener. -When a message arrives, the recipient receives an `onMessgesReceived` callback. Each callback contains one or more messages. You can traverse the message list, and parse and render these messages in this callback. +When a message arrives, the recipient receives an `onMessagesReceived` callback. Each callback contains one or more messages. You can traverse the message list, and parse and render these messages in this callback. ```java -ChatClient.getInstance().chatManager().addMessageListener(msgListener); MessageListener msgListener = new MessageListener() { -// Traverse the message list, and parse and render the messages. -@Override -public void onMessageReceived(List messages) { -} + // Traverse the message list, and parse and render the messages. + @Override + public void onMessageReceived(List messages) { + } }; +// Add a message listener +ChatClient.getInstance().chatManager().addMessageListener(msgListener); +// Remove a message listener +ChatClient.getInstance().chatManager().removeMessageListener(msgListener); ChatClient.getInstance().chatManager().removeMessageListener(msgListener); ``` @@ -100,7 +105,7 @@ Refer to the following code example to create and send a voice message: ```java // Set voiceUri as the local URI of the audio file, and duration as the length of the file in seconds. -ChatMessage message = ChatMessage.createVoiceSendMessage(voiceUri, duration, toChatUsername); +ChatMessage message = ChatMessage.createVoiceSendMessage(voiceUri, duration, conversationId); // Sets the chat type as one-to-one chat, group chat, or chatroom. if (chatType == CHATTYPE_GROUP) message.setChatType(ChatType.GroupChat); @@ -126,7 +131,7 @@ Refer to the following code example to create and send an image message: ```java // Set imageUri as the URI of the image file on the local device. false means not to send the original image. The SDK compresses image files that exceeds 100K before sending them. -ChatMessage.createImageSendMessage(imageUri, false, toChatUsername); +ChatMessage.createImageSendMessage(imageUri, false, conversationId); // Sets the chat type as one-to-one chat, group chat, or chatroom. if (chatType == CHATTYPE_GROUP) message.setChatType(ChatType.GroupChat); @@ -158,7 +163,7 @@ Refer to the following code example to create and send a video message: ```java String thumbPath = getThumbPath(videoUri); -ChatMessage message = ChatMessage.createVideoSendMessage(videoUri, thumbPath, videoLength, toChatUsername); +ChatMessage message = ChatMessage.createVideoSendMessage(videoUri, thumbPath, videoLength, conversationId); sendMessage(message); ``` @@ -221,7 +226,7 @@ Refer to the following code example to create, send, and receive a file message: ```java // Set fileLocalUri as the URI of the file message on the local device. -ChatMessage message = ChatMessage.createFileSendMessage(fileLocalUri, toChatUsername); +ChatMessage message = ChatMessage.createFileSendMessage(fileLocalUri, conversationId); // Sets the chat type as one-to-one chat, group chat, or chatroom. if (chatType == CHATTYPE_GROUP) message.setChatType(ChatType.GroupChat);ChatClient.getInstance().chatManager().sendMessage(message); ``` @@ -266,9 +271,11 @@ To send and receive a location message, you need to integrate a third-party map ```java // Sets the latitude and longitude information of the address. -ChatMessage message = ChatMessage.createLocationSendMessage(latitude, longitude, locationAddress, toChatUsername); +ChatMessage message = ChatMessage.createLocationSendMessage(latitude, longitude, locationAddress, conversationId); // Sets the chat type as one-to-one chat, group chat, or chatroom. -if (chatType == CHATTYPE_GROUP) message.setChatType(ChatType.GroupChat);ChatClient.getInstance().chatManager().sendMessage(message); +if (chatType == CHATTYPE_GROUP) + message.setChatType(ChatType.GroupChat); +ChatClient.getInstance().chatManager().sendMessage(message); ``` ### Send and receive a CMD message @@ -279,15 +286,18 @@ CMD messages are command messages that instruct a specified user to take a certa ```java ChatMessage cmdMsg = ChatMessage.createSendMessage(ChatMessage.Type.CMD); -// Sets the chat type as one-to-one chat, group chat, or chat room -cmdMsg.setChatType(ChatType.GroupChat)String action="action1"; -// You can customize the action -CmdMessageBody cmdBody = new CmdMessageBody(action);String toUsername = "test1"; -// Specify a username to send the cmd message. -cmdMsg.setTo(toUsername);cmdMsg.addBody(cmdBody); ChatClient.getInstance().chatManager().sendMessage(cmdMsg); +// Sets the chat type as one-to-one chat, group chat, or chat room. +cmdMsg.setChatType(ChatType.GroupChat); +String action="action1"; +// You can customize the action. +CmdMessageBody cmdBody = new CmdMessageBody(action); +// Sets the message recipient: user ID of the recipient for one-to-one chat, group ID for group chat, or chat room ID for a chat room. +cmdMsg.setTo(conversationId); +cmdMsg.addBody(cmdBody); +ChatClient.getInstance().chatManager().sendMessage(cmdMsg); ``` -To notify the recipient that a CMD message is received, use a seperate delegate so that users can deal with the message differently. +To notify the recipient that a CMD message is received, use a separate delegate so that users can deal with the message differently. ```java MessageListener msgListener = new MessageListener() @@ -296,7 +306,7 @@ MessageListener msgListener = new MessageListener() @Override public void onMessageReceived(List messages) { } - // Occues when a CMD message is received + // Occurs when a CMD message is received @Override public void onCmdMessageReceived(List messages) { } @@ -315,7 +325,7 @@ ChatMessage customMessage = ChatMessage.createSendMessage(ChatMessage.Type.CUSTO event = "gift"CustomMessageBody customBody = new CustomMessageBody(event); // The data type of params is Map. customBody.setParams(params);customMessage.addBody(customBody); -// Specifies the user ID to receive the message, as Chat ID, chat group ID, or chat room ID. +// Sets the message recipient: user ID of the recipient for one-to-one chat, group ID for group chat, or chat room ID for a chat room. customMessage.setTo(to); // Sets the chat type as one-to-one chat, group chat, or chat room customMessage.setChatType(chatType);ChatClient.getInstance().chatManager().sendMessage(customMessage); @@ -327,7 +337,7 @@ customMessage.setChatType(chatType);ChatClient.getInstance().chatManager().sendM If the message types listed above do not meet your requirements, you can use message extensions to add attributes to the message. This can be applied in more complicated messaging scenarios. ```java -ChatMessage message = ChatMessage.createTxtSendMessage(content, toChatUsername); +ChatMessage message = ChatMessage.createTextSendMessage(content, conversationId); // Adds message attributes. message.setAttribute("attribute1", "value");message.setAttribute("attribute2", true); // Sends the message diff --git a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/flutter.mdx b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/flutter.mdx index 05877ff71..a3cd28fba 100644 --- a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/flutter.mdx +++ b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/flutter.mdx @@ -9,11 +9,11 @@ Follow the steps to create and send a message, and listen for the result of send ```dart // Sets the message type. Agora Chat supports 8 message types. MessageType messageType = MessageType.TXT; -// Sets the user ID of the recipient. +// Sets `targetId` to the user ID of the peer user in one-to-one chat, group ID in group chat, and chat room ID in room chat. String targetId = "tom"; -// Sets the chat type. You can set it as a peer user, chat group, or chat room. +// Sets `chatType` as `Chat`, `GroupChat`, or `ChatRoom` for one-to-one chat, group chat, or room chat. ChatType chatType = ChatType.Chat; -// Creates a message. For different message types, you need to set different parameters. +// Creates a message. Parameters vary with message types. // Creates a text message. ChatMessage msg = ChatMessage.createTxtSendMessage( targetId: targetId, diff --git a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/ios.mdx b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/ios.mdx index 221c284c3..b8f226bb2 100644 --- a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/ios.mdx +++ b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/ios.mdx @@ -5,19 +5,20 @@ Use the `AgoraChatTextMessageBody` class to create a text message, and then send the message. ```objective-c -// Call initWithText to create a text message. Set content as the text content and toChatUsername to the username to whom you want to send this text message. -AgoraChatTextMessageBody *textMessageBody = [[AgoraChatTextMessageBody alloc] initWithText:content]; -AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toChatUsername - from:fromChatUsername - to:toChatUsername - body:textMessageBody - ext:messageExt]; -// Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room. -message.chatType = AgoraChatTypeGroupChat; -// Sends the message -[[AgoraChatClient sharedClient].chatManager sendMessage:message - progress:nil - completion:nil]; +// Call initWithText to create a text message. Set `content` to the text content. + AgoraChatTextMessageBody *textMessageBody = [[AgoraChatTextMessageBody alloc] initWithText:content]; + // Set `conversationId` to the user ID of the peer user in one-to-one chat, group ID in group chat, and chat room ID in room chat. + NSString* conversationId = @"remoteUserId"; + AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:conversationId + body:textMessageBody + ext:messageExt]; + // Set `message.chatType` to `AgoraChatTypeChat` for one-to-one chat, `AgoraChatTypeGroupChat` for group chat, and `AgoraChatTypeChatRoom` for room chat. + // The default value is `AgoraChatTypeChat`. + message.chatType = AgoraChatTypeChat; + // Send the message. + [[AgoraChatClient sharedClient].chatManager sendMessage:message + progress:nil + completion:nil]; ``` You can set the priority of chat room messages. @@ -86,7 +87,7 @@ You can also use `messagesDidRecall` to listen for the message recall state: /** * Occurs when a received message is recalled. */ -- (void)messagesDidRecall:(NSArray *)aMessages; +- (void)messagesInfoDidRecall:(NSArray * _Nonnull)aRecallMessagesInfo; ``` ### Send and receive an attachment message @@ -110,7 +111,7 @@ AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toC ext:nil]; message.chatType = AgoraChatTypeChat; // Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room. -message.chatType = AgoraChatTypeGroupChat; +// message.chatType = AgoraChatTypeGroupChat; // Sends the message [[AgoraChatClient sharedClient].chatManager sendMessage:message progress:nil @@ -144,7 +145,7 @@ AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toC ext:messageExt]; message.chatType = AgoraChatTypeChat; // Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room. -message.chatType = AgoraChatTypeGroupChat; +// message.chatType = AgoraChatTypeGroupChat; // Sends the message [[AgoraChatClient sharedClient].chatManager sendMessage:message progress:nil @@ -185,7 +186,7 @@ AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toC ext:messageExt]; message.chatType = AgoraChatTypeChat; // Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room. -message.chatType = AgoraChatTypeGroupChat; +// message.chatType = AgoraChatTypeGroupChat; // Sends the message [[AgoraChatClient sharedClient].chatManager sendMessage:message progress:nil @@ -225,7 +226,7 @@ AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toC ext:messageExt]; message.chatType = AgoraChatTypeChat; // Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room. -message.chatType = AgoraChatTypeGroupChat; +// message.chatType = AgoraChatTypeGroupChat; // Sends the message [[AgoraChatClient sharedClient].chatManager sendMessage:message progress:nil @@ -265,7 +266,7 @@ AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toC ext:messageExt]; message.chatType = AgoraChatTypeChat; // Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room. -message.chatType = AgoraChatTypeGroupChat; +// message.chatType = AgoraChatTypeGroupChat; // Sends the message [[AgoraChatClient sharedClient].chatManager sendMessage:message progress:nil @@ -286,7 +287,7 @@ AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toC ext:messageExt]; message.chatType = AgoraChatTypeChat; // Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room. -message.chatType = AgoraChatTypeGroupChat; +// message.chatType = AgoraChatTypeGroupChat; // Sends the message [[AgoraChatClient sharedClient].chatManager sendMessage:message progress:nil @@ -311,7 +312,7 @@ The following code example shows how to create and send a customized message: ```objective-c // Set event as the custom message event, for example "userCard". -// Set ext as the extension field of the event, for example as uid, nichname, and avator. +// Set ext as the extension field of the event, for example as uid, nickname, and avatar. AgoraChatCustomMessageBody* body = [[AgoraChatCustomMessageBody alloc] initWithEvent:@"userCard" ext:@{@"uid":aUid ,@"nickname":aNickName,@"avatar":aUrl}]; AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toChatUsername from:fromChatUsername @@ -320,7 +321,7 @@ AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:toC ext:messageExt]; message.chatType = AgoraChatTypeChat; // Set the chat type as Group chat. You can also set is as chat (one-to-one chat) or chat room. -message.chatType = AgoraChatTypeGroupChat; +// message.chatType = AgoraChatTypeGroupChat; // Sends the message. [[AgoraChatClient sharedClient].chatManager sendMessage:message progress:nil diff --git a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/react-native.mdx b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/react-native.mdx index 3954757c1..f6bcbeb81 100644 --- a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/react-native.mdx +++ b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/react-native.mdx @@ -33,25 +33,26 @@ class ChatMessageCallback implements ChatMessageStatusCallback { .catch((reason) => { // The sending operation fails and the log is printed here. console.log("send message operation fail.", reason); - }); + }) + }; ``` Use the `ChatMessage` class to create a message, and `ChannelManager` to send the message. + ```typescript -// Set the message type. The SDK supports 8 message types. For details, see descriptions in ChatMessageType. -// You can send different types of messages by setting this parameter. +// Set the message type. The SDK supports 8 message types. const messageType = ChatMessageType.TXT; -// Set the user ID of the message recipient. +// Set `targetId` to the user ID of the peer user in one-to-one chat, group ID in group chat, and chat room ID in room chat. const targetId = "tom"; -// Set the chat type as a peer-to-peer chat, group chat, or chat room. For details, see descriptions in ChatMessageChatType. +// Set `chatType` as `PeerChat`, `GroupChat`, or `ChatRoom` for one-to-one chat, group chat, or room chat. const chatType = ChatMessageChatType.PeerChat; -// Construct the message. For different message types, you need to set the different parameters. +// Construct the message. Parameters vary with message types. let msg: ChatMessage; if (messageType === ChatMessageType.TXT) { // For a text message, set the message content. const content = "This is text message"; msg = ChatMessage.createTextMessage(targetId, content, chatType); } else if (messageType === ChatMessageType.IMAGE) { - // For am image message, set the file path, width, height, and display name of the image file. + // For an image message, set the file path, width, height, and display name of the image file. const filePath = "/data/.../image.jpg"; const width = 100; const height = 100; diff --git a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/unity.mdx b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/unity.mdx index b0d8aa57c..8f5b1d75d 100644 --- a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/unity.mdx +++ b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/unity.mdx @@ -5,16 +5,18 @@ Use the `Message` class to create a text message, and `IChannelManager` to send the message. ```csharp -// Call CreateTextSendMessage to create a text message. Set `content` as the content of the text message, and `toChatUsernames` the user ID of the message recipient. -Message msg = Message.CreateTextSendMessage(toChatUsername, content); -// Set the message type using the `MessageType` attribute in `Message`. -// You can set `MessageType` as `Chat`, `Group`, or `Room`, which indicates whether to send the message to a peer user, a chat group, or a chat room. +// Call CreateTextSendMessage to create a text message. +// Set `content` as the content of the text message. +// Set `conversationId` to the user ID of the peer user in one-to-one chat, group ID in group chat, and chat room ID in room chat. +Message msg = Message.CreateTextSendMessage(conversationId, content); +// Set `MessageType` in `Message` as `Chat`, `Group`, or `Room` for one-to-one chat, group chat, or room chat. msg.MessageType = MessageType.Group; // Set the priority of chat room messages. The default priority is `Normal`, indicating the normal priority. -msg.MessageType = MessageType.Room; -msg.SetRoomMessagePriority(RoomMessagePriority.High); +// msg.MessageType = MessageType.Room; +// msg.SetRoomMessagePriority(RoomMessagePriority.High); // Call SendMessage to send the message. -// When sending the message, you can instantiate a `Callback` object to listen for the result of the message sending. You can also update the message state in this callback, for example, by adding a pop-up box that reminds the message sending fails. +// When sending the message, you can instantiate a `Callback` object to listen for the result of the message sending. +// You can also update the message state in this callback, for example, by adding a pop-up box that reminds the message sending fails. SDKClient.Instance.ChatManager.SendMessage(ref msg, new CallBack( onSuccess: () => { Debug.Log($"{msg.MsgId} Message sending succeeds."); @@ -39,7 +41,7 @@ You can set the priority for all types of messages in the chat room. See code ex You can use `IChatManagerDelegate` to listen for message events. You can add multiple `IChatManagerDelegates` to listen for multiple events. When you no longer listen for an event, ensure that you remove the delegate. -When a message arrives, the recipient receives an `OnMessgesReceived` callback. Each callback contains one or more messages. You can traverse the message list, and parse and render these messages in this callback and render these messages. +When a message arrives, the recipient receives an `OnMessagesReceived` callback. Each callback contains one or more messages. You can traverse the message list, and parse and render these messages in this callback and render these messages. ```csharp // Inherit and instantiate IChatManagerDelegate. diff --git a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/web.mdx b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/web.mdx index b0e84c945..42824d32b 100644 --- a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/web.mdx +++ b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/web.mdx @@ -10,18 +10,18 @@ function sendPrivateText() { let option = { // Set the message content. msg: "message content", - // Set the username of the receiver. - to: "username", - // Set the chat type + // Set the user ID of the recipient for one-to-one chat, group ID for group chat, or chat room ID for room chat. + to: "userId", + // Set `chatType` as `singleChat` for one-to-one chat, `groupChat` for group chat, or `chatRoom` for room chat. chatType: "singleChat", }; // Create a text message. - let msg = WebIM.message.create(opt); - // Call send to send the message - conn.send(msg).then(()=>{ - console.log("send private text Success"); + let msg = AC.message.create(option); + // Call `send` to send the message + conn.send(msg).then((res)=>{ + console.log("Send message success",res); }).catch((e)=>{ - console.log("Send private text error"); + console.log("Send message fail",e); }); } ``` @@ -47,7 +47,7 @@ function sendTextMessage() { to: "chat room ID", chatType: "chatRoom", }; - let msg = WebIM.message.create(opt); + let msg = AC.message.create(opt); conn.send(msg).then(()=>{ console.log("Send message success"); }).catch((e)=>{ @@ -64,7 +64,7 @@ When a message arrives, the recipient receives an `onXXXMessage` callback. Each ```javascript // Use `addEventHandler` to listen for callback events. -WebIM.conn.addEventHandler("eventName",{ +connection.addEventHandler("eventName",{ // Occurs when the app is connected. onOpened: function (message) {}, // Occurs when the connection is lost. @@ -140,7 +140,7 @@ connection.recallMessage(option).then((res) => { ``` You can also use `onRecallMessage` to listen for the message recall state: ```javascript -WebIM.conn.addEventHandler('MESSAGES',{ +connection.addEventHandler('MESSAGES',{ onRecallMessage: => (msg) { // You can insert a message here, for example, XXX has recalled a message. console.log('Recalling the message succeeds',msg) @@ -167,11 +167,11 @@ Refer to the following code example to create and send a voice message: ```javascript var sendPrivateAudio = function () { // Create a voice message. - var msg = new WebIM.message('audio'); + var msg = new AC.message('audio'); // Select the local audio file. var input = document.getElementById('audio'); // Turn the audio file to a binary file. - var file = WebIM.utils.getFileUrl(input); + var file = AC.utils.getFileUrl(input); var allowType = { 'mp3': true, 'amr': true, @@ -203,7 +203,7 @@ Refer to the following code example to create and send a voice message: ext: {file_length: file.data.size} }; // Create a voice message. - var msg = WebIM.message.create(option); + var msg = AC.message.create(option); // Call send to send the voice message. conn.send(msg).then((res)=>{ // Occurs when the audio file is successfully sent. @@ -224,7 +224,7 @@ Refer to the following code example to create and send an image message: // Select the local image file. var input = document.getElementById("image"); // Turn the image to a binary file. - var file = WebIM.utils.getFileUrl(input); + var file = AC.utils.getFileUrl(input); var allowType = { jpg: true, gif: true, @@ -258,7 +258,7 @@ Refer to the following code example to create and send an image message: }, }; // Create a voice message. - var msg = WebIM.message.create(option); + var msg = AC.message.create(option); // Call send to send the voice message. conn.send(msg).then((res)=>{ // Occurs when the audio file is successfully sent. @@ -286,7 +286,7 @@ To send a URL image message, make sure you set `useOwnUploadFun` as `true`. to: "username", }; // Create an image message. - var msg = WebIM.message.create(option); + var msg = AC.message.create(option); // Call send to send to image file. conn.send(msg); }; @@ -301,7 +301,7 @@ Refer to the following code example to create and send a video message: // Select the local video file. var input = document.getElementById("video"); // Turn the video to a binary file. - var file = WebIM.utils.getFileUrl(input); + var file = AC.utils.getFileUrl(input); var allowType = { mp4: true, wmv: true, @@ -333,7 +333,7 @@ Refer to the following code example to create and send a video message: ext: {file_length: file.data.size}, }; // Create a video message. - var msg = WebIM.message.create(option); + var msg = AC.message.create(option); // Call send to send the video message. conn.send(msg).then((res)=>{ // Occurs when the message is sent. @@ -354,7 +354,7 @@ Refer to the following code example to create, send, and receive a file message: // Select the local file. var input = document.getElementById("file"); // Turn the file message to a binary file. - var file = WebIM.utils.getFileUrl(input); + var file = AC.utils.getFileUrl(input); var allowType = { jpg: true, gif: true, @@ -389,7 +389,7 @@ Refer to the following code example to create, send, and receive a file message: ext: {file_length: file.data.size}, }; // Create a file message. - var msg = WebIM.message.create(option); + var msg = AC.message.create(option); // Call send to send the file message. conn.send(msg).then((res) => { // Occurs when the file message is sent. @@ -401,6 +401,35 @@ Refer to the following code example to create, send, and receive a file message: } }; ``` + +### Send a location message +To send and receive a location message, you need to integrate a third-party map service provider. When sending a location message, you get the longitude and latitude information of the location from the map service provider; when receiving a location message, you extract the received longitude and latitude information and displays the location on the third-party map. +```javascript +const sendLocMsg = () => { + let coords; + if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(function (position) { + coords = position.coords; + let option = { + chatType: "singleChat", + type: "loc", + to: "username", + addr: "London", + buildingName: "Digital Building", + lat: Math.round(coords.latitude), + lng: Math.round(coords.longitude), + }; + let msg = AC.message.create(option); + conn.send(msg).then((res)=>{ + console.log("Send message success", res); + }).catch((e)=>{ + console.log("Send message fail", e); + }); + }) + } +} +``` + ### Send a CMD message CMD messages are command messages that instruct a specified user to take a certain action. The recipient deals with the command messages themselves. @@ -420,7 +449,7 @@ var options = { ext :{'extmsg':'extends messages'} } // Create a CMD message. -var msg = WebIM.message.create(options); +var msg = AC.message.create(options); // Call send to send the CMD message. conn.send(msg).then((res)=>{ // Occurs when the message is sent. @@ -454,7 +483,7 @@ var sendCustomMsg = function () { ext: {}, } // Create a custom message. - var msg = WebIM.message.create(options); + var msg = AC.message.create(options); // Call send to send the custom message. conn.send(msg).then((res)=>{ // Occurs when the message is sent. @@ -484,7 +513,7 @@ function sendPrivateText() { }, } } - let msg = WebIM.message.create(options); + let msg = AC.message.create(options); // Call send to send the extended message. conn.send(msg).then((res)=>{ console.log("send private text Success"); diff --git a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/windows.mdx b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/windows.mdx index f430b902a..f13165200 100644 --- a/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/windows.mdx +++ b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/windows.mdx @@ -5,16 +5,18 @@ Use the `Message` class to create a text message, and `IChannelManager` to send the message. ```csharp -// Call CreateTextSendMessage to create a text message. Set `content` as the content of the text message, and `toChatUsernames` the user ID of the message recipient. -Message msg = Message.CreateTextSendMessage(toChatUsername, content); -// Set the message type using the `MessageType` attribute in `Message`. -// You can set `MessageType` as `Chat`, `Group`, or `Room`, which indicates whether to send the message to a peer user, a chat group, or a chat room. +// Call CreateTextSendMessage to create a text message. +// Set `content` as the content of the text message. +// Set `conversationId` to the user ID of the peer user in one-to-one chat, group ID in group chat, and chat room ID in room chat. +Message msg = Message.CreateTextSendMessage(conversationId, content); +// Set `MessageType` in `Message` as `Chat`, `Group`, or `Room` for one-to-one chat, group chat, or room chat. msg.MessageType = MessageType.Group; -//Set the priority of chat room messages. The default priority is `Normal`, indicating the normal priority. -msg.MessageType = MessageType.Room; -msg.SetRoomMessagePriority(RoomMessagePriority.High); +// Set the priority of chat room messages. The default priority is `Normal`, indicating the normal priority. +// msg.MessageType = MessageType.Room; +// msg.SetRoomMessagePriority(RoomMessagePriority.High); // Call SendMessage to send the message. -// When sending the message, you can instantiate a `Callback` object to listen for the result of the message sending. You can also update the message state in this callback, for example, by adding a pop-up box that reminds the message sending fails. +// When sending the message, you can instantiate a `Callback` object to listen for the result of the message sending. +// You can also update the message state in this callback, for example, by adding a pop-up box that reminds the message sending fails. SDKClient.Instance.ChatManager.SendMessage(ref msg, new CallBack( onSuccess: () => { Debug.Log($"{msg.MsgId} Message sending succeeds."); @@ -39,7 +41,7 @@ You can set the priority for all types of messages in the chat room. See code ex You can use `IChatManagerDelegate` to listen for message events. You can add multiple `IChatManagerDelegates` to listen for multiple events. When you no longer listen for an event, ensure that you remove the delegate. -When a message arrives, the recipient receives an `OnMessgesReceived` callback. Each callback contains one or more messages. You can traverse the message list, and parse and render these messages in this callback and render these messages. +When a message arrives, the recipient receives an `OnMessagesReceived` callback. Each callback contains one or more messages. You can traverse the message list, and parse and render these messages in this callback and render these messages. ```csharp // Inherit and instantiate IChatManagerDelegate. diff --git a/shared/chat-sdk/client-api/presence/project-implementation/ios.mdx b/shared/chat-sdk/client-api/presence/project-implementation/ios.mdx index ff2cb68b2..74c298f3e 100644 --- a/shared/chat-sdk/client-api/presence/project-implementation/ios.mdx +++ b/shared/chat-sdk/client-api/presence/project-implementation/ios.mdx @@ -59,7 +59,7 @@ You can call `unsubscribe` to unsubscribe from the presence statuses of the spec You can call `fetchSubscribedMembersWithPageNum` to retrieve the list of your subscriptions in a paginated list, as shown in the following code sample: ```objc -[[AgoraChatClient sharedClient] presenceManager] fetchSubscribedMembersWithPageNum:0 pageSize:50 Completion:^(NSArray* members,AgoraChatError*error){ +[[[AgoraChatClient sharedClient] presenceManager] fetchSubscribedMembersWithPageNum:0 pageSize:50 Completion:^(NSArray* members,AgoraChatError*error){ }]; ``` @@ -68,7 +68,7 @@ You can call `fetchSubscribedMembersWithPageNum` to retrieve the list of your su You can call `fetchPresenceStatus` to retrieve the current presence statuses of the specified users without the need to subscribe to them, as shown in the following code sample: ```objc -[[AgoraChatClient sharedClient] presenceManager] fetchPresenceStatus:@[@"Alice",@"Tom"] completion:^(NSArray* presences,AgoraChatError*error){ +[[[AgoraChatClient sharedClient] presenceManager] fetchPresenceStatus:@[@"Alice",@"Tom"] completion:^(NSArray* presences,AgoraChatError*error){ }]; ``` diff --git a/shared/chat-sdk/client-api/presence/project-implementation/web.mdx b/shared/chat-sdk/client-api/presence/project-implementation/web.mdx index 22f6ecfbb..6f4c6f90b 100644 --- a/shared/chat-sdk/client-api/presence/project-implementation/web.mdx +++ b/shared/chat-sdk/client-api/presence/project-implementation/web.mdx @@ -59,7 +59,7 @@ conn.unsubscribePresence(payload).then(res => {console.log(res)}) ### Retrieve the list of subscriptions -You can call `getSubscribedPresenceList` to retrieve the list of your subscriptions in a paginated list, as shown in the following code sample: +You can call `getSubscribedPresencelist` to retrieve the list of your subscriptions in a paginated list, as shown in the following code sample: ```javascript let option = { diff --git a/shared/chat-sdk/client-api/reaction/project-implementation/web.mdx b/shared/chat-sdk/client-api/reaction/project-implementation/web.mdx index ab61ca2b4..a1b472a93 100644 --- a/shared/chat-sdk/client-api/reaction/project-implementation/web.mdx +++ b/shared/chat-sdk/client-api/reaction/project-implementation/web.mdx @@ -59,12 +59,12 @@ conn }); ``` -### Retrieve the reaction in the roaming message +### Retrieve the reaction in the historical message from the server -When calling `fetchHistoryMessages` to retrieve historical messages from the server, if the message has a reaction attached to it, the retrieved message body also contains the information of the reaction. +When calling `getHistoryMessages` to retrieve historical messages from the server, if the message has a reaction attached to it, the retrieved message body also contains the information of the reaction. ```javascript -conn.fetchHistoryMessages({ queue: "user", count: 20 }).then((messages) => { +conn.getHistoryMessages({ targetId:'targetId',chatType:'groupChat', pageSize: 20 }).then((messages) => { console.log(messages); }); ``` diff --git a/shared/chat-sdk/client-api/reaction/understand/web.mdx b/shared/chat-sdk/client-api/reaction/understand/web.mdx index bbe140490..e95dfb753 100644 --- a/shared/chat-sdk/client-api/reaction/understand/web.mdx +++ b/shared/chat-sdk/client-api/reaction/understand/web.mdx @@ -4,5 +4,6 @@ - `deleteReaction`: Removes the reaction from the specified message. - `getReactionList`: Retrieves a list of reactions from the server. - `getReactionDetail`: Retrieves the details of the reaction from the server. +- `getHistoryMessages`:Retrieves the reactions in historical messages from the server. \ No newline at end of file diff --git a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/android.mdx b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/android.mdx index ef166762b..8d3722fb3 100644 --- a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/android.mdx +++ b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/android.mdx @@ -7,12 +7,12 @@ Sending a thread message is similar to sending a message in a chat group. The di ```java // Calls `createTxtSendMessage` to create a text message. // Sets `content` to the content of the text message. -// Sets `chatThreadId` to the ID of a thread that receives the text message. +// Sets `chatThreadId` to the thread ID. ChatMessage message = ChatMessage.createTxtSendMessage(content, chatThreadId); -// Sets `ChatType` to `GroupChat` as a thread that belongs to a chat group. +// Sets `ChatType` to `GroupChat` as a thread belongs to a chat group. message.setChatType(ChatType.GroupChat); // Sets `isChatThreadMessage` to `true` to mark this message as a thread message. -message.setisChatThreadMessage(true); +message.setIsChatThreadMessage(true); // Calls `setMessageStatusCallback` to listen for the message sending status. You can implement subsequent settings in this callback, for example, displaying a pop-up if the message sending fails. message.setMessageStatusCallback(new CallBack() { @Override @@ -86,25 +86,44 @@ MessageListener msgListener = new MessageListener() { ### Retrieve thread messages -Whether to retrieve thread messages from the server or local database depends on your production context. +You can retrieve thread messages locally or from the server, depending on your production environment. -When you join a thread, messages are displayed in chronological order by default. In this case, Agora recommends that you retrieve the historical messages of the thread from the server. When you recall a thread message, Agora recommend that you insert the recall notification in the local database. +You can check `ChatConversation#isChatThread()` to determine whether the current conversation is a thread conversation. -#### Retrieve thread messages from the server +#### Retrieve messages of a thread from the server -For details about how to retrieve messages from the server, see Retrieve Historical Messages. +You can call `asyncFetchHistoryMessage` to retrieve messages of a thread from the server. The only difference between retrieving messages of a thread from the server and retrieving group messages is that a thread ID needs to be passed in for the former and a group ID is required for the latter. -#### Retrieve the conversation of a thread from the memory and local database +```java +String chatThreadId = "{your chatThreadId}"; +Conversation.ConversationType type = Conversation.ConversationType.GroupChat; +int pageSize = 10; +String startMsgId = "";// Starting message ID for retrieving. If you pass in an empty string, the SDK will retrieve messages according to the search direction while ignoring this parameter. +Conversation.SearchDirection direction = Conversation.SearchDirection.DOWN; + +ChatClient.getInstance().chatManager().asyncFetchHistoryMessage(chatThreadId, type, + pageSize, startMsgId, direction, new ValueCallBack>() { + @Override + public void onSuccess(CursorResult value) { + + } + + @Override + public void onError(int error, String errorMsg) { + + } +}); +``` + +#### Retrieve messages of a thread locally -By calling [`getAllConversations`](/agora-chat/client-api/messages/manage-messages#retrieve-conversations), you can only retrieve the conversations of one-to-one chats or group chats. To retrieve the conversation of a thread, refer to the following code sample: +By calling [`loadAllConversations`](/agora-chat/client-api/messages/manage-messages#retrieve-conversations), you can only retrieve local one-to-one chat conversations and group conversations. To retrieve messages of a thread locally, refer to the following code sample: ```java // Sets the conversation type to group chat as a thread belongs to a chat group. // Sets `isChatThread` to `true` to mark the conversation as a thread. ChatConversation conversation = ChatClient.getInstance().chatManager().getConversation(chatThreadId, ChatConversationType.GroupChat, createIfNotExists, isChatThread); -// Retrieves all messages in the specified thread from the memory. -List messages = conversation.getAllMessages(); -// Retrieves more messages in the specified thread from the local database. The SDK automatically loads and stores the retrieved messages to the memory. +// Retrieves messages in the specified thread from the local database. The SDK automatically loads and stores the retrieved messages to the memory. List messages = conversation.loadMoreMsgFromDB(startMsgId, pagesize, searchDirection); ``` diff --git a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/flutter.mdx b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/flutter.mdx index bd981bc0a..8ac75b32e 100644 --- a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/flutter.mdx +++ b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/flutter.mdx @@ -5,13 +5,13 @@ Sending a thread message is similar to sending a message in a chat group. The difference lies in the `isChatThreadMessage` field, as shown in the following code sample: ```dart -// Sets `targetGroup` to the ID of the chat group that receives the message. +// Sets `chatThreadId` to thread ID. // Sets `content` to the message content. ChatMessage msg = ChatMessage.createTxtSendMessage( - targetId: targetGroup, + chatThreadId: threadId, content: content, ); -// Sets `ChatType` to GroupChat as a thread that belongs to a chat group. +// Sets `ChatType` to GroupChat as a thread belongs to a chat group. msg.chatType = ChatType.GroupChat; // Sets `isChatThreadMessage` to `true` to mark this message as a thread message. msg.isChatThreadMessage = true; @@ -77,8 +77,56 @@ Once a message is recalled in a thread, all chat group members receive the `Chat ChatClient.getInstance.chatThreadManager.removeEventHandler("UNIQUE_HANDLER_ID"); ``` -### Retrieve thread messages from the server +### Retrieve thread messages -For details about how to retrieve messages from the server, see Retrieve Conversations and Messages from Server. +You can retrieve thread messages locally or from the server, depending on your production environment. + +You can check `ChatConversation#isChatThread()` to determine whether the current conversation is a thread conversation. + +#### Retrieve messages of a thread from the server + +You can call `fetchHistoryMessages` to retrieve messages of a thread from the server. The only difference between retrieving messages of a thread from the server and retrieving group messages is that a thread ID needs to be passed in for the former and a group ID is required for the latter. + +```dart +try { + // The thread ID. + String threadId = "threadId"; + // The conversation type is set to `GroupChat` as a thread belongs to a group conversation. + ChatConversationType convType = ChatConversationType.GroupChat; + // The number of thread messages that you expect to get on each page. + int pageSize = 10; + // The starting message ID for retrieving. + String startMsgId = ""; + ChatCursorResult cursor = + await ChatClient.getInstance.chatManager.fetchHistoryMessages( + conversationId: convId, + type: convType, + pageSize: pageSize, + startMsgId: startMsgId, + ); +} on ChatError catch (e) { +} +``` + +#### Retrieve messages of a thread locally + +By calling [`loadAllConversations`](/agora-chat/client-api/messages/manage-messages#retrieve-conversations), you can only retrieve local one-to-one chat conversations and group conversations. To retrieve messages of a thread locally, refer to the following code sample: + +```dart +try { + // The thread ID. + String threadId = "threadId"; + // The conversation type is set to `GroupChat` as a thread belongs a group conversation. + ChatConversationType convType = ChatConversationType.GroupChat; + ChatConversation? conversation = await ChatClient.getInstance.chatManager + .getConversation(threadId, type: convType); + // The starting message for retrieving. + String startMsgId = "startMsgId"; + // The number of messages that you expect to retrieve on each page. + int pageSize = 10; + List? list = await conversation?.loadMessages( + startMsgId: startMsgId, loadCount: pageSize); +} on ChatError catch (e) {} +``` \ No newline at end of file diff --git a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/ios.mdx b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/ios.mdx index 2f8454995..357ae1d9e 100644 --- a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/ios.mdx +++ b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/ios.mdx @@ -7,15 +7,15 @@ Sending a thread message is similar to sending a message in a chat group. The di ```objc // Calls `initWithConversationID` to create a text message. // Sets `*message` to the content of the text message. -// Sets `*to` to the ID of a thread that receives the text message. +// Sets `chatThreadId` to the thread ID. NSString *from = [[AgoraChatClient sharedClient] currentUsername]; -NSString *to = self.currentConversation.conversationId; -AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:to from:from to:to body:aBody ext:aExt]; +NSString *chatThreadId = self.currentConversation.conversationId; +AgoraChatMessage *message = [[AgoraChatMessage alloc] initWithConversationID:chatThreadId from:from to:chatThreadId body:aBody ext:aExt]; // Specifies whether a read receipt is required for this text message. if([aExt objectForKey:MSG_EXT_READ_RECEIPT]) { message.isNeedGroupAck = YES; } -// Sets `chatType` to `AgoraChatTypeGroupChat` as a thread that belongs to a chat group. +// Sets `chatType` to `AgoraChatTypeGroupChat` as a thread belongs to a chat group. message.chatType = (AgoraChatType)self.conversationType; // Sets `isChatThread` to `YES` to mark this message as a thread message. message.isChatThreadMessage = self.isChatThread; @@ -61,8 +61,28 @@ Once a message is recalled in a thread, all chat group members receive the `Agor {} ``` -### Retrieve thread messages from the server +### Retrieve thread messages -For details about how to retrieve messages from the server, see Retrieve Historical Messages. +You can retrieve thread messages locally or from the server, depending on your production environment. + +You can check `AgoraChatConversation#isChatThread()` to determine whether the current conversation is a thread conversation. + +#### Retrieve messages of a thread from the server + +You can call `asyncFetchHistoryMessagesFromServer` to retrieve messages of a thread from the server. The only difference between retrieving messages of a thread from the server and retrieving group messages is that a thread ID needs to be passed in for the former and a group ID is required for the latter. + +```objc +[AgoraChatClient.sharedClient.chatManager asyncFetchHistoryMessagesFromServer:@"threadId" conversationType:AgoraChatConversationTypeGroupChat startMessageId:@"" fetchDirection:AgoraChatMessageFetchHistoryDirectionUp pageSize:20 completion:^(AgoraChatCursorResult * _Nullable aResult, AgoraChatError * _Nullable aError) { + + }]; +``` +#### Retrieve messages of a thread locally + +By calling [`getAllConversations`](/agora-chat/client-api/messages/manage-messages#retrieve-conversations), you can only retrieve local one-to-one chat conversations and group conversations. To retrieve messages of a thread locally, refer to the following code sample: +```objc +AgoraChatConversation *conversation = [AgoraChatClient.sharedClient.chatManager getConversation:@"threadId" type:AgoraChatConversationTypeGroupChat createIfNotExist:NO isThread:YES]; +[conversation loadMessagesStartFromId:msgId count:50 searchDirection:AgoraChatMessageSearchDirectionUp completion:^(NSArray *aMessages, AgoraChatError *aError) { +}]; +``` \ No newline at end of file diff --git a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/react-native.mdx b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/react-native.mdx index b0a16f620..eaaecc734 100644 --- a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/react-native.mdx +++ b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/react-native.mdx @@ -5,11 +5,13 @@ Sending a thread message is similar to sending a message in a chat group. The difference lies in the `isChatThread` field, as shown in the following code sample: ```typescript -// Sets `targetId` to the ID of the chat group that receives the message. +// Sets `chatThreadId` to the thread ID. // Sets `content` to the message content. -// Sets `chatType` to a group chat as a thread that belongs to a chat group. +// Sets `chatType` to `GroupChat` as a thread belongs to a chat group. // Sets `isChatThread` to `true` to mark this message as a thread message. -ChatMessage message = ChatMessage.createTextMessage(targetId, content, chatType, {isChatThread}); +const message = ChatMessage.createTextMessage(chatThreadId, content, chatType, { + isChatThread: true, +}); // Implements `ChatMessageCallback` to listen for the message sending event. const callback = new ChatMessageCallback(); // Sends the message. @@ -77,8 +79,69 @@ class ChatMessageEvent implements ChatMessageEventListener { ``` -### Retrieve thread messages from the server +### Retrieve thread messages -For details about how to retrieve messages from the server, see Retrieve Conversations and Messages from Server. +You can retrieve thread messages locally or from the server, depending on your production environment. + +You can check `ChatConversation#isChatThread()` to determine whether the current conversation is a thread conversation. + +#### Retrieve messages of a thread from the server + +You can call `asyncFetchHistoryMessage` to retrieve messages of a thread from the server. The only difference between retrieving messages of a thread from the server and retrieving group messages is that a thread ID needs to be passed in for the former and a group ID is required for the latter. + +```typescript +// chatThreadID: The thread ID. +const chatThreadID = "chatThreadID"; +// The chat type is set to ChatConversationType.GroupChat as a thread belongs to a group. +const convType = ChatConversationType.GroupChat; +// The number of thread messages that you expect to get on each page. +const pageSize = 10; +// The starting message ID for retrieving. +const startMsgId = ""; +// The message search direction. +const direction = ChatSearchDirection.UP; +ChatClient.getInstance() + .chatManager.fetchHistoryMessages(chatThreadID, chatType, { + pageSize, + startMsgId, + direction, + }) + .then((messages) => { + console.log("get message success: ", messages); + }) + .catch((reason) => { + console.log("load conversions fail.", reason); + }); +``` + +#### Retrieve messages of a thread locally + +By calling [`getAllConversations`](/agora-chat/client-api/messages/manage-messages#retrieve-conversations), you can only retrieve local one-to-one chat conversations and group conversations. To retrieve messages of a thread locally, refer to the following code sample: + +```typescript +// Gets a thread conversation. +ChatClient.getInstance() + .chatManager.getThreadConversation(chatThreadID, createIfNeed) + .then((conv) => { + // Gets messages of the thread from the local database. The SDK automatically loads and stores the retrieved messages to the memory. + conv + .getMessages( + chatThreadID, + ChatConversationType.GroupChat, + startMsgId, + direction, + loadCount + ) + .then((messages) => { + console.log("success.", messages); + }) + .catch((reason) => { + console.log("fail.", reason); + }); + }) + .catch((reason) => { + console.log("fail.", reason); + }); +``` \ No newline at end of file diff --git a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/unity.mdx b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/unity.mdx index 49a99bb6a..542b198e8 100644 --- a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/unity.mdx +++ b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/unity.mdx @@ -5,7 +5,7 @@ Send a thread message is similar to send a message in a chat group. The difference lies in the `IsThread` field, as shown in the following code sample: ```csharp -// Creates a text message. `content` contains the message content, and `chatThreadId` contains the thread ID. +// Creates a text message. Sets `chatThreadId` to the thread ID and `content` to the message content. Message msg = Message.CreateTextSendMessage(chatThreadId, content); // Sets the message type. For thread messages, set `ChatType` as `GroupChat`. msg.MessageType = MessageType.Group @@ -78,21 +78,38 @@ For more information about recalling a message, see Retrieve Conversations and Messages from Server. +#### Retrieve messages of a thread from the server -#### Retrieve local messages +You can call `ChatManager#FetchHistoryMessagesFromServer` to retrieve messages of a thread from the server. The only difference between retrieving messages of a thread from the server and retrieving group messages is that a thread ID needs to be passed in for the former and a group ID is required for the latter. -Calling `EMChatManager#getAllConversations()` returns peer-to-peer messages and chat group messages but not thread messages. You can get specified thread messages from local database, as shown in the following code sample: +```c# +SDKClient.Instance.ChatManager.FetchHistoryMessagesFromServer(threadId, ConversationType.Group, startMsgId, pageSize, MessageSearchDirection.DOWN, new ValueCallBack>( + onSuccess: (result) => + { + foreach (var msg in result.Data) + { + //process every msg + } + }, + onError: (code, desc) => + { + } + )); +``` + +#### Retrieve messages of a thread locally + +By calling `ChatManager#LoadAllConversations`, you can only retrieve local one-to-one chat conversations and group conversations. To retrieve messages of a thread locally, refer to the following code sample: ```csharp // Specifies the conversation type by setting `ConversationType.Group` and setting `isChatThread` as `true`. Conversation conversation = SDKClient.Instance.ChatManager.GetConversation(chatThreadId, EMConversationType.GroupChat, createIfNotExists, isChatThread); -// If you want to handle thread messages from your local database, use the following methods to retrieve the messages. The SDK automatically saves these messages. +// If you want to handle thread messages from your local database, use the following methods to retrieve the messages. The SDK automatically loads and stores the retrieved messages to the memory. conversation.LoadMessages(startMsgId, count, direct, new ValueCallBack>( onSuccess: (list) => { Console.WriteLine($"LoadMessages found {list.Count} messages"); @@ -107,7 +124,4 @@ conversation.LoadMessages(startMsgId, count, direct, new ValueCallBack \ No newline at end of file diff --git a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/web.mdx b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/web.mdx index 6a353d98b..cf674c760 100644 --- a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/web.mdx +++ b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/web.mdx @@ -9,8 +9,8 @@ function sendTextMessage() { let option = { chatType: 'groupChat', // Sets `chatType` to `groupChat` as a thread belongs to a chat group. type: 'txt', // Sets `type` to `txt` to create and send a text message. - to: chatThreadId, // Sets `to` to the ID of a thread that receives the text message. - msg: 'message content', // Sets `msg` to the content of the text message. + to: chatThreadId, // Sets `to` to the thread ID. + msg: 'message content', // Sets `msg` to the content of the text message. isChatThread:true, // Sets `isChatThread` to `true` to mark this message as a thread message. } // Calls `create` to create a text message. @@ -77,8 +77,32 @@ conn.addEventHandler('MESSAGES',{ For more information about recalling a message, see Recall Messages. -### Retrieve thread messages from the server +### Retrieve messages of a thread from the server -For details about how to retrieve messages from the server, see Retrieve Historical Messages. +You can call `ChatManager#FetchHistoryMessagesFromServer` to retrieve messages of a thread from the server. The only difference between retrieving messages of a thread from the server and retrieving group messages is that a thread ID needs to be passed in for the former and a group ID is required for the latter. + +```javascript +let options = { + // The thread ID. + targetId: "threadId", + // The number of thread messages that you expect to get on each page. The value range is [1,50], with `20` as the default. + pageSize: 20, + // The starting message ID for retrieving. If you set this parameter to `-1`, `null`, or an empty string, the SDK retrieves messages from the latest one. + cursor: -1, + // The chat type is set to `groupChat` as a thread belongs to a group chat. + chatType: "groupChat", + // The message search direction: (Default): `up`: The SDK retrieves messages in the descending order of the time when the server receives the messages. `down`: The SDK retrieves messages in the ascending order of the time when the server receives the messages. + searchDirection: "up", +}; +conn + .getHistoryMessages(options) + .then((res) => { + // Succeed in getting historical messages. + console.log(res); + }) + .catch((e) => { + // Fail to get historical messages. + }); + ``` \ No newline at end of file diff --git a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/windows.mdx b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/windows.mdx index 29debc50c..3b9c38b93 100644 --- a/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/windows.mdx +++ b/shared/chat-sdk/client-api/threading/thread-messages/project-implementation/windows.mdx @@ -5,7 +5,7 @@ Send a thread message is similar to send a message in a chat group. The difference lies in the `IsThread` field, as shown in the following code sample: ```csharp -// Creates a text message. `content` contains the message content, and `chatThreadId` contains the thread ID. +// Creates a text message. Sets `chatThreadId` to the thread ID and `content` to the message content. Message msg = Message.CreateTextSendMessage(chatThreadId, content); // Sets the message type. For thread messages, set `ChatType` as `GroupChat`. msg.MessageType = MessageType.Group @@ -78,21 +78,37 @@ For more information about recalling a message, see Retrieve Conversations and Messages from Server. +You can call `ChatManager#FetchHistoryMessagesFromServer` to retrieve messages of a thread from the server. The only difference between retrieving messages of a thread from the server and retrieving group messages is that a thread ID needs to be passed in for the former and a group ID is required for the latter. -#### Retrieve local messages +```c# +SDKClient.Instance.ChatManager.FetchHistoryMessagesFromServer(threadId, ConversationType.Group, startMsgId, pageSize, MessageSearchDirection.DOWN, new ValueCallBack>( + onSuccess: (result) => + { + foreach (var msg in result.Data) + { + //process every message + } + }, + onError: (code, desc) => + { + } + )); +``` + +#### Retrieve messages of a thread locally -Calling `EMChatManager#getAllConversations()` returns peer-to-peer messages and chat group messages but not thread messages. You can get specified thread messages from local database, as shown in the following code sample: +By calling `ChatManager#LoadAllConversations`, you can only retrieve local one-to-one chat conversations and group conversations. To retrieve messages of a thread locally, refer to the following code sample: ```csharp // Specifies the conversation type by setting `ConversationType.Group` and setting `isChatThread` as `true`. Conversation conversation = SDKClient.Instance.ChatManager.GetConversation(chatThreadId, EMConversationType.GroupChat, createIfNotExists, isChatThread); -// If you want to handle thread messages from your local database, use the following methods to retrieve the messages. The SDK automatically saves these messages. +// If you want to handle thread messages from your local database, use the following methods to retrieve the messages. The SDK automatically loads and stores the retrieved messages to the memory. conversation.LoadMessages(startMsgId, count, direct, new ValueCallBack>( onSuccess: (list) => { Console.WriteLine($"LoadMessages found {list.Count} messages"); @@ -107,7 +123,4 @@ conversation.LoadMessages(startMsgId, count, direct, new ValueCallBack \ No newline at end of file diff --git a/shared/chat-sdk/client-api/user-attributes/project-implementation/android.mdx b/shared/chat-sdk/client-api/user-attributes/project-implementation/android.mdx index 3176b974f..aa1e8508e 100644 --- a/shared/chat-sdk/client-api/user-attributes/project-implementation/android.mdx +++ b/shared/chat-sdk/client-api/user-attributes/project-implementation/android.mdx @@ -42,6 +42,19 @@ ChatClient.getInstance().userInfoManager().updateOwnInfoByAttribute(UserInfoType }); ``` +When you call the [RESTful API](../restful-api/user-attributes-management#setting-user-attributes) to set the user's nickname, avatar, contact information, email address, gender, signature, birthday and extension fields, pass the following keys to make sure that the client can obtain the settings: + +| Field | Type | Description | +| :---------- | :----- | :----------------------------------------------------------- | +| `nickname` | String | The user nickname, which can contain at most 64 characters. | +| `avatarurl` | String | The user avatar URL, which can contain at most 256 characters. | +| `phone` | String | The user's phone number, which can contain at most 32 characters. | +| `mail` | String | The user's email address, which can contain at most 64 characters. | +| `gender` | Number | The user gender:
  • `1`:Male;
  • `2`:Female;
  • (Default) `0`: Unknown;
  • Other values are invalid.
| +| `sign` | String | The user's signature, which can contain at most 256 characters. | +| `birth` | String | The user's birthday, which can contain at most 256 characters. | +| `ext` | String | The extension fields. | + ### Retrieve user attributes You can use `fetchUserInfoByUserId` to retrieve the user attributes of the specified users. For each method call, you can retrieve the user attributes of a maximum of 100 users. diff --git a/shared/chat-sdk/client-api/user-attributes/project-implementation/flutter.mdx b/shared/chat-sdk/client-api/user-attributes/project-implementation/flutter.mdx index db5beff15..1ccafd6a2 100644 --- a/shared/chat-sdk/client-api/user-attributes/project-implementation/flutter.mdx +++ b/shared/chat-sdk/client-api/user-attributes/project-implementation/flutter.mdx @@ -12,7 +12,18 @@ try { } ``` - +When you call the [RESTful API](../restful-api/user-attributes-management#setting-user-attributes) to set the user's nickname, avatar, contact information, email address, gender, signature, birthday and extension fields, you must pass the following keys to make sure that the client can obtain the settings: + +| Field | Type | Description | +| :---------- | :----- | :----------------------------------------------------------- | +| `nickname` | String | The user nickname, which can contain at most 64 characters. | +| `avatarurl` | String | The user avatar URL, which can contain at most 256 characters. | +| `phone` | String | The user's phone number, which can contain at most 32 characters. | +| `mail` | String | The user's email address, which can contain at most 64 characters. | +| `gender` | Number | The user gender:
  • `1`:Male;
  • `2`:Female;
  • (Default) `0`: Unknown;
  • Other values are invalid.
| +| `sign` | String | The user's signature, which can contain at most 256 characters. | +| `birth` | String | The user's birthday, which can contain at most 256 characters. | +| `ext` | String | The extension fields. | ### Retrieve user attributes diff --git a/shared/chat-sdk/client-api/user-attributes/project-implementation/ios.mdx b/shared/chat-sdk/client-api/user-attributes/project-implementation/ios.mdx index 451650845..4a96e1926 100644 --- a/shared/chat-sdk/client-api/user-attributes/project-implementation/ios.mdx +++ b/shared/chat-sdk/client-api/user-attributes/project-implementation/ios.mdx @@ -32,6 +32,19 @@ NSString *url = @"https://download-sdk.oss-cn-beijing.aliyuncs.com/downloads/IMD }]; ``` +When you call the [RESTful API](../restful-api/user-attributes-management#setting-user-attributes) to set the user's nickname, avatar, contact information, email address, gender, signature, birthday and extension fields, you must pass the following keys to make sure that the client can obtain the settings: + +| Field | Type | Description | +| :---------- | :----- | :----------------------------------------------------------- | +| `nickname` | String | The user nickname, which can contain at most 64 characters. | +| `avatarurl` | String | The user avatar URL, which can contain at most 256 characters. | +| `phone` | String | The user's phone number, which can contain at most 32 characters. | +| `mail` | String | The user's email address, which can contain at most 64 characters. | +| `gender` | Number | The user gender:
  • `1`:Male;
  • `2`:Female;
  • (Default) `0`: Unknown;
  • Other values are invalid.
| +| `sign` | String | The user's signature, which can contain at most 256 characters. | +| `birth` | String | The user's birthday, which can contain at most 256 characters. | +| `ext` | String | The extension fields. | + ### Retrieve user attributes You can use `fetchUserInfoById` to retrieve the user attributes of the specified users. For each method call, you can retrieve the user attributes of a maximum of 100 users. diff --git a/shared/chat-sdk/client-api/user-attributes/project-implementation/react-native.mdx b/shared/chat-sdk/client-api/user-attributes/project-implementation/react-native.mdx index e2df69db8..f335edf9f 100644 --- a/shared/chat-sdk/client-api/user-attributes/project-implementation/react-native.mdx +++ b/shared/chat-sdk/client-api/user-attributes/project-implementation/react-native.mdx @@ -27,6 +27,19 @@ ChatClient.getInstance() }); ``` +When you call the [RESTful API](../restful-api/user-attributes-management#setting-user-attributes) to set the user's nickname, avatar, contact information, email address, gender, signature, birthday and extension fields, you must pass the following keys to make sure that the client can obtain the settings: + +| Field | Type | Description | +| :---------- | :----- | :----------------------------------------------------------- | +| `nickname` | String | The user nickname, which can contain at most 64 characters. | +| `avatarurl` | String | The user avatar URL, which can contain at most 256 characters. | +| `phone` | String | The user's phone number, which can contain at most 32 characters. | +| `mail` | String | The user's email address, which can contain at most 64 characters. | +| `gender` | Number | The user gender:
  • `1`:Male;
  • `2`:Female;
  • (Default) `0`: Unknown;
  • Other values are invalid.
| +| `sign` | String | The user's signature, which can contain at most 256 characters. | +| `birth` | String | The user's birthday, which can contain at most 256 characters. | +| `ext` | String | The extension fields. | + ### Retrieve user attributes You can use `fetchUserInfoById` to retrieve the user attributes of the specified users. For each method call, you can retrieve the user attributes of a maximum of 100 users. diff --git a/shared/chat-sdk/client-api/user-attributes/project-implementation/unity.mdx b/shared/chat-sdk/client-api/user-attributes/project-implementation/unity.mdx index 5d3314554..7c8f6932e 100644 --- a/shared/chat-sdk/client-api/user-attributes/project-implementation/unity.mdx +++ b/shared/chat-sdk/client-api/user-attributes/project-implementation/unity.mdx @@ -23,6 +23,19 @@ SDKClient.Instance.UserInfoManager.UpdateOwnInfo(userInfo, new CallBack( )); ``` +When you call the [RESTful API](../restful-api/user-attributes-management#setting-user-attributes) to set the user's nickname, avatar, contact information, email address, gender, signature, birthday and extension fields, you must pass the following keys to make sure that the client can obtain the settings: + +| Field | Type | Description | +| :---------- | :----- | :----------------------------------------------------------- | +| `nickname` | String | The user nickname, which can contain at most 64 characters. | +| `avatarurl` | String | The user avatar URL, which can contain at most 256 characters. | +| `phone` | String | The user's phone number, which can contain at most 32 characters. | +| `mail` | String | The user's email address, which can contain at most 64 characters. | +| `gender` | Number | The user gender:
  • `1`:Male;
  • `2`:Female;
  • (Default) `0`: Unknown;
  • Other values are invalid.
| +| `sign` | String | The user's signature, which can contain at most 256 characters. | +| `birth` | String | The user's birthday, which can contain at most 256 characters. | +| `ext` | String | The extension fields. | + ### Retrieve user attributes You can use `FetchUserInfoByUserId` to retrieve the user attributes of the specified users. For each method call, you can retrieve the user attributes of a maximum of 100 users. diff --git a/shared/chat-sdk/client-api/user-attributes/project-implementation/web.mdx b/shared/chat-sdk/client-api/user-attributes/project-implementation/web.mdx index 85660d53e..150468f32 100644 --- a/shared/chat-sdk/client-api/user-attributes/project-implementation/web.mdx +++ b/shared/chat-sdk/client-api/user-attributes/project-implementation/web.mdx @@ -32,6 +32,19 @@ WebIM.conn.updateUserInfo('nickname', 'Your nickname').then((res) => { }) ``` +When you call the [RESTful API](../restful-api/user-attributes-management#setting-user-attributes) to set the user's nickname, avatar, contact information, email address, gender, signature, birthday and extension fields, you must pass the following keys to make sure that the client can obtain the settings: + +| Field | Type | Description | +| :---------- | :----- | :----------------------------------------------------------- | +| `nickname` | String | The user nickname, which can contain at most 64 characters. | +| `avatarurl` | String | The user avatar URL, which can contain at most 256 characters. | +| `phone` | String | The user's phone number, which can contain at most 32 characters. | +| `mail` | String | The user's email address, which can contain at most 64 characters. | +| `gender` | Number | The user gender:
  • `1`:Male;
  • `2`:Female;
  • (Default) `0`: Unknown;
  • Other values are invalid.
| +| `sign` | String | The user's signature, which can contain at most 256 characters. | +| `birth` | String | The user's birthday, which can contain at most 256 characters. | +| `ext` | String | The extension fields. + ### Retrieve user attributes You can use `fetchUserInfoById` to retrieve the user attributes of the specified users. For each method call, you can retrieve the user attributes of a maximum of 100 users. diff --git a/shared/chat-sdk/client-api/user-attributes/project-implementation/windows.mdx b/shared/chat-sdk/client-api/user-attributes/project-implementation/windows.mdx index 2cb3e818a..4fbe6f73d 100644 --- a/shared/chat-sdk/client-api/user-attributes/project-implementation/windows.mdx +++ b/shared/chat-sdk/client-api/user-attributes/project-implementation/windows.mdx @@ -23,6 +23,19 @@ SDKClient.Instance.UserInfoManager.UpdateOwnInfo(userInfo, new CallBack( )); ``` +When you call the [RESTful API](../restful-api/user-attributes-management#setting-user-attributes) to set the user's nickname, avatar, contact information, email address, gender, signature, birthday and extension fields, you must pass the following keys to make sure that the client can obtain the settings: + +| Field | Type | Description | +| :---------- | :----- | :----------------------------------------------------------- | +| `nickname` | String | The user nickname, which can contain at most 64 characters. | +| `avatarurl` | String | The user avatar URL, which can contain at most 256 characters. | +| `phone` | String | The user's phone number, which can contain at most 32 characters. | +| `mail` | String | The user's email address, which can contain at most 64 characters. | +| `gender` | Number | The user gender:
  • `1`:Male;
  • `2`:Female;
  • (Default) `0`: Unknown;
  • Other values are invalid.
| +| `sign` | String | The user's signature, which can contain at most 256 characters. | +| `birth` | String | The user's birthday, which can contain at most 256 characters. | +| `ext` | String | The extension fields. | + ### Retrieve user attributes You can use `FetchUserInfoByUserId` to retrieve the user attributes of the specified users. For each method call, you can retrieve the user attributes of a maximum of 100 users. diff --git a/shared/chat-sdk/develop/_authentication.mdx b/shared/chat-sdk/develop/_authentication.mdx index cb8512e7c..aaac86990 100644 --- a/shared/chat-sdk/develop/_authentication.mdx +++ b/shared/chat-sdk/develop/_authentication.mdx @@ -1,6 +1,11 @@ Authentication is the process of validating identities. Agora uses digital tokens to authenticate users and their privileges before they access an Agora service, such as joining an Agora call, or logging in to Agora Chat. -To ensure security in real-time communication, Agora provide tokens for you to authenticate your users. Tokens, generated in your app server, can be used in the following scenarios: +To ensure security in real-time communication, Agora provides tokens for you to authenticate your users. For test purposes, you can generate temporary tokens in Agora Console. +See [Manage users and generate tokens](../get-started/enable?platform=react-native#manage-users-and-generate-tokens) for details. + +However, in the development environment, you need to deploy your own app server to use AgoraTools to generate tokens. + +Tokens, generated in your app server, can be used in the following scenarios: | Applicable scenarios | Used Token | Token consists of the following | Token maximum validity period | | -------------------- | ---------------------- | ---------------------- | ---------------------- | @@ -9,7 +14,6 @@ To ensure security in real-time communication, Agora provide tokens for you to a This page introduces how to retrieve tokens from your app server to authenticate your users. - ## Understand the tech - The following diagram shows the process of authenticating users using a token with app privileges. @@ -18,7 +22,6 @@ This page introduces how to retrieve tokens from your app server to authenticate - The following diagram shows the process of authenticating users using a token with user privileges. ![](https://web-cdn.agora.io/docs-files/1663232538814) - ## Prerequisites In order to follow this procedure, you must have the following: @@ -44,7 +47,7 @@ To show the authentication workflow, this section shows how to build and run a t
This sample server is for demonstration purposes only. Do not use it in a production environment.
The following figure shows the API call sequence of generating an Agora Chat token with user privileges: -![](https://web-cdn.agora.io/docs-files/1663232557791) +![token_generate_user_token](/images/chat/token_generate_user_token.png) 1. Create a Maven project in IntelliJ, set the name of your project, choose the location to save your project, then click **Finish**. @@ -52,7 +55,7 @@ The following figure shows the API call sequence of generating an Agora Chat tok ```xml - 1.8 + 11 2.4.3 @@ -88,6 +91,18 @@ The following figure shows the API call sequence of generating an Agora Chat tok commons-codec 1.14 + + com.google.guava + guava + 30.0-jre + + + + + io.agora + authentication + 2.0.0 + @@ -108,19 +123,7 @@ The following figure shows the API call sequence of generating an Agora Chat tok ``` -3. Import the token builders provided by Agora into your project: - - 1. Download the [chat](https://github.com/AgoraIO/Tools/tree/master/DynamicKey/AgoraDynamicKey/java/src/main/java/io/agora/chat) and [media](https://github.com/AgoraIO/Tools/tree/master/DynamicKey/AgoraDynamicKey/java/src/main/java/io/agora/media) packages. - 2. In your token server project, create a `com.agora.chat.token.io.agora` package under `/src/main/java`. - 3. Copy the `chat` and `media` packages and paste them under `com.agora.chat.token.io.agora`. Now the project structure is as following screenshot shows: - ![](https://web-cdn.agora.io/docs-files/1638864182234) - 4. Fix the import errors in the `chat/ChatTokenBuilder2` and `media/AccessToken` files. - - In `ChatTokenBuilder2`, change `package io.agora.chat;` to `package com.agora.chat.token.io.agora.chat;` and change `import io.agora.media.AccessToken2;` to `import com.agora.chat.token.io.agora.media.AccessToken2;`. - - In all files of the `com.agora.chat.token.io.agora.media` package, change `package io.agora.media;` to `package com.agora.chat.token.io.agora.media;`. - - In `AccessToken`, change `import static io.agora.media.Utils.crc32;` to `import static com.agora.chat.token.io.agora.media.Utils.crc32;`. - - -4. In `/src/main/resource`, create an `application.properties` file to store the information for generating tokens and update it with your project information and token validity period. For example, set `expire.second` as `6000`, which means the token is valid for 6000 seconds. +3. In `/src/main/resource`, create an `application.properties` file to store the information for generating tokens and update it with your project information and token validity period. For example, set `expire.second` as `6000`, which means the token is valid for 6000 seconds. ``` shellscript ## Server port. @@ -140,154 +143,218 @@ The following figure shows the API call sequence of generating an Agora Chat tok
To get the app key and the RESTful API domain, refer to Get the information of the Agora Chat project.
-5. In the `com.agora.chat.token` package, create a Java class named `AgoraChatTokenController` with the following content: +4. In the `com.agora.chat.token` package, create a Java class named `AgoraChatTokenController` with the following content: ```java package com.agora.chat.token; - import com.agora.chat.token.io.agora.chat.ChatTokenBuilder2; - import com.agora.chat.token.io.agora.media.AccessToken2; - import org.springframework.beans.factory.annotation.Value; - import org.springframework.http.*; - import org.springframework.util.StringUtils; - import org.springframework.web.bind.annotation.CrossOrigin; - import org.springframework.web.bind.annotation.GetMapping; - import org.springframework.web.bind.annotation.PathVariable; - import org.springframework.web.bind.annotation.RestController; - import org.springframework.web.client.RestClientException; - import org.springframework.web.client.RestTemplate; - - import java.util.Collections; - import java.util.HashMap; - import java.util.List; - import java.util.Map; - - @RestController - @CrossOrigin - public class AgoraChatTokenController { - - @Value("${appid}") - private String appid; - - @Value("${appcert}") - private String appcert; - - @Value("${expire.second}") - private int expire; - - @Value("${appkey}") - private String appkey; - - @Value("${domain}") - private String domain; - - private final RestTemplate restTemplate = new RestTemplate(); - - // Gets a token with app privileges. - @GetMapping("/chat/app/token") - public String getAppToken() { - if (!StringUtils.hasText(appid) || !StringUtils.hasText(appcert)) { - return "appid or appcert is not empty"; - } + import com.google.common.cache.Cache; + import com.google.common.cache.CacheBuilder; + import io.agora.chat.ChatTokenBuilder2; + import org.springframework.beans.factory.annotation.Value; + import org.springframework.http.*; + import org.springframework.util.StringUtils; + import org.springframework.web.bind.annotation.CrossOrigin; + import org.springframework.web.bind.annotation.GetMapping; + import org.springframework.web.bind.annotation.PathVariable; + import org.springframework.web.bind.annotation.RestController; + import org.springframework.web.client.RestClientException; + import org.springframework.web.client.RestTemplate; - // Generates a token with app privileges. - AccessToken2 accessToken = new AccessToken2(appid, appcert, expire); - AccessToken2.Service serviceChat = new AccessToken2.ServiceChat(); - serviceChat.addPrivilegeChat(AccessToken2.PrivilegeChat.PRIVILEGE_CHAT_APP, expire); - accessToken.addService(serviceChat); + import javax.annotation.PostConstruct; + import java.util.*; + import java.util.concurrent.TimeUnit; - try { - return accessToken.build(); - } catch (Exception e) { - e.printStackTrace(); - return ""; - } - } + @RestController + @CrossOrigin + public class AgoraChatTokenController { - // Gets a token with user privileges. - @GetMapping("/chat/user/{chatUserName}/token") - public String getChatUserToken(@PathVariable String chatUserName) { - if (!StringUtils.hasText(appid) || !StringUtils.hasText(appcert)) { - return "appid or appcert is not empty"; - } - if (!StringUtils.hasText(appkey) || !StringUtils.hasText(domain)) { - return "appkey or domain is not empty"; - } - if (!appkey.contains("#")) { - return "appkey is illegal"; - } - if (!StringUtils.hasText(chatUserName)) { - return "chatUserName is not empty"; - } - ChatTokenBuilder2 builder = new ChatTokenBuilder2(); - String chatUserUuid = getChatUserUuid(chatUserName); - if (chatUserUuid == null) { - chatUserUuid = registerChatUser(chatUserName); - } + @Value("${appid}") + private String appid; - // Generates a token with user privileges. - AccessToken2 accessToken = new AccessToken2(appid, appcert, expire); - AccessToken2.Service serviceChat = new AccessToken2.ServiceChat(chatUserUuid); - serviceChat.addPrivilegeChat(AccessToken2.PrivilegeChat.PRIVILEGE_CHAT_USER, expire); - accessToken.addService(serviceChat); + @Value("${appcert}") + private String appcert; - try { - return accessToken.build(); - } catch (Exception e) { - e.printStackTrace(); - return ""; - } - } + @Value("${expire.second}") + private int expire; - // Gets the UUID of the user. - private String getChatUserUuid(String chatUserName) { - String orgName = appkey.split("#")[0]; - String appName = appkey.split("#")[1]; - String url = "http://" + domain + "/" + orgName + "/" + appName + "/users/" + chatUserName; - HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - headers.setBearerAuth(getAppToken()); - HttpEntity> entity = new HttpEntity<>(null, headers); - ResponseEntity responseEntity = null; - try { - responseEntity = restTemplate.exchange(url, HttpMethod.GET, entity, Map.class); - } catch (Exception e) { - System.out.println("get chat user error : " + e.getMessage()); - } - if (responseEntity != null) { - List> results = (List>) responseEntity.getBody().get("entities"); - return (String) results.get(0).get("uuid"); - } - return null; - } + @Value("${appkey}") + private String appkey; - // Creates a user with the password "123", and gets UUID. - private String registerChatUser(String chatUserName) { - String orgName = appkey.split("#")[0]; - String appName = appkey.split("#")[1]; - String url = "http://" + domain + "/" + orgName + "/" + appName + "/users"; - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - headers.setBearerAuth(getAppToken()); - Map body = new HashMap<>(); - body.put("username", chatUserName); - body.put("password", "123"); - HttpEntity> entity = new HttpEntity<>(body, headers); - ResponseEntity response; - try { - response = restTemplate.exchange(url, HttpMethod.POST, entity, Map.class); - } catch (Exception e) { - throw new RestClientException("register chat user error : " + e.getMessage()); - } - List> results = (List>) response.getBody().get("entities"); - return (String) results.get(0).get("uuid"); - } - } + @Value("${domain}") + private String domain; + + private final RestTemplate restTemplate = new RestTemplate(); + + private Cache agoraChatAppTokenCache; + + @PostConstruct + public void init() { + agoraChatAppTokenCache = CacheBuilder.newBuilder().maximumSize(1).expireAfterWrite(expire, TimeUnit.SECONDS).build(); + } + + /** + * Gets a token with app privileges. + * + * @return app privileges token + */ + @GetMapping("/chat/app/token") + public String getAppToken() { + + if (!StringUtils.hasText(appid) || !StringUtils.hasText(appcert)) { + return "appid or appcert is not empty"; + } + + return getAgoraAppToken(); + } + + /** + * Gets a token with user privileges. + * + * @param chatUserName ChatUserName + * @return user privileges token + */ + @GetMapping("/chat/user/{chatUserName}/token") + public String getChatToken(@PathVariable String chatUserName) { + + if (!StringUtils.hasText(appid) || !StringUtils.hasText(appcert)) { + return "appid or appcert is not empty"; + } + + if (!StringUtils.hasText(appkey) || !StringUtils.hasText(domain)) { + return "appkey or domain is not empty"; + } + + if (!appkey.contains("#")) { + return "appkey is illegal"; + } + + if (!StringUtils.hasText(chatUserName)) { + return "chatUserName is not empty"; + } + + ChatTokenBuilder2 builder = new ChatTokenBuilder2(); + + String chatUserUuid = getChatUserUuid(chatUserName); + + if (chatUserUuid == null) { + chatUserUuid = registerChatUser(chatUserName); + } + + return builder.buildUserToken(appid, appcert, chatUserUuid, expire); + } + + /** + * Creates a user with the password "123", and gets UUID. + * + * @param chatUserName The username of the agora chat user. + * @return uuid + */ + private String registerChatUser(String chatUserName) { + + String orgName = appkey.split("#")[0]; + + String appName = appkey.split("#")[1]; + + String url = "http://" + domain + "/" + orgName + "/" + appName + "/users"; + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setBearerAuth(getAgoraChatAppTokenFromCache()); + + Map body = new HashMap<>(); + body.put("username", chatUserName); + body.put("password", "123"); + + HttpEntity> entity = new HttpEntity<>(body, headers); + + ResponseEntity response; + + try { + response = restTemplate.exchange(url, HttpMethod.POST, entity, Map.class); + } catch (Exception e) { + throw new RestClientException("register chat user error : " + e.getMessage()); + } + + List> results = (List>) response.getBody().get("entities"); + + return (String) results.get(0).get("uuid"); + } + + /** + * Gets the UUID of the user. + * + * @param chatUserName The username of the agora chat user. + * @return uuid + */ + private String getChatUserUuid(String chatUserName) { + + String orgName = appkey.split("#")[0]; + + String appName = appkey.split("#")[1]; + + String url = "http://" + domain + "/" + orgName + "/" + appName + "/users/" + chatUserName; + + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setBearerAuth(getAgoraChatAppTokenFromCache()); + + HttpEntity> entity = new HttpEntity<>(null, headers); + + ResponseEntity responseEntity = null; + + try { + responseEntity = restTemplate.exchange(url, HttpMethod.GET, entity, Map.class); + } catch (Exception e) { + System.out.println("get chat user error : " + e.getMessage()); + } + + if (responseEntity != null) { + + List> results = (List>) responseEntity.getBody().get("entities"); + + return (String) results.get(0).get("uuid"); + } + + return null; + } + + /** + * Generate a token with app privileges. + * + * @return token + */ + private String getAgoraAppToken() { + if (!StringUtils.hasText(appid) || !StringUtils.hasText(appcert)) { + throw new IllegalArgumentException("appid or appcert is not empty"); + } + + // Use agora App Id and App Cert to generate an Agora app token. + ChatTokenBuilder2 builder = new ChatTokenBuilder2(); + return builder.buildAppToken(appid, appcert, expire); + } + + /** + * Get the token with app privileges from the cache + * + * @return token + */ + private String getAgoraChatAppTokenFromCache() { + try { + return agoraChatAppTokenCache.get("agora-chat-app-token", () -> { + return getAgoraAppToken(); + }); + } catch (Exception e) { + throw new IllegalArgumentException("Get Agora Chat app token from cache error"); + } + } + + } ``` -6. In the `com.agora.chat.token` package, create a Java class named `AgoraChatTokenStarter` with the following content: +5. In the `com.agora.chat.token` package, create a Java class named `AgoraChatTokenStarter` with the following content: ```java package com.agora.chat.token; @@ -303,7 +370,7 @@ The following figure shows the API call sequence of generating an Agora Chat tok } ``` -7. To start the server, click the green triangle button, and select **Debug "AgoraChatTokenStarter..."**. +6. To start the server, click the green triangle button, and select **Debug "AgoraChatTokenStarter..."**. ![](https://web-cdn.agora.io/docs-files/1638868741690) @@ -402,7 +469,15 @@ try { return ""; } ``` +Add the AgoraTools dependency to pom.xml: +``` + + io.agora + authentication + 2.0.0 + +``` To show the authentication workflow, this section shows how to build and run a Web client on your local machine.
This sample client is for demonstration purposes only. Do not use it in a production environment.
@@ -453,7 +528,7 @@ To implement the Web client, do the following: "author": "", "license": "ISC", "dependencies": { - "agora-chat-sdk": "latest" + "agora-chat": "latest" }, "devDependencies": { "webpack": "^5.50.0", @@ -579,7 +654,7 @@ To implement the Web client, do the following: The `index.html` page opens in your browser. 3. Input a user name and click the login button. - Open the browser console, and you can see the web client performs the following actions: + Open the browser console, and you can see the web client performs the following actions: - Generates a token with user privileges. - Connects to the Agora Chat system. - Renews a token when it is about to expire. @@ -639,11 +714,17 @@ This section introduces the method to generate a token for Agora Chat. Take Java A token for Agora Chat is valid for a maximum of 24 hours. -When a privilege is about to expire or has expired, the RTC SDK triggers the `onTokenWillExpire` callback or the `onTokenExpired` callback. You need to take the following actions in your own app logic: +When a token is about to expire or has expired, the Chat SDK triggers the `onTokenWillExpire` callback or the `onTokenExpired` callback. You need to take the following actions in your own app logic: - Tag the type of privilege that is about to expire or has expired in your app logic. -- The app fetches a new AccessToken2 from the token server. -- The SDK calls `renewToken` to renew the AccessToken2. +- The app fetches a new token from the app server. +- The SDK calls `renewToken` to renew the token. + +### Reconnection upon token expiration + +Automatic reconnection upon token expiration can ensure that the Agora Chat service of end users remains connected when the application is running in the background, and does not need to log in again when re-entering the application. The implementation process is as follows: +1. [Deploy an app server](#deploy-an-app-server-to-generate-tokens) to generate tokens and provide an API for retrieving tokens. +2. Implement monitoring for token expiration on your app. When the token expires, your app needs to obtain a new token via the token retrieval API, and logs in to the Agora server again. ### Tokens for Agora RTC products diff --git a/shared/chat-sdk/develop/_cross_border_proxy.mdx b/shared/chat-sdk/develop/_cross_border_proxy.mdx new file mode 100644 index 000000000..5fe37f2c1 --- /dev/null +++ b/shared/chat-sdk/develop/_cross_border_proxy.mdx @@ -0,0 +1,7 @@ +With the development of economic globalization and the advancement of Internet technologies, cross-border dedicated proxy is indispensable for many enterprises. It can help enterprises better cope with the pressure of international competition and expand overseas markets. + +In order to improve the instant messaging experience for enterprises conducting global business and meet the communication needs of end users in the Chinese mainland and other regions, Agora has set up dedicated lines from the Chinese mainland to Hong Kong and vice versa. + +Online education enterprises are typical cases, where teachers and students tend to be located in different countries and regions. For example, American teachers teach English courses to Chinese students through online videos. Enabling the dedicated proxy can greatly improve the use experience of Agora Chat. + +This service is disabled by default. To enable it, contact [support@agora.io](mailto:support@agora.io). \ No newline at end of file diff --git a/shared/chat-sdk/develop/_setup-webhooks.mdx b/shared/chat-sdk/develop/_setup-webhooks.mdx index 1f52ad01a..0002b2728 100644 --- a/shared/chat-sdk/develop/_setup-webhooks.mdx +++ b/shared/chat-sdk/develop/_setup-webhooks.mdx @@ -62,29 +62,30 @@ To receive the HTTP callbacks, you need to configure rules for the pre- or post- 1. Log in to Agora Console and find your project on the Project Management page, then click the edit button. 2. Find **Chat** on the project editing page, and click **Configure**. -3. Click **Add Target Url** in the **Real-time Callback** section on the configuration page. +3. Choose **Features** > **Callback** and click **Add Callback Address** on the **Callback** page. - ![1645523175808](https://web-cdn.agora.io/docs-files/1645523175808) + ![](/images/chat/callback_addr_list.png) -4. To add a rule for pre-delivery callbacks, fill the following fields under the **pre send** tab and then click **Save**. +4. To add a rule for pre-delivery callbacks, fill the following fields under the **Pre send** tab and then click **Save**. - Rule Name: Enter a name for the rule. Under one project, each rule must have a unique name. - Chat Type: Select the types of chat this rule applies to. - Message Type: Select the types of messages this rule applies to. - - Timeout: (Optional) Specify the time (in ms) that the Chat server should wait for the HTTP responses. The default value is 200 ms. If the reponse times out, the Chat server continues with the fallback action. - - Fallback Action: (Optional) Select the action of the Chat server when the HTTP response times out or returns errors. The default option is pass. - - Target Url: Enter the URL of your app server for receiving the pre-delivery callbacks. Supports both HTTP and HTTPS URLs. - - Rejection Behaviour: (Optional) Set whether to notify the message sender when their message is rejected. The default option is to not notify the message sender. + - Timeout: (Optional) Specify the time (in ms) that the Agora Chat server should wait for the HTTP responses. The default value is 200 ms. If the response times out, the Agora Chat server continues with the fallback action. + - Fallback Action: (Optional) Select the action of the Agora Chat server when the HTTP response times out or an error is returned. The default value is **Passed**. + - Report Error: (Optional) Set whether to notify the message sender when their message is rejected. The default value is **No**, indicating that the sender is not notified of the message delivery failure. + - Status: Set whether to enable this rule. The default value is **Enabled**. + - Callback Address: Enter the URL of your app server for receiving the pre-delivery callbacks. Both HTTP and HTTPS URLs are allowed. -5. To add a rule for post-delivery callbacks, fill the following fields under the **post send** tab and then click **Save**. +5. To add a rule for post-delivery callbacks, fill the following fields under the **Post send** tab and then click **Save**. - Rule Name: Enter a name for the rule. Under one project, each rule must have a unique name. - Callback Service: Select the types of chat or events this rule applies to. - - Message Type: Select the types of messages this rule applies to. - Message Status: Select whether this rule applies to chat or offline messages, or both. - To synchronize the chat history on your own server, select chat messages. All messages sent by the users are chat messages, regardless of the online status of the message receiver. - To push message notifications, select offline messages. Messages sent to an offline user are counted as offline messages. - - Target Url: Enter the URL of your app server for receiving the post-delivery callbacks. Supports both HTTP and HTTPS URLs. + - Status: Set whether to enable this rule. The default value is **Disabled**. + - Callback Address: Enter the URL of your app server for receiving the post-delivery callbacks. Both HTTP and HTTPS URLs are allowed. The rules take effect immediately. @@ -101,10 +102,10 @@ To enhance the security of the callbacks, Chat includes a signature in the reque To verify the signature in a callback, do the following: 1. Retrieve the following information: - - The callback ID, which is the callId paramater in the request body of the callback. + - The callback ID, which is the callId parameter in the request body of the callback. - The secret assigned to the callback rule. You can find this value on the Chat configuration page in Agora Console. - ![1645523345319](https://web-cdn.agora.io/docs-files/1645523345319) + ![1645523345319](/images/chat/callback_secret.png) - The callback timestamp, which is the timestamp parameter in the request body of the callback. diff --git a/shared/chat-sdk/develop/callkit/project-implementation/ios.mdx b/shared/chat-sdk/develop/callkit/project-implementation/ios.mdx index 0746fb62a..10161b652 100644 --- a/shared/chat-sdk/develop/callkit/project-implementation/ios.mdx +++ b/shared/chat-sdk/develop/callkit/project-implementation/ios.mdx @@ -197,6 +197,8 @@ During the call, you can also listen for the following callback events: } ``` +When receiving the `callDidJoinChannel:uid` or `remoteUserDidJoinChannel:uid:username:` callback, the user needs to look up the Chat user ID corresponding to the Agora UID in you app server. If the Chat user ID is found, construct a dictionary with Agora UID and Chat user ID and then set it to the app using `setUsers:channelName:`. + ### End the call A one-to-one call ends as soon as one of the two users hangs up, while a group call ends only after the local user hangs up. When the call ends, the SDK triggers the `callDidEnd` callback. diff --git a/shared/chat-sdk/develop/callkit/project-implementation/web.mdx b/shared/chat-sdk/develop/callkit/project-implementation/web.mdx index c1fee39c4..c6714fdfe 100644 --- a/shared/chat-sdk/develop/callkit/project-implementation/web.mdx +++ b/shared/chat-sdk/develop/callkit/project-implementation/web.mdx @@ -81,7 +81,7 @@ The following screenshot gives an example of the user interface after sending a ### Receive the invitation -Once a call invitaion is sent, if the callee is online and available for a call, the callee receives the invitation in the `onInvite` callback. You can pop out a user interface that allows the callee to accept or decline the invitation in this callback. +Once a call invitation is sent, if the callee is online and available for a call, the callee receives the invitation in the `onInvite` callback. You can pop out a user interface that allows the callee to accept or decline the invitation in this callback. ```javascript /** diff --git a/shared/chat-sdk/develop/callkit/project-setup/web.mdx b/shared/chat-sdk/develop/callkit/project-setup/web.mdx index 387294a67..c3adec100 100644 --- a/shared/chat-sdk/develop/callkit/project-setup/web.mdx +++ b/shared/chat-sdk/develop/callkit/project-setup/web.mdx @@ -3,7 +3,7 @@ 1. In your terminal, run the following command to install the call kit: ```bash - npm install AgoraChatCallKit + npm install chat-callkit ``` 2. Add the following line to import the callkit: diff --git a/shared/chat-sdk/develop/callkit/reference/web.mdx b/shared/chat-sdk/develop/callkit/reference/web.mdx index cee0ec8f4..c712d2b9f 100644 --- a/shared/chat-sdk/develop/callkit/reference/web.mdx +++ b/shared/chat-sdk/develop/callkit/reference/web.mdx @@ -21,12 +21,14 @@ Callbacks: | onInvite | Occurs when the call invitation is received. | | onStateChange | Occurs when the call state changes. | -Attributes +Attributes: | Attribute | Description | | --- | --- | | contactAvatar | The avatar displayed during one-to-one calls. | -| groupAvatar | The avatar displayed during group calls. +| groupAvatar | The avatar displayed during group calls. | +| ringingSource | The ringtone file. | + ### Sample project diff --git a/shared/chat-sdk/get-started/_enable.mdx b/shared/chat-sdk/get-started/_enable.mdx index bdf0f3ef5..8db55af51 100644 --- a/shared/chat-sdk/get-started/_enable.mdx +++ b/shared/chat-sdk/get-started/_enable.mdx @@ -52,7 +52,7 @@ For details about these advanced features, see the following: assigns the following information to each project that enables : -- **Data Center**: provides several data centers for the service in different regions, including Beijing1 (China), Beijing VIP (China), Singapore, Frankfurt (Germany), and Virginia (USA). After the plan is changed, the data center remains unchanged. +- **Data Center**: provides several data centers for the service in different regions, including Singapore, Frankfurt (Germany), and Virginia (USA). After the plan is changed, the data center remains unchanged. - **AppKey**: The unique identifier that assigns to each app. The **AppKey** is of the form `${OrgName}#{AppName}`. - **OrgName**: The unique identifier that assigns to each enterprise (organization). - **AppName**: The name that assigns to each app. Each app under the same enterprise (organization) must have a unique App Name. @@ -90,6 +90,11 @@ To register a user, do the following: ![](https://web-cdn.agora.io/docs-files/1664531162872) +### Generate an app token + +In the **Data Center** section of the **Application Information** page, click **Generate** next to **Chat App Temp Token** to generate a token with app privileges. + + ![token_generate_app_token](/images/chat/token_generate_app_token.png) ### Generate a user token @@ -109,7 +114,6 @@ For testing purposes, supports generating temporary tokens fo ![](https://web-cdn.agora.io/docs-files/1664531214169) - ## Change the plan 1. Log in to the [](https://console.agora.io). diff --git a/shared/chat-sdk/get-started/get-started-sdk/project-implementation/flutter.mdx b/shared/chat-sdk/get-started/get-started-sdk/project-implementation/flutter.mdx index 13ade2814..06f04fe4e 100644 --- a/shared/chat-sdk/get-started/get-started-sdk/project-implementation/flutter.mdx +++ b/shared/chat-sdk/get-started/get-started-sdk/project-implementation/flutter.mdx @@ -205,6 +205,8 @@ To implement this workflow in your , take the following steps: ); agoraChatClient = ChatClient.getInstance; await agoraChatClient.init(options); + // Notify the SDK that the Ul is ready. After the following method is executed, callbacks within ChatRoomEventHandler and ChatGroupEventHandler can be triggered. + await ChatClient.getlnstance.startCallback(); } ``` @@ -315,19 +317,23 @@ To implement this workflow in your , take the following steps: targetId: recipientId, content: messageContent, ); - msg.setMessageStatusCallBack(MessageStatusCallBack( - onSuccess: () { - displayMessage(messageContent, true); - messageBoxController.text = ""; - messageContent = ""; - FocusManager.instance.primaryFocus?.unfocus(); - }, - onError: (e) { - showLog( - "Send message failed, code: ${e.code}, desc: ${e.description}", - ); - }, - )); + ChatClient.getInstance.chatManager.addMessageEvent( + "UNIQUE_HANDLER_ID", + ChatMessageEvent( + onSuccess: (msgId, msg) { + _addLogToConsole("on message succeed"); + }, + onProgress: (msgId, progress) { + _addLogToConsole("on message progress"); + }, + onError: (msgId, msg, error) { + _addLogToConsole( + "on message failed, code: ${error.code}, desc: ${error.description}", + ); + }, + ), + ); + ChatClient.getInstance.chatManager.removeMessageEvent("UNIQUE_HANDLER_ID"); agoraChatClient.chatManager.sendMessage(msg); } ``` diff --git a/shared/chat-sdk/get-started/get-started-sdk/project-setup/ios.mdx b/shared/chat-sdk/get-started/get-started-sdk/project-setup/ios.mdx index b2fe119e1..03431777b 100644 --- a/shared/chat-sdk/get-started/get-started-sdk/project-setup/ios.mdx +++ b/shared/chat-sdk/get-started/get-started-sdk/project-setup/ios.mdx @@ -24,7 +24,7 @@ To integrate into your app, do the following: https://github.com/AgoraIO/AgoraChat_iOS.git ``` - You see the available packages. In ****, specify the latest version, for example `1.0.9`. You can obtain the latest version information using [Maven Central Repository Search](https://search.maven.org/search?q=g:io.agora.rtc%20AND%20a:chat-sdk). + You see the available packages. In ****, specify the latest version, for example `1.0.9`. You can obtain the latest version information in the [release notes](../reference/release-notes). 1. Click **Add Package**. In the new window, click **Add Package**. diff --git a/shared/chat-sdk/get-started/get-started-sdk/reference/ios.mdx b/shared/chat-sdk/get-started/get-started-sdk/reference/ios.mdx index f407c3507..43942acbe 100644 --- a/shared/chat-sdk/get-started/get-started-sdk/reference/ios.mdx +++ b/shared/chat-sdk/get-started/get-started-sdk/reference/ios.mdx @@ -1,5 +1,30 @@ +### Integrate the SDK through CocoaPods + +1. Install CocoaPods. For details, see [Getting Started with CocoaPods](https://guides.cocoapods.org/using/getting-started.html#getting-started). + +1. In the Terminal, navigate to the project root directory and run the `pod init` command to create a text file `Podfile` in the project folder. + +1. Open the `Podfile` file and add the Agora Chat SDK. Remember to replace `Your project target` with the target name of your project. + + ```swift + platform :ios, '11.0' + + target 'Your project target' do + pod 'Agora_Chat_iOS' + end + ``` +1. In the project root directory, run the following command to integrate the SDK: + + ```swift + pod install + ``` + + When the SDK is installed successfully, you can see `Pod installation complete!` in the Terminal and an `xcworkspace` file in the project folder. + +1. Open the xcworkspace file in Xcode. + ### API reference - AgoraChatClient.initializeSDKWithOptions diff --git a/shared/chat-sdk/get-started/get-started-uikit/next-steps/web.mdx b/shared/chat-sdk/get-started/get-started-uikit/next-steps/web.mdx index ed8b5011f..469f3ef5b 100644 --- a/shared/chat-sdk/get-started/get-started-uikit/next-steps/web.mdx +++ b/shared/chat-sdk/get-started/get-started-uikit/next-steps/web.mdx @@ -2,48 +2,6 @@ This section includes more advanced features you can implement in your project. -### Applicable use cases - -As a conversation component, `EaseChat` can be applied in a wide range of use cases, for example, by popping up the dialogue box for a click event, or adding callback events after the user is logged in. - -```javascript -import React, { useState } from "react"; -import { EaseChat } from "agora-chat-uikit"; - const addListen = (res) => { - if(res.isLogin){ - const WebIM = EaseChat.getSdk() - WebIM.conn.addEventHandler('testListen',{ - onTextMessage:()=>{}, - onError:()=>{}, - ... - }) - } - } - const chat = () => { - return ( -
- -
- ) - } - const app = () =>{ - const [showSession, setShowSession] = useState(false); - return( -
- { showSession && chat()} - - -
- ) - } -``` - ### Customizable attributes `EaseChat` provides the following attributes for customization. You can customize the features and layout by setting these attributes. To ensure the functionality of `EaseChat`, ensure that you set all the required parameters. @@ -54,7 +12,7 @@ import { EaseChat } from "agora-chat-uikit"; | `username` |String| Yes | The user ID. | | `agoraToken` |String| Yes | The token. | | `to` |String| Yes | In one-to-one messaging, it is the user ID of the recipient; in group chat, it is the group ID.| -| `showByselfAvatar`|Bool| No | Whether to display the avatar of the current user.
  • `true`: Yes
  • (Default) `false`: No
| +| `showByselfAvatar`|Boolean| No | Whether to display the avatar of the current user.
  • `true`: Yes
  • (Default) `false`: No
| | `easeInputMenu`|String| No | The mode of the input menu.
  • (Default) `all`: The complete mode.
  • `noAudio`: No audio.
  • `noEmoji`: No emoji.
  • `noAudioAndEmoji`: No audio or emoji.
  • `onlyText`: Only text.
|`menuList`|Array| No |The extensions of the input box on the right panel.
(Default) `menuList`: `[ {name:'Send a pic', value:'img'},{name:'Send a file', value:'file'}]` | |`handleMenuItem`|`function({item, key}`) | No | The callback event triggered by clicking on the right panel of the input box.| @@ -68,7 +26,7 @@ In scenarios where you want to add your own business logic, you can use the vari 1. Get the SDK instance ```javascript - const WebIM = EaseChat.getSdk({ appkey: 'xxxx' }) + const WebIM = EaseApp.getSdk({ appkey: 'xxxx' }) ``` 2. Add callback events diff --git a/shared/chat-sdk/get-started/get-started-uikit/project-implementation/android.mdx b/shared/chat-sdk/get-started/get-started-uikit/project-implementation/android.mdx index 2141758e2..77b2151dc 100644 --- a/shared/chat-sdk/get-started/get-started-uikit/project-implementation/android.mdx +++ b/shared/chat-sdk/get-started/get-started-uikit/project-implementation/android.mdx @@ -397,7 +397,7 @@ To enable your app to send and receive messages between individual users, do the return; } // 1: single chat; 2: group chat; 3: chat room - EaseChatFragment fragment = new EaseChatFragment.Builder(toChatUsername, 1) + EaseChatFragment fragment = new EaseChatFragment.Builder(toChatUsername, EaseChatType.SINGLE_CHAT) .useHeader(false) .setOnChatExtendMenuItemClickListener(new OnChatExtendMenuItemClickListener() { @Override diff --git a/shared/chat-sdk/get-started/get-started-uikit/project-implementation/web.mdx b/shared/chat-sdk/get-started/get-started-uikit/project-implementation/web.mdx index e8327474f..bb38a0606 100644 --- a/shared/chat-sdk/get-started/get-started-uikit/project-implementation/web.mdx +++ b/shared/chat-sdk/get-started/get-started-uikit/project-implementation/web.mdx @@ -1,9 +1,6 @@ -The Chat UI Samples for Web has two components: - -- `EaseApp`, which contains the conversation list and applies to use cases where you want to quickly launch a real-time chat app. -- `EaseChat`, which contains a conversation box and applies to most chat use cases such as sending and receiving messages, displaying the message on the UI, and managing unread messages. +The Web Chat UIKit contains the `EaseApp` component, which contains the conversation list and applies to use cases where you want to quickly launch a real-time chat app. This section introduces the steps you need to take to quickly implement one-to-one messaging with `EaseApp`. @@ -15,7 +12,7 @@ This section introduces the steps you need to take to quickly implement one-to-o // App.js import React, {Component} from 'react'; import { EaseApp } from "agora-chat-uikit" - import './App.scss'; + import './App.css'; class App extends Component { render() { diff --git a/shared/chat-sdk/get-started/get-started-uikit/project-setup/android.mdx b/shared/chat-sdk/get-started/get-started-uikit/project-setup/android.mdx index 66c42da6d..6cb7e2910 100644 --- a/shared/chat-sdk/get-started/get-started-uikit/project-setup/android.mdx +++ b/shared/chat-sdk/get-started/get-started-uikit/project-setup/android.mdx @@ -24,15 +24,15 @@ Follow the steps to create the environment necessary to add video call into your } ``` -
The way to add the Maven Central dependency can be different if you set dependencyResolutionManagement in your Android project.
+
After the project is created, Android Studio will automatically start gradle synchronization. Ensure that you proceed to the following operations only after the synchronization is successful.
b. In `/Gradle Scripts/build.gradle(Module: .app)`, add the following lines to integrate the Chat UI Samples into your Android project: ```java android { defaultConfig { - // The Android OS version should be 19 or higher. - minSdkVersion 19 + // The Android OS version should be 21 or higher. + minSdkVersion 21 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -59,6 +59,8 @@ Follow the steps to create the environment necessary to add video call into your + + ``` These are the minimum permissions you need to add to start Chat. You can also add other permissions according to your use case. diff --git a/shared/chat-sdk/reference/_chat_receive_webhook.mdx b/shared/chat-sdk/reference/_chat_receive_webhook.mdx index 86f45f492..4971537fa 100644 --- a/shared/chat-sdk/reference/_chat_receive_webhook.mdx +++ b/shared/chat-sdk/reference/_chat_receive_webhook.mdx @@ -9,11 +9,15 @@ This page introduces the events and callbacks in Agora Chat. ## User login and logout events -When a user logs in to or logs out of the Agora Chat app, the Agora Chat server sends a callback to your app server. +A user's login to or logout of the Agora Chat app will cause the user's online status to change. + +When a user logs in to or out of the Agora Chat app, the Agora Chat server sends a callback to your app server to synchronize the user's online or offline state and the reason for the status change, including `login`, `logout` and `replaced`. When receiving the callback, the app server will return a response to the Agora Chat server which deems that the user state is successfully synchronized to your app server only when the HTTP status code 200 is received. If no response is received within 60 seconds, the Agora Chat server sends the callback again. If there is still no response, the Agora Chat server no longer sends the callback, but records a callback sending failure. If a good many responses from the app server fail to be received during a short period, the Agora Chat server stops sending callbacks to your app server and you can change the callback address on the **Post Send** page in the **Add Callback Rules** dialog box under **Features > Callback** on the [Agora Console](https://console.agora.io/). + +In special network conditions, for example, a user entering a tunnel, the user's state change may be caused by the heartbeat timeout. Specifically, if a user's app remains disconnected from the Agora Chat server for five minutes, the user gets offline. ### Log in to the app -When a user logs in to the Agora Chat app, the Agora Chat server sends a callback to your app server. The sample code is as follows: +When a user logs in to the Agora Chat app, the Agora Chat server sends a callback to your app server, notifying the user's online state and the reason `login`. The sample code is as follows: ```json { @@ -34,7 +38,7 @@ When a user logs in to the Agora Chat app, the Agora Chat server sends a callbac | Field | Data Type | Description | | --- | --- | --- | | `callId` | String | The ID of the callback. The unique identifier assigned to each callback, in the format of `{appKey}_{file_uuid}`, where the value of `file_uuid` is randomly generated. | -| `reason` | String | The reason that triggers the callback. `login` indicates that a user logs in to the app. | +| `reason` | String | The reason `login` that triggers the callback. | | `security` | String | The signature in the callback request used to confirm whether this callback is sent from the Agora Chat server. The signature is the MD5 hash of the `{callId} + {secret} + {timestamp}` string, where the value of `secret` can be found on [Agora Console](https://console.agora.io/).| | `os` | String | The operating system of the device. Valid values: `ios`, `android`, `linux`, `win`, and `other.` | | `ip` | String | The IP address of the user who logs in to the app. | @@ -43,11 +47,11 @@ When a user logs in to the Agora Chat app, the Agora Chat server sends a callbac | `user` | String | The ID of the user. The unique identifier of each user in the Agora Chat app, in the format of `{appKey}/{OS}_{deviceId}`. | | `version` | String | The version of the Agora Chat SDK. | | `timestamp` | Long | The Unix timestamp when the Agora Chat server receives the login request, in milliseconds. | -| `status` | String | The current status of the user. `online` indicates that the user is online. | +| `status` | String | The current status of the user. `online` indicates that the user is online and the app is connected to the Agora Chat server. | ### Log out of the app voluntarily -When a user logs out of the Agora Chat app, the Agora Chat server sends a callback to your app server. The sample code is as follows: +When a user logs out of the Agora Chat app, the Agora Chat server sends a callback to your app server, notifying the user's offline state and the reason `logout`. The sample code is as follows: ```json { @@ -68,7 +72,7 @@ When a user logs out of the Agora Chat app, the Agora Chat server sends a callba | Field | Data Type | Description | | --- | --- | --- | | `callId` | String | The ID of the callback. The unique identifier assigned to each callback, in the format of `{appKey}_{file_uuid}`, where the value of `file_uuid` is randomly generated. | -| `reason` | String | The reason that triggers the callback. `logout` indicates that a user logs out of the app. | +| `reason` | String | The reason `logout` that triggers the callback. | | `security` | String | The signature in the callback request used to confirm whether this callback is sent from the Agora Chat server. The signature is the MD5 hash of the `{callId} + {secret} + {timestamp}` string, where the value of `secret` can be found on [Agora Console](https://console.agora.io/).| | `os` | String | The operating system of the device. Valid values: `ios`, `android`, `linux`, `win`, and `other.` | | `ip` | String | The IP address of the user who logs out of the app. | @@ -77,11 +81,11 @@ When a user logs out of the Agora Chat app, the Agora Chat server sends a callba | `user` | String | The ID of the user. The unique identifier of each user in the Agora Chat app, in the format of `{appKey}/{OS}_{deviceId}`. | | `version` | String | The version of the Agora Chat SDK. | | `timestamp` | Long | The Unix timestamp when the Agora Chat server receives the logout request, in milliseconds. | -| `status` | String | The current status of the user. `offline` indicates that the user is offline. | +| `status` | String | The current status of the user. `offline` indicates that the user is offline and the app is disconnected from the Agora Chat server. ### Log out of the app passively -When a user logs out of the Agora Chat app due to being kicked out by another device, the Agora Chat server sends a callback to your app server. The sample code is as follows: +When a user is forced by the developer to go offline on the device or due to being kicked out by another device as the maximum number of login devices is reached, the Agora Chat server sends a callback to your app server, notifying the user's offline state and the reason `replaced`. The sample code is as follows: ```json { @@ -101,7 +105,7 @@ When a user logs out of the Agora Chat app due to being kicked out by another de | Field | Data Type | Description | | --- | --- | --- | | `callId` | String | The ID of the callback. The unique identifier assigned to each callback, in the format of `{appKey}_{file_uuid}`, where the value of `file_uuid` is randomly generated. | -| `reason` | String | The reason that triggers the callback. `replaced` indicates that a user logs out of the app due to being kicked out by another device. | +| `reason` | String | The reason `replaced` that triggers the callback. | | `security` | String | The signature in the callback request used to confirm whether this callback is sent from the Agora Chat server. The signature is the MD5 hash of the `{callId} + {secret} + {timestamp}` string, where the value of `secret` can be found on [Agora Console](https://console.agora.io/).| | `os` | String | The operating system of the device. Valid values: `ios`, `android`, `linux`, `win`, and `other.` | | `ip` | String | The IP address of the user. | @@ -110,7 +114,7 @@ When a user logs out of the Agora Chat app due to being kicked out by another de | `user` | String | The ID of the user. The unique identifier of each user in the Agora Chat app, in the format of `{appKey}/{OS}_{deviceId}`. | | `version` | String | The version of the Agora Chat SDK. | | `timestamp` | Long | The Unix timestamp when the Agora Chat server receives the logout request, in milliseconds. | -| `status` | String | The current status of the user. `offline` indicates that the user is offline. | +| `status` | String | The current status of the user. `offline` indicates that the app is disconnected from the Agora Chat server and the user is offline. | ## Message events @@ -363,7 +367,7 @@ When a user sends a custom message in a one-to-one chat, chat group, or chat roo | Field | Data Type | Description | | --- | --- | --- | | `customExts/v2:customExts` | Json | The attribute of the custom event, in the `Map` format. The attribute can contain a maximum of 16 elements. | -| `customEvent`| String | The type of the custom event. The type can be 1 to 32 characters. | +| `customEvent`| String | The type of the custom event. The type can be 1 to 32 characters and must meet the following regular expression condition: [a-zA-Z0-9-_/.]{1,32}.| | `type` | String | The type of the message. `custom` indicates a custom message. | ### Recall a message @@ -980,15 +984,15 @@ When a user uploads a shared file to a chat group, the Agora Chat server sends a "payload": { "muc_id": "XXXX#XXXX173560762007553XXXX", - "reason": "{ - \"data\":{ - \"file_id\":\"79ddf840-8e2f-11ec-bec3-ad40868b03f9\", - \"file_name\":\"a.csv\", - \"file_owner\":\"@ppAdmin\", - \"file_size\":6787, - \"created\":1644909510085 - } - }", + "reason": { + "data": { + "file_id": "79ddf840-8e2f-11ec-bec3-ad40868b03f9", + "file_name": "a.csv", + "file_owner": "@ppAdmin", + "file_size": 6787, + "created": 1644909510085 + } + }, "is_chatroom": false, // "upload_file" indicates that the current operation is to upload a shared file to a chat group. "operation": "upload_file", diff --git a/shared/chat-sdk/reference/_chatroom-overview.mdx b/shared/chat-sdk/reference/_chatroom-overview.mdx index 05f5fa4d4..ccacbdb82 100644 --- a/shared/chat-sdk/reference/_chatroom-overview.mdx +++ b/shared/chat-sdk/reference/_chatroom-overview.mdx @@ -1,6 +1,6 @@ import * as data from '@site/data/variables'; -Chat rooms enable real-time messaging among multiple users. Chat rooms do not have a strict membership and members do not have any relationship with each other. Once a chat room member exits the chat room, this member does not receive any push message from the chat room, and within 5 minutes, automatically leaves the chat room. Chat rooms are widely applied in live broadcast use cases as stream chat in Twitch. +Chat rooms enable real-time messaging among multiple users and are widely applied in live broadcast use cases as stream chat in Twitch. Chat rooms do not have a strict membership, and members do not retain any permanent relationship with each other. Once going offline, chat room members cannot receive any messages from the chat room and automatically leave the chat room after 2 minutes. If you want to adjust the time, contact [support@agora.io](mailto:support@agora.io). ## Chat room roles and privileges diff --git a/shared/chat-sdk/reference/_group-overview.mdx b/shared/chat-sdk/reference/_group-overview.mdx index da87f18dd..559f38c20 100644 --- a/shared/chat-sdk/reference/_group-overview.mdx +++ b/shared/chat-sdk/reference/_group-overview.mdx @@ -27,10 +27,10 @@ The specific feature differences are listed in the following table: | Use cases | Group chat scenarios in Signal and Skype, where members have a preexisting relationship with each other. | Stream chat scenarios in Twitch, where viewers have no relationship with each other. Once a member quits the stream channel, they leave the chat room. | | Maximum number of members | 5,000 | 20,000+ | | Message push support | Members receive push messages when they go offline. | Members do not receive push messages when they go offline. | -| Message storage support | Supports message storage when a member is offline. Once online, this member receives all the stored messages. A maximum of 200 messages can be stored for each group chat thread. | This feature can be enabled and disabled. If you enable this feature, the SDK supports message storage when a member is offline. Once online, this member receives all the stored messages. By default, 10 messages can be stored for each chat room thread, and you can set you can set the maximum number to 200. | +| Offline message storage | This feature is supported. The server stores messages sent to offline group members and sends to them once they gets online. A maximum number of 200 messages can be stored for each group conversation. | This feature is disabled for chat rooms by default. To enable it, contact support@agora.io. After this feature is enabled, when a user joins a chat room, the server sends the latest 10 historical messages to the client side via the message receiving callback. The number of historical messages sent to the new chat room member can be increased up to 200. | +| Historical message storage | This feature is disabled for chat rooms by default. To enable it, contact support@agora.io. After this feature is enabled, when a user joins a chat room, the server sends the latest 10 historical messages to the client side via the message receiving callback. The number of historical messages sent to the new chat room member can be increased up to 200. | This feature is not supported for chat rooms. | | Message reliability | All members receive all the messages in the chat group. | Members might not see all messages. The SDK discards messages if the chat group message threshold is exceeded. The default threshold is 100 messages per second. You can adjust this threshold according to your needs. | - ## Chat group features The Chat SDK supports creating and managing chat groups, managing group members, and modifying group attributes. diff --git a/shared/chat-sdk/reference/_http-status-codes.mdx b/shared/chat-sdk/reference/_http-status-codes.mdx index 13597426d..9c8d9131b 100644 --- a/shared/chat-sdk/reference/_http-status-codes.mdx +++ b/shared/chat-sdk/reference/_http-status-codes.mdx @@ -46,10 +46,10 @@ This status code indicates that the authentication process could not be implemen | Status code | Error code | Error message | Description | | :----- | :------------ | :----------------------------------------------------------- | :------------------------------------------------| -| `401` | `unauthorized` | "Registration is not open, please contact the app admin." | The error message returned because the app token is not included in the request header when registering users. | -| `401` | `unauthorized` | "Unable to authenticate due to expired access token." | The error message returned because the token has expired. | -| `401` | `auth_bad_access_token` | "Unable to authenticate due to corrupt access token." | The error message returned because the token format is invalid. | -| `401` | `auth_bad_access_token` | "Unable to authenticate." | The error message returned because the token is not generated by the server that receives the request, and as a consequence the server cannot recognize the token. | +| `401` | `unauthorized` | "Registration is not open, please contact the app admin." |The error message returned because you pass in an incorrect app token or do not pass in an app token when you call the API of [registering a user](../restful-api/user-system-registration#registering-a-user) or [registering multiple users](../restful-api/user-system-registration#registering-multiple-users). For example, you pass in an app token that has already expired or is in incorrect format. | +| `401` | `unauthorized` | "Unable to authenticate due to expired access token." | This error message is returned because you pass in an expired app token or do not pass in an app token when you call any other RESTful API than the API of registering a user or registering multiple users. | +| `401` | `auth_bad_access_token` | "Unable to authenticate due to corrupt access token." | The error message returned because you pass in an app token that is in invalid format when you call any other RESTful API than the API of registering a user or registering multiple users. | +| `401` | `auth_bad_access_token` | "Unable to authenticate." | The error message returned because the server cannot recognize your app token that is in the correct format, but is not generated by the server that receives the request. This error occurs when you call any other RESTful API than the API of registering a user or registering multiple users. | ### 403 Forbidden This status code indicates that the API request is rejected by the server due to forbidden operations. @@ -63,6 +63,9 @@ This status code indicates that the API request is rejected by the server due to | `403` | `forbidden_op` | "Forbidden operation on group owner!" | The error message returned because the specified operation cannot be performed on chat group owners, such as adding the chat group owner to block list. | | `403` | `forbidden_op` | "Can not join this group, reason:user: `{username}` has joined too many groups/chatroom!" | The error message returned because the number of chat groups or chat rooms joined by a user has reached the limit. | | `403` | `forbidden_op` | "This appKey has create too many groups/chatrooms!" | The number of chat groups or chat rooms created by using an App key has reached the limit. For details, see [Pricing plans](../reference/pricing-plan-details). | +| `403` | `exceed_limit` | "Invitee's contact max count" | The user receiving the friend request has reached the maximum number of contacts allowed.| +| `403` | `exceed_limit` | "Inviter's contact max count" | The user sending the friend request has reached the maximum number of contacts allowed. | + ### 404 Not Found This status code indicates that the specified resources of the API request could not be found by the server. diff --git a/shared/chat-sdk/reference/_ip_allowlist.mdx b/shared/chat-sdk/reference/_ip_allowlist.mdx new file mode 100644 index 000000000..05ab35ed5 --- /dev/null +++ b/shared/chat-sdk/reference/_ip_allowlist.mdx @@ -0,0 +1,47 @@ +import * as data from '@site/data/variables'; + +For the communication between end users behind enterprise firewalls, Agora Chat allows all communications to always use TCP/TLS 443 with TLS headers. Agora Chat supports the IP allowlist function. If you have a strict security policy for end users and allow only certain absolute domain names or specified IP addresses/port ranges to communicate through TCP/TLS 443, you can add the allowed IP addresses or domain names to the IP allowlist. To ensure smooth communication via Agora Chat, you must add the IP addresses and ports of data centers of Agora Chat to the firewall allowlist. + +### Add IP addresses and ports of data centers of Agora Chat to the firewall allowlist + +1. Prepare the development environment. See [SDK quickstart](../get-started/get-started-sdk) for your platform. + +1. Add the IP addresses and ports of Agora Chat access points to the firewall allowlist. + +1. Test message sending and receiving in the development environment. + +### List of domain names of Agora Chat data centers + +For each Agora Chat data center, for example, Singapore, virginia US, or Frankfurt Germany, Agora Chat provides fully qualified domain names for the access points. + +Agora fully controls the servers and the traffic on the IP addresses of the access points. The IP addresses are subject to change and any changes will be announced with a minimum of a 3-month notice to you, ensuring that you have enough time to update their firewalls to trust these IP addresses. + +**virginia, US** + +| Domain Name | IP Address | Port | Platform | +| :---------- | :------- | :----- | :------------- | +|[msync-api-41.chat.agora.io](http://msync-api-41.chat.agora.io/)|
  • 3.33.220.151
  • 15.197.222.199
| 443 | Client SDKs (excluding SDK for Web) | +|[msync-im-41-tls.chat.agora.io](http://msync-im-41-tls.chat.agora.io/)|
  • 52.223.55.237
  • 35.71.161.179
| 443 | Client SDKs (excluding SDK for Web) | +|[a41.chat.agora.io](http://a41.chat.agora.io/)|
  • 99.83.189.183,
  • 75.2.75.207
| 443 | RESTful API| +|ap-america.agora.io|
  • 106.14.12.130
  • 47.107.39.93
  • 118.190.148.38
  • 112.126.96.46
  • 52.58.56.244
  • 35.178.208.187
  • 52.52.84.170
  • 50.17.126.121
  • 3.0.163.78
  • 52.194.158.59
  • 54.65.86.72
  • 13.127.149.196
  • 15.206.47.129
  • 123.56.235.221
  • 101.132.108.165
  • 52.28.239.238
  • 3.9.120.239
  • 52.54.85.111
  • 184.72.18.217
  • 13.250.89.184
  • 18.176.162.64
|
  • UDP port: 8443, 5888-5889, 4000-4100 and 8130
  • UDP port: 443 and 8443
| Client SDKs (excluding SDK for Web) | + +**Singapore** + +| Domain Name | IP Address | Port | Platform | +| :---------- | :------- | :----- | :------------- | +|[msync-api-61.chat.agora.io](http://msync-api-61.chat.agora.io/)|
  • 35.71.135.178,
  • 52.223.50.200
| 443 | Client SDKs (excluding SDK for Web) | +|[msync-im-61-tls.chat.agora.io](http://msync-im-61-tls.chat.agora.io/)|
  • 35.71.183.128,
  • 52.223.36.218
| 443 | Client SDKs (excluding SDK for Web) | +|[a61.chat.agora.io](http://a61.chat.agora.io/)|
  • 52.223.32.250,
  • 35.71.139.186
| 443 | RESTful API| +|ap-asia.agora.io|
  • 106.14.12.130
  • 47.107.39.93
  • 118.190.148.38
  • 112.126.96.46
  • 52.58.56.244
  • 35.178.208.187
  • 52.52.84.170
  • 50.17.126.121
  • 3.0.163.78
  • 52.194.158.59
  • 54.65.86.72
  • 13.127.149.196
  • 15.206.47.129
  • 123.56.235.221
  • 101.132.108.165
  • 52.28.239.238
  • 3.9.120.239
  • 52.54.85.111
  • 184.72.18.217
  • 13.250.89.184
  • 18.176.162.64
|
  • UDP port: 8443、5888-5889, 4000-4100 and 8130
  • TCP port: 443 and 8443
| Client SDKs (excluding excluding SDK for Web) | + +**Frankfurt Germany** + +| Domain Name | IP Address | Port | Platform | +| :---------- | :------- | :----- | :------------- | +|[msync-api-71.chat.agora.io](http://msync-api-71.chat.agora.io/)|
  • 75.2.86.219,
  • 99.83.214.138
| 443 | Client SDKs (excluding SDK for Web)| +|[msync-im-71-tls.chat.agora.io](http://msync-im-71-tls.chat.agora.io/)|
  • 75.2.56.250,
  • 99.83.180.145
|443| Client SDKs (excluding SDK for Web) | +|[a71.chat.agora.io](http://a71.chat.agora.io/)|
  • 3.33.221.135,
  • 15.197.253.209
| 443 |RESTful API| +|ap-europe.agora.io|
  • 106.14.12.130
  • 47.107.39.93
  • 118.190.148.38
  • 112.126.96.46
  • 52.58.56.244
  • 35.178.208.187
  • 52.52.84.170
  • 50.17.126.121
  • 3.0.163.78
  • 52.194.158.59
  • 54.65.86.72
  • 13.127.149.196
  • 15.206.47.129
  • 123.56.235.221
  • 101.132.108.165
  • 52.28.239.238
  • 3.9.120.239
  • 52.54.85.111
  • 184.72.18.217
  • 13.250.89.184
  • 18.176.162.64
|
  • UDP port: 8443、5888-5889, 4000-4100 and 8130
  • TCP port: 443 and 8443
| Client SDKs (excluding SDK for Web)| + + + diff --git a/shared/chat-sdk/reference/_message-overview.mdx b/shared/chat-sdk/reference/_message-overview.mdx index 051dde630..60aa0c583 100644 --- a/shared/chat-sdk/reference/_message-overview.mdx +++ b/shared/chat-sdk/reference/_message-overview.mdx @@ -97,6 +97,16 @@ Apart from the local device, you can also retrieve conversations from the server The Chat SDK stores historical messages in the chat server, and you can retrieve historical messages in each conversation from the server with pagination. The time duration for storing historical messages varies according to your pricing plan. See [Limitations of message storage duration](#limitations). +### Message resending mechanism + +- For Android and iOS, the message resending mechanism is as follows: + +After the client calls the method of sending a message, it will wait for the server to return a response. The response timeout period is 10 seconds. If the sending fails due to a response timeout, the client will try to send the message again by reconnecting to the server through a persistent connection to send the message. If the sending fails again, the SDK considers the sending of the message failed, and returns error code 300 and the error message `SERVER_NOT_REACHABLE`, indicating that the server is unreachable. + +- For Web, the message resending mechanism is as follows: + +When sending a message, if the WebSocket is disconnected and is reconnecting to the server, the message will be resent after reconnection; if the WebSocket is disconnected during message sending, the SDK will display error code 510 and the error message `MESSAGE_WEBSOCKET_DISCONNECTED `, indicating that the network disconnection caused the message sending failure. + ### Message delivery receipt The SDK supports sending a message delivery receipt when the message is successfully sent. diff --git a/shared/chat-sdk/reference/error-codes/android.mdx b/shared/chat-sdk/reference/error-codes/android.mdx index 7cbbe634d..117f25f05 100644 --- a/shared/chat-sdk/reference/error-codes/android.mdx +++ b/shared/chat-sdk/reference/error-codes/android.mdx @@ -11,10 +11,15 @@ The error codes and error messages might be returned in the following ways: | 1 | `GENERAL_ERROR` | The SDK has not been successfully initialized, or the specified reason for the error is not identified when you request the server. You can try reinitializing the SDK. | | 2 | `NETWORK_ERROR` | Disconnections between the SDK and the server happen due to the network problems. | | 4 | `EXCEED_SERVICE_LIMIT` |The service limit is exceeded, for example, the total number of the registered users or their friends exceeds the plan limit. | +| 8 | `APP_ACTIVE_NUMBER_REACH_LIMITATION` | The number of daily active users (DAU) or monthly active users (MAU) of the app has reached the upper limit. | | 100 | `INVALID_APP_KEY` | The App Key is invalid. Log in again using a valid App Key. | | 101 | `INVALID_USER_NAME` | The user ID is empty, or the format of the parameter is incorrect. Use a [valid user ID](/agora-chat/restful-api/user-system-registration). | | 102 | `INVALID_PASSWORD` | The password entered to log in is empty or incorrect. Log in again using the correct password. | | 104 | `INVALID_TOKEN` | The token entered to log in is empty or incorrect. Log in again using the correct token. | +| 105 | `USER_NAME_TOO_LONG` | The user ID is too long. The user ID cannot exceed 64 bytes. | +| 108 | `TOKEN_EXPIRED` | The Agora Chat token has expired. | +| 109 | `TOKEN_WILL_EXPIRE` | The Agora Chat token will expire. This error is triggered from when half of the token validity period passed. | +| 110 | `INVALID_PARAM` | Invalid parameter. | | 200 | `USER_ALREADY_LOGIN` | The user has already logged in. Do not log in repeatedly. | | 201 | `USER_NOT_LOGIN` | The user has not logged in when the method is called. Please check the your code logic. | | 202 | `USER_AUTHENTICATION_FAILED` | The user authentication fails. Check whether the token has expired. | @@ -31,7 +36,9 @@ The error codes and error messages might be returned in the following ways: | 215 | `USER_MUTED` | If the user is muted in the group or the chatroom, when the user sends a message, the SDK returns this error code. | | 216 | `USER_KICKED_BY_CHANGE_PASSWORD` | If the logged in user changes the present password, the SDK kicks the user out and returns this error code. | | 217 | `USER_KICKED_BY_OTHER_DEVICE` | When the multi-device login function is enabled, if the user forces the user ID logged in at the current device to log out by calling APIs or managing the backend at another device, the SDK returns this error code. | -| 221 | `USER_NOT_FRIEND` | When a peer user sets not to receive messages from a user that is not a contact, if you send a message to this peer user, the SDK reports this error code. You can enable this service on Agora Console. | +| 218 | `USER_ALREADY_LOGIN_ANOTHER` | If the user logs in to the device with another account before logging out of the device with the current account, the SDK returns the error code, indicating that an account is already logged in. | +| 219 | `USER_MUTED_BY_ADMIN` | The user is muted by the admin. | +| 220 | `USER_DEVICE_CHANGED` | The login device of the user is different from the last one and you need to log in again. This error occurs in the following scenario: During single-device auto-login, you have turned on the switch of allowing you to log in to another device without forcing you to log out of the current device. | | 300 | `SERVER_NOT_REACHABLE` | The SDK disconnects from the Chat system due to network problems. Try again later. | | 301 | `SERVER_TIMEOUT` | Some API calls require the SDK to return the execution result. This error occurs if the SDK takes too long (more than 30 seconds) to return the result. | | 302 | `SERVER_BUSY` | The server is currently busy. Try again later. | @@ -45,11 +52,14 @@ The error codes and error messages might be returned in the following ways: | 404 | `FILE_DELETE_FAILED` | When getting the log file, the SDK deletes the old log file. If the old log files cannot be deleted, the SDK returns this error code. | | 405 | `FILE_TOO_LARGE` | When the size of the message attachment or the group shared file exceeds the limit, the SDK returns this error code. Adjust the file size, and try uploading again. | | 500 | `MESSAGE_INVALID` | The content of the message to be sent is empty, the message ID is empty, or the user ID of the sender is not the user ID that is currently logged in. Check the problems, and try sending the message again. | +| 501 | `MESSAGE_INCLUDE_ILLEGAL_CONTENT` | The message contains inappropriate content. This error is returned when a message is found by the filtering system to contain inappropriate content. | | 502 | `MESSAGE_SEND_TRAFFIC_LIMIT` | The message-sending frequency is too high or the message size is too large. Agora recommends reducing the sending frequency or the message size. | | 504 | `MESSAGE_RECALL_TIME_LIMIT` | When a timeout occurs during message recall, the SDK returns this error code. | | 505 | `SERVICE_NOT_ENABLED` | When you try using a service that is not enabled, the SDK returns this error code. | | 506 | `MESSAGE_EXPIRED` | If you send a group receipt after the time limit (the default is three days), the SDK returns this error code. | | 507 | `MESSAGE_ILLEGAL_WHITELIST` | If all members are banned in the group or chat room and the user ID is not included in the allow list, when this user tries sending a message, the SDK returns this error code. | +| 508 | `MESSAGE_EXTERNAL_LOGIC_BLOCKED` | For the pre-sending-callback, the message is blocked as specified in a rule on your own server. | +| 510 | `MESSAGE_SIZE_LIMIT` | The size of the message that you send has exceeded the upper limit. | | 600 | `GROUP_INVALID_ID` | When you call the methods related to the group and the group ID provided is invalid, the SDK returns this error code. | | 601 | `GROUP_ALREADY_JOINED` | When you call the group joining method, if the user has already joined the group, the SDK returns this error code. | | 602 | `GROUP_NOT_JOINED` | When you try sending messages or controlling a group that you have not joined, the SDK returns this error code. | @@ -71,10 +81,13 @@ The error codes and error messages might be returned in the following ways: | 1001 | `CONTACT_REACH_LIMIT` | You cannot add a contact because the number of your contacts has reached the limit. | | 1002 | `CONTACT_REACH_LIMIT_PEER` | You cannot add a contact because the number of peer contacts has reached the limit. | | 1100 | `PRESENCE_PARAM_LENGTH_EXCEED` | The length of the parameters you pass in when calling APIs of the presence service exceed the limit. | +| 1101 | `PRESENCE_CANNOT_SUBSCRIBE_YOURSELF` | You cannot subscribe to your own presence state. | | 1110 | `TRANSLATE_PARAM_INVALID` | The parameters you pass in when calling APIs of the translation service are invalid. | | 1111 | `TRANSLATE_SERVICE_NOT_ENABLE` | The translation service has not been activated. | | 1112 | `TRANSLATE_USAGE_LIMIT` | The usage of the translation service exceeds the limit. | | 1113 | `TRANSLATE_MESSAGE_FAIL` | The request to retrieve the translation service fails. | +| 1200 | `MODERATION_FAILED` | The moderation result of the third-party moderation service is `Rejected`. | +| 1299 | `THIRD_SERVER_FAILED` | The moderation result of another service than the third-party moderation service is `Rejected`. | | 1200 | `MODERATION_FAILED` | The third-party content moderation service of Chat rates the message as "Reject". | | 1299 | `THIRD_SERVER_FAILED` | Another service rather than the third-party content moderation service of Chat rates the message as "Reject". | | 1300 | `REACTION_REACH_LIMIT` | The number of reactions exceeds the limit. | diff --git a/shared/chat-sdk/reference/error-codes/ios.mdx b/shared/chat-sdk/reference/error-codes/ios.mdx index ff68ba1a9..3ea48d9dc 100644 --- a/shared/chat-sdk/reference/error-codes/ios.mdx +++ b/shared/chat-sdk/reference/error-codes/ios.mdx @@ -8,10 +8,12 @@ During the run time of the Chat SDK, if the method call succeeds, the SDK return | 2 | `AgoraChatErrorNetworkUnavailable` | Disconnections between the SDK and the server happen due to the network problems. | | 3 | `AgoraChatErrorDatabaseOperationFailed` | Fails to open local database. Please contact Agora technical support. | | 4 | `AgoraChatErrorExceedServiceLimit` | The service limit is exceeded, for example: the total number of registered users or their friends exceeds the plan limit described in [Package plan](../reference/pricing-plan-details). | +| 8 | `AgoraChatAppActiveNumbersReachLimitation` | The number of daily active users (DAU) or monthly active users (MAU) of the app has reached the upper limit. | | 100 | `AgoraChatErrorInvalidAppkey` | The App Key is invalid. Log in again using a valid App Key. For how to get the App Key, see [Get the information of the Chat project](/agora-chat/get-started/enable#get-the-information-of-the-agora-chat-project). | | 101 | `AgoraChatErrorInvalidUsername` | The user ID is empty, or the format of the parameter is incorrect. Use a valid user ID. | | 102 | `AgoraChatErrorInvalidPassword` | The password entered to log in is empty or incorrect. Log in again using the correct password. | -| 104 | `AgoraChatErrorUsernameTooLong` | The user ID is too long. Log in again with a valid user ID. | +| 104 | `AgoraChatErrorErrorInvalidToken` | The user token is empty or incorrect. | +| 105 | `AgoraChatErrorUsernameTooLong` | The user ID is too long. Log in again with a valid user ID. | | 200 | `AgoraChatErrorUserAlreadyLoginSame` | This user is already logged in. Do not log in repeatedly. | | 201 | `AgoraChatErrorUserNotLogin` | The user is not logged in when the method is called. Please check your code logic. | | 202 | `AgoraChatErrorUserAuthenticationFailed` | The user authentication fails. Check whether the token has expired. | @@ -28,7 +30,9 @@ During the run time of the Chat SDK, if the method call succeeds, the SDK return | 215 | `AgoraChatErrorUserMuted` | If the user is muted in the group or the chatroom, when the user sends a message, the SDK returns this error code. | | 216 | `AgoraChatErrorUserKickedByChangePassword` | If the logged in user changes the present password, the SDK kicks the user out and returns this error code. Try logging in again with the new password. | | 217 | `AgoraChatErrorUserKickedByOtherDevice` | When the multi-device login function is enabled, if the user forces the user ID logged in at the current device to log out by calling APIs or managing the backend at another device, the SDK returns this error code. | -| 221 | `AgoraChatErrorUserNotOnRoster` | When a peer user sets not to receive messages from a user that is not a contact, if you send a message to this peer user, the SDK reports this error code. You can enable this feature on Agora Console. | +| 218 | `AgoraChatErrorUserAlreadyLoginAnother` | When the multi-device login function is enabled, if the user forces the user ID logged in at the current device to log out by calling APIs or managing the backend at another device, the SDK returns this error code. | +| 219 | `AgoraChatErrorUserMutedByAdmin` | You are muted by the admin. Please contact the admin to unmute you. | +| 221 | `AgoraChatErrorUserNotOnRoster` | When a peer user sets not to receive messages from a user that is not a contact, if you send a message to this peer user, the SDK reports this error code. You can enable this feature on Agora Console. | | 300 | `AgoraChatErrorServerNotReachable` | The SDK disconnects from the Chat system due to network problems. Try again later. | | 301 | `AgoraChatErrorServerTimeout` |Some API calls require the SDK to return the execution result. This error occurs if the SDK takes too long (more than 30 seconds) to return the result. | | 302 | `AgoraChatErrorServerBusy` |The server is currently busy. Try again later. | @@ -49,6 +53,7 @@ During the run time of the Chat SDK, if the method call succeeds, the SDK return | 506 | `AgoraChatErrorMessageExpired` | If you send a group receipt after the time limit (the default is three days), the SDK returns this error code. | | 507 | `AgoraChatErrorMessageIllegalWhiteList` | If all members are banned in the group or chat room and the user ID is not included in the allow list, when this user tries sending a message, the SDK returns this error code. | | 508 | `AgoraChatErrorMessageExternalLogicBlocked` |The sent message is intercepted by the user-defined pre-send callback rule. Check your settings of the pre-send callback rule. | +| 510 | `AgoraChatErrorMessageSizeLimit` | The size of the message that you send has exceeded the upper limit. | | 600 | `AgoraChatErrorGroupInvalidId` | When you call the methods related to the group and the group ID provided is invalid, the SDK returns this error code. | | 601 | `AgoraChatErrorGroupAlreadyJoined` | When you call the group joining method, if the user has already joined the group, the SDK returns this error code. | | 602 | `AgoraChatErrorGroupNotJoined` | When you try sending messages or controlling a group that you have not joined, the SDK returns this error code. | @@ -71,11 +76,14 @@ During the run time of the Chat SDK, if the method call succeeds, the SDK return | 1001 | `AgoraChatErrorContactReachLimit` | You cannot add a contact because the number of your contacts has reached the limit. | | 1002 | `AgoraChatErrorContactReachLimitPeer` | You cannot add a contact because the number of the peer contacts has reached the limit. | | 1100 | `AgoraChatErrorPresenceParamExceed` | The length of the parameters you are attempting to pass in when calling APIs of the presence service exceed the limit. | +| 1101 | `AgoraChatErrorPresenceCannotSubscribeSelf` | You cannot subscribe to the presence state of yourself. | | 1101 | `AgoraChatErrorPresenceCannotSubscribeSelf` | You cannot subscribe to the presence status of yourself.| | 1110 | `AgoraChatErrorTranslateParamError` | The parameters you are attempting to pass in when calling APIs of the translation service are invalid. | | 1111 | `AgoraChatErrorTranslateServiceNotEnabled` | The translation service has not been activated. | | 1112 | `AgoraChatErrorTranslateUsageLimit` | The usage of the translation service exceeds the limit. | | 1113 | `AgoraChatErrorTranslateServiceFail` | The request to retrieve the translation service fails. | +| 1200 | `AgoraChatErrorModerationFailed` | The content moderation result of the third-party moderation service is `Rejected`. | +| 1299 | `AgoraChatErrorThirdServiceFailed` | The content moderation result of another moderation service than the third-party service is `Rejected`. | | 1200 | `AgoraChatErrorModerationFailed` | The third-party content moderation service of Chat rates the message as "Reject". | | 1299 | `AgoraChatErrorThirdServiceFailed` | Another service rather than the third-party content moderation service of Chat rates the message as "Reject". | | 1300 | `AgoraChatErrorReactionReachLimit` | The number of reactions exceeds the limit. | diff --git a/shared/chat-sdk/reference/error-codes/web.mdx b/shared/chat-sdk/reference/error-codes/web.mdx index ab251c62a..2b80a766b 100644 --- a/shared/chat-sdk/reference/error-codes/web.mdx +++ b/shared/chat-sdk/reference/error-codes/web.mdx @@ -12,7 +12,7 @@ During the run time of the Chat SDK, the error codes and error messages might be | -2 | `REQUEST_UNKNOWN` | An unidentified error occurs. | | -3 | `REQUEST_PARAMETER_ERROR` | The request parameters are invalid. | | -4 | `REQUEST_ABORT` | The request is aborted. | -| 1 | `WEBIM_CONNCTION_OPEN_ERROR` | The request to retrieve a token fails. | +| 1 | `WEBIM_CONNCTION_OPEN_ERROR` | The request to retrieve a token fails or the token is invalid. | | 2 | `WEBIM_CONNCTION_AUTH_ERROR` | The SDK fails to verify the App Key. Try logging in again with a valid App Key. | | 12 | `WEBIM_CONNCTION_GETROSTER_ERROR` | Fails to generate the token. | | 16 | `WEBIM_CONNCTION_DISCONNECTED` | The WebSocket is disconnected due to network reasons. Try calling the method again. | @@ -23,7 +23,7 @@ During the run time of the Chat SDK, the error codes and error messages might be | 32 | `WEBIM_CONNCTION_CLIENT_OFFLINE` | If a user is not logged in or drops offline, when the user sends a message, the SDK returns this error. Log in and try sending the message. | | 39 | `WEBIM_CONNECTION_CLOSED` | If a user is not logged in, or logged out, when the user sends a message, the SDK returns this error, Log in again and try sending the message. | | 40 | `WEBIM_CONNECTION_ERROR` | The user authentication fails. | -| 50 | `MAX_LIMIT` | The number of reactions or the usage of translations has reached the limit. | +| 50 | `MAX_LIMIT` | The number of reactions or the usage of translations has reached the upper limit. Alternatively, the number of daily active users (DAU), the number of active users, or the number of monthly active users has reached the upper limit. | | 51 | `MESSAGE_NOT_FOUND` | The message to be reported does not exist. | | 52 | `NO_PERMISSION` | The user has no permission to perform this operation. | | 53 | `OPERATION_UNSUPPORTED` | The current operation is not supported. | diff --git a/shared/chat-sdk/restful-api/_contact-management.mdx b/shared/chat-sdk/restful-api/_contact-management.mdx index cc8edce48..9dc91c699 100644 --- a/shared/chat-sdk/restful-api/_contact-management.mdx +++ b/shared/chat-sdk/restful-api/_contact-management.mdx @@ -97,7 +97,7 @@ curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' - ```json { "path": "/users/4759aa70-XXXX-XXXX-925f-6fa0510823ba/contacts", - "uri": "https://XXXX/XXXX/XXXX/users/4759aa70-eba5-11e8-925f-6fa0510823ba/contacts", + "uri": "https://XXXX/XXXX/XXXX/users/4759aa70-XXXX-XXXX-925f-6fa0510823ba/contacts", "timestamp": 1542598913819, "organization": "XXXX", "application": "8be024f0-XXXX-XXXX-b697-5d598d5f8402", @@ -166,7 +166,7 @@ curl -X DELETE -H 'Accept: application/json' -H 'Authorization: Bearer {YourAppT ```json { "path": "/users/4759aa70-XXXX-XXXX-925f-6fa0510823ba/contacts", - "uri": "https://XXXX/XXXX/XXXX/users/4759aa70-eba5-11e8-925f-6fa0510823ba/contacts", + "uri": "https://XXXX/XXXX/XXXX/users/4759aa70-XXXX-XXXX-925f-6fa0510823ba/contacts", "timestamp": 1542599266616, "organization": "XXXX", "application": "8be024f0-XXXX-XXXX-b697-5d598d5f8402", @@ -243,7 +243,7 @@ curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer {YourAppToke "uri": "http://XXXX/XXXX/XXXX/users/user1/contacts/users", "timestamp": 1543819826513, "entities": [], - "count": 2 + "count": 2, "action": "get", "data": [ "user3", @@ -283,7 +283,7 @@ The request body is a JSON object, which contains the following fields: | Field | Type | Description | Required | | :-------- | :--------- | :------------------------------------------------ | :------- | -| `usernames` | An array of usernames | The usernames to be added to the block list, such as ["user1", "user2"]. | Yes | +| `usernames` | An array of usernames | The usernames to be added to the block list, such as ["user1", "user2"]. You can pass in a maximum of 50 user IDs each time. | Yes | ### HTTP response @@ -304,7 +304,7 @@ If the returned HTTP status code is not 200, the request fails. You can refer to #### Request example ```shell -curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer {YourAppToken}' -d '{ "usernames": [ "user2" ] }' 'http://XXXX/XXXX/XXXX/users/user1/blocks/users' +curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer ' -d '{ "usernames": [ "user2" ] }' 'http://XXXX/XXXX/XXXX/users/user1/blocks/users' ``` #### Response example @@ -442,7 +442,7 @@ curl -X DELETE -H 'Accept: application/json' -H 'Authorization: Bearer {YourAppT ```json { "path": "/users/4759aa70-XXXX-XXXX-925f-6fa0510823ba/blocks", - "uri": "https://XXXX/XXXX/XXXX/users/4759aa70-eba5-11e8-925f-6fa0510823ba/blocks", + "uri": "https://XXXX/XXXX/XXXX/users/4759aa70-XXXX-XXXX-925f-6fa0510823ba/blocks", "timestamp": 1542600712985, "organization": "XXXX", "application": "8be024f0-XXXX-XXXX-b697-5d598d5f8402", diff --git a/shared/chat-sdk/restful-api/_global-mute.mdx b/shared/chat-sdk/restful-api/_global-mute.mdx index 01280ebf4..1853adeb3 100644 --- a/shared/chat-sdk/restful-api/_global-mute.mdx +++ b/shared/chat-sdk/restful-api/_global-mute.mdx @@ -54,7 +54,7 @@ POST https://{host}/{orgName}/{appName}/mutes #### Path parameter -For parameters and the detailed descriptions, see [Commom parameters](#param). +For parameters and the detailed descriptions, see [Common parameters](#param). #### Request parameter @@ -136,7 +136,7 @@ GET https://{host}/{orgName}/{appName}/mutes/{username} | --- | --- | --- | --- | | `username` | String | Yes | The user ID whose global-mute settings you want to query. | -For other parameters and the detailed descriptions, see [Commom parameters](#param). +For other parameters and the detailed descriptions, see [Common parameters](#param). #### Request header @@ -207,7 +207,7 @@ GET https://{host}/{orgName}/{appName}/mutes #### Path parameter -For parameters and the detailed descriptions, see [Commom parameters](#param). +For parameters and the detailed descriptions, see [Common parameters](#param). #### Request header @@ -216,12 +216,12 @@ For parameters and the detailed descriptions, see [Commom parameters](#param). | `Content-Type` | String | The content type. Set is as `application/json`. | | `Authorization` | String | The authentication token of the user or admin, in the format of `Bearer ${YourAppToken}`, where `Bearer` is a fixed character, followed by an English space, and then the obtained token value. | -#### Request body +#### Query parameter | Parameter | Type | Required | Description | | --- | --- | --- | --- | -| `pageNum` | Number | Yes | The number of page for querying the globally muted users in the app. | -| `pageSize` | Number | Yes | The number of data entries on each page. | +| `pageNum` | Number | No | The number of pages for querying the globally muted users in the app. | +| `pageSize` | Number | No | The number of data entries on each page. The value range is [1,50]. | ### HTTP response diff --git a/shared/chat-sdk/restful-api/_message-management.mdx b/shared/chat-sdk/restful-api/_message-management.mdx index 6430a7114..998aa90b3 100644 --- a/shared/chat-sdk/restful-api/_message-management.mdx +++ b/shared/chat-sdk/restful-api/_message-management.mdx @@ -93,7 +93,8 @@ The request body is a JSON object, which contains the following parameters: | `body` | JSON | The message content. For different message types, this parameter contains different fields. For details, see [Body of different message types](#body). | Yes | | `sync_device` | Bool | Whether to synchronize the message to the message sender.
  • `true`: Yes.
  • `false`: No.
| No | | `routetype` | String | The route type when the message is not online.
  • To send the message only when the user is online, set this parameter as `ROUTE_TYPE`.
  • To send the message regardless of whether the user is online or not, do not set this parameter.
| No | -| `ext` | JSON | The extension filed of the message. | No | +| `ext` | JSON | The extension field of the message. It cannot be `null`.| No | +| `ext.em_ignore_notification` | Whether to send a silent message:
  • `true`: Yes;
  • (Default)`false`: No.
Sending silent messages means that when the user is offline, Agora Chat will not push message notifications to the user's device through a third-party message push service. Therefore, users will not receive push notifications for messages. When the user goes online again, all messages sent from the offline period will be received. Unlike the Do Not Disturb mode which is set by the recipient to prevent notifications during a certain period, sending silent messages is set by the sender.| Boolean | @@ -187,15 +188,14 @@ If the returned HTTP status code is not `200`, the request fails. You can refer ```shell # Replace {YourToken} with the app token generated on your server - curl -X POST -i 'http://XXXX/XXXX/XXXX/messages/users' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer {YourToken}' -d '{"from": "user1","to": ["user2"],"type": "txt","body": {"msg": "testmessages"}}' + curl -X POST -i 'http://XXXX/XXXX/XXXX/messages/users' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer {YourToken}' -d '{"from": "user1","to": ["user2"],"type": "txt","body": {"msg": "testmessages"},"ext": {"em_ignore_notification": true}}' ``` - Send a text message to the online user while synchronizing the message with the sender ```shell # Replace {YourToken} with the app token generated on your server - curl -X POST -i 'http://XXXX/XXXX/XXXX/messages/users' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer {YourToken}' -d '{"from": "user1","to": ["user2"],"type": "txt","body": {"msg": "testmessages"},"routetype":"ROUTE_ONLINE", "sync_device":true}' - ``` + curl -X POST -i 'http://XXXX/XXXX/XXXX/messages/users' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer {YourToken}' -d '{"from": "user1","to": ["user2"],"type": "txt","body": {"msg": "testmessages"},"ext": {"em_ignore_notification": true},"routetype":"ROUTE_ONLINE", "sync_device":true}' ``` - Send an image message @@ -1118,10 +1118,10 @@ curl -X GET -H 'Accept: application/octet-stream' -H 'Authorization: Bearer {You This method retrieves historical messages sent and received by the user. - For each request, you can retrieve all the historical messages sent and received within one hour from the specified time. -- There is a certain delay when querying historical message records, which cannot be obtained in real time. +- Messages cannot be retrieved in real time. For example, at 9 a.m., you can retrieve messages that are sent or received at 8 a.m. - The default storage time of historical messages differs by plan version. For details, see [package details](/agora-chat/reference/pricing-plan-details). -For each App Key, the call frequency limit of this method is 100 per second. +For each App Key, the call frequency limit of this method is 10 per minute. ### HTTP request @@ -1469,9 +1469,9 @@ For the parameters and detailed descriptions, see [Common parameters](#param). | :---------- | :------- | :------- | :----------------------------------------------------------- | | `msg_id` | String | Yes | The ID of the recalled message. | | `to` | String | No | The user, chat group, or chat room that receives the recalled message. You can specify a username, a chat group ID, or a chat room ID.
**Note**: If the recalled message exceeds the message storage duration and no longer exists in the server, this message cannot be recalled on the server side. You can only recall the message on the receiver client instead. | -| `chat_type` | String | Yes | The type of the chat where the recalled message is located.
  • `chat`: A one-on-one chat.
  • `group_chat`: A chat group.
  • `chatroom`: A chat room.
| +| `chat_type` | String | Yes | The type of the chat where the recalled message is located.
  • `chat`: An one-on-one chat.
  • `groupchat`: A chat group.
  • `chatroom`: A chat room.
| | `from` | String | No | The user who recalls the message. By default, the recaller is the app admin. You can also specify another user as the recaller. | -| `force` | bool | Yes | Whether to force a recall if the recalled message exceeds the message storage duration and no longer exists in the server.
  • `true`: Force the recall on the client that receives the message.
  • `false`: The recall fails.
The maximum message storage duration varies based on different pricing plans. For details, see [Message storage duration](../reference/limitations#message-storage-duration). | +| `force` | bool | Yes | Whether to allow to recall messages beyond the storage time on the server. For details on the message storage duration on the server, see [Message storage duration](https://docs.agora.io/en/agora-chat/reference/limitations#message-storage-duration).
  • `true`: Yes. In this case, you can recall messages within the recall period or those beyond the storage time on the server. For the latter, this API recalls the messages locally saved by the recipient. If the message sending time is between your recall duration and the storage duration on the server, the recall fails. For example, if the recall duration is 2 minutes and the storage time on the server is 7 days, you can recall a message sent within 2 minutes or one that was sent more than 7 days ago; if the message is sent 3 minutes ago, the recall will fail.
  • `false`: No. You cannot recall messages beyond the storage time on the server. If you use the default recall time of 2 minutes or a custom duration, the server can only recall the messages sent within the specified time, and those beyond this time cannot be recalled. For example, if you set the recall time to 3 minutes and the message is sent 4 minutes ago, the recall will fail.
| ### HTTP response diff --git a/shared/chat-sdk/restful-api/_offline-push-configuration.mdx b/shared/chat-sdk/restful-api/_offline-push-configuration.mdx index ebde752a5..a213c0e0b 100644 --- a/shared/chat-sdk/restful-api/_offline-push-configuration.mdx +++ b/shared/chat-sdk/restful-api/_offline-push-configuration.mdx @@ -76,7 +76,7 @@ For the descriptions of path parameters, see [Common Parameters](#request). | Parameter | Type | Description | Required | | :----- | :----- | :------- | -------- | -| `nickname` | String | The nickname displayed in push notifications. The length of the nickname cannot exceed 100 characters, and the following character sets are supported:
  • 26 lowercase English letters (a-z)
  • 26 uppercase English letters (A-Z)
  • 10 numbers (0-9)
  • Chinese characters
  • Special characters
  • The nickname can be different from the nickname in the user profile; however, Agora recommends that you use the same nickname for both. Therefore, if either nickname is updated, the other should be changed at the same time. To update the nickname in the user profile, see [Setting user attributes](/agora-chat/restful-api/user-attributes-management#setting-user-attributes).
    | No | +| `nickname` | String | The nickname that is displayed in the push notification bar of the recipient's client when a message from the user is pushed. The length of the nickname cannot exceed 100 characters, and the following character sets are supported:
  • 26 lowercase English letters (a-z)
  • 26 uppercase English letters (A-Z)
  • 10 numbers (0-9)
  • Chinese characters
  • Special characters

  • If no nickname is set, when a message from this user is pushed, the user ID of the message sender, instead of the nickname, is indicated in the notification details (`notification_display_style` is set to 1).
    The nickname can be different from the nickname in user attributes. However, Agora recommends that you use the same nickname for both. Therefore, if either nickname is updated, the other should be changed at the same time. To update the nickname in user attributes, see Setting user attributes.
    | No | ### HTTP response @@ -103,7 +103,7 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```bash -curl -X PUT -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer YWMte3bGuOukEeiTkNP4grL7iwAAAAAAAAAAAAAAAAAAAAGL4CTw6XgR6LaXXVmNX4QCAgMAAAFnKdc-ZgBPGgBFTrLhhyK8woMEI005emtrLJFJV6aoxsZSioSIZkr5kw' -d '{ "nickname": "testuser" }' 'http://a1.agora.com/agora-demo/testapp/users/user1' +curl -X PUT -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer ' -d '{ "nickname": "testuser" }' 'http://XXXX/XXXX/XXXX/users/user1' ``` #### Response example @@ -111,12 +111,12 @@ curl -X PUT -H 'Content-Type: application/json' -H 'Accept: application/json' -H ```json { "action": "put", - "application": "8be024f0-e978-11e8-b697-5d598d5f8402", + "application": "8be024f0-XXXX-XXXX-b697-5d598d5f8402", "path": "/users", - "uri": "https://a1.agora.com/agora-demo/testapp/users", + "uri": "https://XXXX/XXXX/XXXX/users", "entities": [ { - "uuid": "4759aa70-eba5-11e8-925f-6fa0510823ba", + "uuid": "4759aa70-XXXX-XXXX-925f-6fa0510823ba", "type": "user", "created": 1542595573399, "modified": 1542596083687, @@ -187,7 +187,7 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```bash -curl -X PUT -H "Authorization: Bearer YWMtSozP9jHNEeSQegV9EKeAQAAAUlmBR2bTGr-GP2xNh8GhUCdKViBFDSEF2E" -i https://a1.agora.com/agora-demo/testapp/users/a -d '{"notification_display_style": "1"}' +curl -X PUT -H "Authorization: Bearer " -i https://XXXX/XXXX/XXXX/users/a -d '{"notification_display_style": "1"}' ``` #### Response example @@ -195,12 +195,12 @@ curl -X PUT -H "Authorization: Bearer YWMtSozP9jHNEeSQegV9EKeAQAAAUlmBR2bTGr-GP2 ```json { "action" : "put", - "application" : "17d59e50-0aee-11e8-8092-0dc80c0f5e99", + "application" : "17d59e50-XXXX-XXXX-8092-0dc80c0f5e99", "path" : "/users", - "uri" : "https://a1.agora.com/agora-demo/testapp/users", + "uri" : "https://XXXX/XXXX/XXXX/users", "entities" : [ { - "uuid" : "3b8c9890-7b9a-11e8-9d88-f50bf55cafad", + "uuid" : "3b8c9890-XXXX-XXXX-9d88-f50bf55cafad", "type" : "user", "created" : 1530276298905, "modified" : 1534407146060, @@ -212,8 +212,8 @@ curl -X PUT -H "Authorization: Bearer YWMtSozP9jHNEeSQegV9EKeAQAAAUlmBR2bTGr-GP2 } ], "timestamp" : 1534407146058, "duration" : 3, -"organization" : "1112171214115068", -"applicationName" : "testapp" +"organization" : "XXXX", +"applicationName" : "XXXX" } ``` @@ -277,8 +277,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```bash -curl -L -X PUT '{url}/{org_name}/{app_name}/users/{username}/notification/user/{key}' \ --H 'Authorization: Bearer {token}' \ +curl -L -X PUT 'http://XXXX/XXXX/XXXX/users/{username}/notification/user/{key}' \ +-H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ --data-raw '{ "type":"NONE", @@ -292,10 +292,10 @@ curl -L -X PUT '{url}/{org_name}/{app_name}/users/{username}/notification/user/{ ```json { "path": "/users", - "uri": "https://localhost/hx/hxdemo/users/notification/user/hxtest", + "uri": "https://XXXX/XXXX/XXXX/users/notification/user/hxtest", "timestamp": 1647503749918, - "organization": "hx", - "application": "17fe201b-ad9b-4a3a-83df-1ed1ebd7b227", + "organization": "XXX", + "application": "17fe201b-XXXX-XXXX-83df-1ed1ebd7b227", "action": "put", "data": { "type": "NONE", @@ -303,7 +303,7 @@ curl -L -X PUT '{url}/{org_name}/{app_name}/users/{username}/notification/user/{ "ignoreInterval": "21:30-08:00" }, "duration": 20, - "applicationName": "hxdemo" + "applicationName": "XXXX" } ``` @@ -317,7 +317,7 @@ For each App Key, the call frequency limit of this method is 100 per second. ### HTTP request ```html -GET https://{host}/{org}/{app}/users/{username}/notification/{chattype}/{key} +GET https://{host}/{org_name}/{app_name}/users/{username}/notification/{chattype}/{key} ``` #### Path parameter @@ -356,8 +356,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```bash -curl -L -X GET '{url}/{org}/{app}/users/{username}/notification/chatgroup/{key}' \ --H 'Authorization: Bearer {token}' +curl -L -X GET 'https://XXXX/XXXX/XXXX/users/{username}/notification/chatgroup/{key}' \ +-H 'Authorization: Bearer ' ``` #### Response example @@ -365,10 +365,10 @@ curl -L -X GET '{url}/{org}/{app}/users/{username}/notification/chatgroup/{key}' ```json { "path": "/users", - "uri": "https://localhost/hx/hxdemo/users/notification/chatgroup/12312312321", + "uri": "https://XXXX/XXXX/XXXX/users/notification/chatgroup/12312312321", "timestamp": 1647503749918, - "organization": "hx", - "application": "17fe201b-ad9b-4a3a-83df-1ed1ebd7b227", + "organization": "XXXX", + "application": "17fe201b-XXXX-XXXX-83df-1ed1ebd7b227", "action": "get", "data": { "type": "NONE", @@ -376,7 +376,7 @@ curl -L -X GET '{url}/{org}/{app}/users/{username}/notification/chatgroup/{key}' "ignoreInterval": "21:30-08:00" }, "duration": 20, - "applicationName": "hxdemo" + "applicationName": "XXXX" } ``` @@ -390,7 +390,7 @@ For each App Key, the call frequency limit of this method is 100 per second. ### HTTP request ```html -PUT https://{host}/{org}/{app}/users/{username}/notification/language +PUT https://{host}/{org_name}/{app_name}/users/{username}/notification/language ``` #### Path parameter @@ -429,8 +429,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```bash -curl -L -X PUT '{url}/{org}/{app}/users/{username}/notification/language' \ --H 'Authorization: Bearer {token}' \ +curl -L -X PUT 'https://XXXX/XXXX/XXXX/users/{username}/notification/language' \ +-H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ --data-raw '{ "translationLanguage":"EU" @@ -442,16 +442,16 @@ curl -L -X PUT '{url}/{org}/{app}/users/{username}/notification/language' \ ```json { "path": "/users", - "uri": "https://localhost/hx/hxdemo/users/notification/language", + "uri": "https://XXXX/XXXX/XXXX/users/notification/language", "timestamp": 1648089630244, - "organization": "hx", - "application": "17fe201b-ad9b-4a3a-83df-1ed1ebd7b227", + "organization": "XXXX", + "application": "17fe201b-XXXX-XXXX-83df-1ed1ebd7b227", "action": "put", "data": { "language": "EU" }, "duration": 66, - "applicationName": "hxdemo" + "applicationName": "XXXX" } ``` @@ -498,8 +498,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```bash -curl -L -X GET '{url}/{org}/{app}/users/{username}/notification/language' \ --H 'Authorization: Bearer {token}' +curl -L -X GET 'https://XXXX/XXXX/XXXX/users/{username}/notification/language' \ +-H 'Authorization: Bearer ' ``` #### Response example @@ -507,16 +507,16 @@ curl -L -X GET '{url}/{org}/{app}/users/{username}/notification/language' \ ```json { "path": "/users", - "uri": "https://localhost/hx/hxdemo/users/notification/language", + "uri": "https://XXXX/XXXX/XXXX/users/notification/language", "timestamp": 1648089630244, - "organization": "hx", - "application": "17fe201b-ad9b-4a3a-83df-1ed1ebd7b227", + "organization": "XXXX", + "application": "17fe201b-XXXX-XXXX-83df-1ed1ebd7b227", "action": "put", "data": { "language": "EU" }, "duration": 66, - "applicationName": "hxdemo" + "applicationName": "XXXX" } ``` @@ -575,8 +575,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```bash -curl -X POST '{url}/{org}/{app}/notification/template' \ --H 'Authorization: Bearer {token}' \ +curl -X POST 'https://XXXX/XXXX/XXXX/notification/template' \ +-H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "test7", @@ -589,10 +589,10 @@ curl -X POST '{url}/{org}/{app}/notification/template' \ ```json { - "uri": "https://localhost/hx/hxdemo/notification/template", + "uri": "https://XXXX/XXXX/XXXX/notification/template", "timestamp": 1646989584108, - "organization": "hx", - "application": "17fe201b-ad9b-4a3a-83df-1ed1ebd7b227", + "organization": "XXXX", + "application": "17fe201b-XXXX-XXXX-83df-1ed1ebd7b227", "action": "post", "data": { "name": "test7", @@ -602,7 +602,7 @@ curl -X POST '{url}/{org}/{app}/notification/template' \ "content_pattern": "Test,{0}" }, "duration": 26, - "applicationName": "hxdemo" + "applicationName": "XXXX" } ``` @@ -656,18 +656,18 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```bash -curl -X GET '{url}/{org}/{app}/notification/template/{name}' \ --H 'Authorization: Bearer {token}' +curl -X GET 'https://XXXX/XXXX/XXXX/notification/template/{name}' \ +-H 'Authorization: Bearer ' ``` #### Response example ```json { - "uri": "https://localhost/hx/hxdemo/notification/template/test7", + "uri": "https://XXXX/XXXX/XXXX/notification/template/test7", "timestamp": 1646989686393, - "organization": "hx", - "application": "17fe201b-ad9b-4a3a-83df-1ed1ebd7b227", + "organization": "XXXX", + "application": "17fe201b-XXXX-XXXX-83df-1ed1ebd7b227", "action": "get", "data": { "name": "test7", @@ -677,7 +677,7 @@ curl -X GET '{url}/{org}/{app}/notification/template/{name}' \ "content_pattern": "Test,{0}" }, "duration": 11, - "applicationName": "hxdemo" + "applicationName": "XXXX" } ``` @@ -731,18 +731,18 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```bash -curl -X DELETE '{url}/{org}/{app}/notification/template' \ --H 'Authorization: Bearer {token}' +curl -X DELETE 'https://XXXX/XXXX/XXXX/notification/template' \ +-H 'Authorization: Bearer ' ``` #### Response example ```json { - "uri": "https://localhost/hx/hxdemo/notification/template", + "uri": "https://XXXX/XXXX/XXXX/notification/template", "timestamp": 1646989686393, - "organization": "hx", - "application": "17fe201b-ad9b-4a3a-83df-1ed1ebd7b227", + "organization": "XXXX", + "application": "17fe201b-XXXX-XXXX-83df-1ed1ebd7b227", "action": "delete", "data": { "name": "test7", @@ -752,7 +752,7 @@ curl -X DELETE '{url}/{org}/{app}/notification/template' \ "content_pattern": "Test,{0}" }, "duration": 11, - "applicationName": "hxdemo" + "applicationName": "XXXX" } ``` diff --git a/shared/chat-sdk/restful-api/_presence.mdx b/shared/chat-sdk/restful-api/_presence.mdx index fd4ec6030..b2f15b8fe 100644 --- a/shared/chat-sdk/restful-api/_presence.mdx +++ b/shared/chat-sdk/restful-api/_presence.mdx @@ -23,7 +23,7 @@ This page shows how to use the Chat RESTful APIs to implement presence in your p ## Set the presence status of a user -Sets the presence status of a user. +Sets the user's presence status on a specific device. For each App Key, the call frequency limit of this method is 50 per second. @@ -37,8 +37,9 @@ POST https://{host}/{org_name}/{app_name}/users/{uid}/presence/{resource}/{statu | Parameter | Type | Description | Required | |:---------------| :------ | :------- |:------------------| -| `resource` | String | The unique identifier assigned to each device resource in the format `{Device Type}_{Resource ID}`, where the device type can be `android`, `ios`, or `web`, followed by a resource ID assigned by the SDK. | Yes | -| `status` | String | The presence status defined by the user:
  • `0`: Offline.
  • `1`: Online
  • Other strings: Custom status.
  • | Yes | +| `uid` | String | The user ID of user whose presence status is to be set. | Required | +| `resource` | String | The ID of the user's device for which the presence status is set. This device ID is the unique identifier assigned to each device resource in the format `{Device Platform}_{Resource ID}`, where the device platform can be `android`, `ios`, or `webim`, followed by an underscore plus a resource ID assigned by the SDK. For example, `android_34f0bbf7-8eab-46db-b572-b56b02405690`.| Yes | +| `status` | String | The presence status defined by the user:
    • `0`: Offline.
    • `1`: Online
    • Other numeric strings: Custom status.
    | Yes | For the descriptions of the other path parameters, see [Common Parameters](#param). @@ -72,8 +73,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```json -curl -X POST 'a1-test.agora.com:8089/5101220107132865/test/users/c1/presence/android_123423453246/0' \ --H 'Authorization: Bearer YWMtnjEbUopPEeybKGMmN0wpeZsaLSh8UEgpirS4wNAM_qx8oS2wik8R7LE4Rclv5hu9AwMAAAF-4tr__wBPGgDWGAeO86wl2lHGeTnU030fpWuEDR015Vk6ULWGYGKccA' \ +curl -X POST 'http://XXXX/XXXX/XXXX/users/c1/presence/android_123423453246/0' \ +-H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ -d '{"ext":"123"}' ``` @@ -140,8 +141,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```json -curl -X POST 'a1-test.agora.com:8089/5101220107132865/test/users/wzy/presence/1000' \ --H 'Authorization: Bearer YWMtnjEbUopPEeybKGMmN0wpeZsaLSh8UEgpirS4wNAM_qx8oS2wik8R7LE4Rclv5hu9AwMAAAF-4tr__wBPGgDWGAeO86wl2lHGeTnU030fpWuEDR015Vk6ULWGYGKccA' \ +curl -X POST 'http://XXXX/XXXX/XXXX/users/wzy/presence/1000' \ +-H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ -d '{"usernames":["c2","c3"]}' ``` @@ -203,8 +204,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```json -curl -X POST 'a1-test.agora.com:8089/5101220107132865/test/users/wzy/presence' \ --H 'Authorization: Bearer YWMtnjEbUopPEeybKGMmN0wpeZsaLSh8UEgpirS4wNAM_qx8oS2wik8R7LE4Rclv5hu9AwMAAAF-4tr__wBPGgDWGAeO86wl2lHGeTnU030fpWuEDR015Vk6ULWGYGKccA' \ +curl -X POST 'http://XXXX/XXXX/XXXX/users/wzy/presence' \ +-H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ -d '{"usernames":["c2","c3"]}' ``` @@ -275,8 +276,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```json -curl -X DELETE 'a1-test.agora.com:8089/5101220107132865/test/users/wzy/presence' \ --H 'Authorization: Bearer YWMtnjEbUopPEeybKGMmN0wpeZsaLSh8UEgpirS4wNAM_qx8oS2wik8R7LE4Rclv5hu9AwMAAAF-4tr__wBPGgDWGAeO86wl2lHGeTnU030fpWuEDR015Vk6ULWGYGKccA' \ +curl -X DELETE 'http://XXXX/XXXX/XXXX/users/wzy/presence' \ +-H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ -d '["c1"]' ``` @@ -338,8 +339,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example ```json -curl -X GET 'a1-test.agora.com:8089/5101220107132865/test/users/wzy/presence/sublist?pageNum=1&pageSize=100' \ --H 'Authorization: Bearer YWMtnjEbUopPEeybKGMmN0wpeZsaLSh8UEgpirS4wNAM_qx8oS2wik8R7LE4Rclv5hu9AwMAAAF-4tr__wBPGgDWGAeO86wl2lHGeTnU030fpWuEDR015Vk6ULWGYGKccA' \ +curl -X GET 'http://XXXX/XXXX/XXXX/users/wzy/presence/sublist?pageNum=1&pageSize=100' \ +-H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' ``` diff --git a/shared/chat-sdk/restful-api/_push-notification-management.mdx b/shared/chat-sdk/restful-api/_push-notification-management.mdx index 2e9748f79..da9d479c9 100644 --- a/shared/chat-sdk/restful-api/_push-notification-management.mdx +++ b/shared/chat-sdk/restful-api/_push-notification-management.mdx @@ -88,15 +88,15 @@ If the returned HTTP status code is not `200`, the request fails. You can refer ##### Request example ```shell -curl -X POST "http://localhost:8099/agora-demo/testy/push/single" -H "Authorization: Bearer YWMtOzQVjJ3mEeuJQv1qXhB5QAAAAAAAAAAAAAAAAAAAAAFDtjwasNNKD6W3CET2O3RNAQMAAAF41YIKUABPGgDuIZeu5IMVC_M9G5JlTjUsZeYVSg5o8BwshLgWveZxjA" -H "Content-Type: application/json" --data-raw "{ - \"targets\": [ - \"test2\" +curl -X POST "http://XXXX/XXXX/XXXX/push/single" -H "Authorization: Bearer " -H "Content-Type: application/json" --data-raw "{ + "targets": [ + "test2" ], - \"pushMessage\": { - \"title\": \"Hello\", - \"subTitle\": \"Hello\", - \"content\": \"Hello\", - \"vivo\": { + "pushMessage": { + "title": "Hello", + "subTitle": "Hello", + "content": "Hello", + "vivo": { } } @@ -123,7 +123,7 @@ curl -X POST "http://localhost:8099/agora-demo/testy/push/single" -H "Authorizat Sends push notifications to all users under one label, or the intersection of users under multiple labels. -A push task is automatically created per request, and the ID of the push task is returned for data statistics. +A push task is automatically created per request, and the ID of the push task is returned for data statistics. A maximum of three push tasks can be executed at the same time. See [Set push labels](set-push-labels) for configuring labels. @@ -148,7 +148,7 @@ For the descriptions of path parameters, see [Common parameters](#param). | Parameter | Type | Description | Required | | :-------------- | :----- | :------- | :----------- | -| `targets` | List | The targeting label names. You can either pass one label to send push notifications to all users under the label, or pass a maximum of three labels to send push notifications to the intersection of users under these labels. | Yes | +| `targets` | List | The targeting label names. You can either pass one label to send push notifications to all users under the label, or pass a maximum of five labels to send push notifications to the intersection of users under these labels. | Yes | | `strategy` | Number | The push strategies.
    • `0`: Use third-party push service first. When the pushing attempt fails, use Agora push service instead.
    • `1`: Use Agora push service only. If the target user is offline, Agora retains the push message for a certain period, depending on the Chat package to which you subscribe. After the retention period, the push message is dropped and the push attempt fails.
    • `2`: (Default) Use third-party push service only. If the target user is offline, whether to retain the push message and the retention period of the push message depend on the setting of the third-party service. If the push attempt fails, the message is discarded.
    • `3`: Use Agora push service first. When the pushing attempt fails, use third-party push service instead.
    | No | | `pushMessage` | JSON | The push messages. See [Set push notifications](./agora_chat_restful_config_push_notification) for details. | Yes | @@ -173,8 +173,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer ##### Request example ```shell -curl -L -X POST 'http://a1-hsb.agora.com/agora-demo/easeim/push/list/label' \ --H 'Authorization: Bearer YWMtIPBHKsOyEeAAAAAAAAAAAExCXvf5bRGAJBgXNYFJVQ9AQMAAAGAWu67KQBPGgBOV9ghkGKbtt9H9b1' \ +curl -L -X POST 'http://XXXX/XXXX/XXXX/push/list/label' \ +-H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ --data-raw '{ "targets": [ @@ -206,7 +206,7 @@ curl -L -X POST 'http://a1-hsb.agora.com/agora-demo/easeim/push/list/label' \ Sends push notifications to all users under the app. -A push task is automatically created per request, and the ID of the push task is returned for data statistics. +A push task is automatically created per request, and the ID of the push task is returned for data statistics. A maximum of three push tasks can be executed at the same time. #### HTTP request ```html @@ -250,12 +250,12 @@ If the returned HTTP status code is not `200`, the request fails. You can refer ##### Request example ```shell -curl -X POST "http://a1-hsb.agora.com/agora-demo/testy/push/task" -H "Content-Type: application/json" --data-raw "{ - \"pushMessage\": { - \"title\": \"Hello1234\", - \"subTitle\": \"Hello\", - \"content\": \"Hello\", - \"vivo\": {} +curl -X POST "http://XXXX/XXXX/XXXX/push/task" -H "Content-Type: application/json" --data-raw "{ + "pushMessage": { + "title": "Hello1234", + "subTitle": "Hello", + "content": "Hello", + "vivo": {} } }" ``` @@ -535,8 +535,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer ##### Request example ```shell -curl -L -X POST 'localhost/hx/hxdemo/push/label' \ --H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A' \ +curl -L -X POST 'http://XXXX/XXXX/XXXX/push/label' \ +-H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ --data-raw '{ "name":"post-90s", @@ -605,8 +605,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer ##### Request example ```shell -curl -L -X GET 'localhost/hx/hxdemo/push/label/90' \ --H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A' +curl -L -X GET 'http://XXXX/XXXX/XXXX/push/label/90' \ +-H 'Authorization: Bearer ' ``` ##### Response example @@ -744,8 +744,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer ##### Request example ```shell -curl -L -X DELETE 'localhost/hx/hxdemo/push/label/post-90s' \ --H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A' +curl -L -X DELETE 'http://XXXX/XXXX/XXXX/push/label/post-90s' \ +-H 'Authorization: Bearer ' ``` ##### Response example @@ -761,7 +761,7 @@ curl -L -X DELETE 'localhost/hx/hxdemo/push/label/post-90s' \ ### Add users to a push label -Adds one or more users to the specified push label. A maximum of 200,000 users can be added to a push label. To lift the upper limit, contact support@agora.io. +Adds one or more users to the specified push label. A maximum of 20,000 users can be added to a push label. To lift the upper limit, contact support@agora.io. You can add a maximum of 100 users at each call. @@ -813,8 +813,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer ##### Request example ```shell -curl -L -X POST 'localhost/hx/hxdemo/push/label/post-90s/user' \ --H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A' \ +curl -L -X POST 'http://XXXX/XXXX/XXXX/push/label/post-90s/user' \ +-H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ --data-raw '{ "usernames":["hx1","hx2"] @@ -883,8 +883,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer ##### Request example ```shell -curl -L -X GET 'localhost/hx/hxdemo/push/label/post-90s/user/hx1' \ --H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A' +curl -L -X GET 'http://XXXX/XXXX/XXXX/push/label/post-90s/user/hx1' \ +-H 'Authorization: Bearer ' ``` ##### Response example @@ -952,8 +952,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer ##### Request example ```shell -curl -L -X GET 'localhost/hx/hxdemo/push/label/post-90s/user?limit=1' \ --H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A' +curl -L -X GET 'http://XXXX/XXXX/XXXX/push/label/post-90s/user?limit=1' \ +-H 'Authorization: Bearer ' ``` ##### Response example @@ -1023,8 +1023,8 @@ If the returned HTTP status code is not `200`, the request fails. You can refer ##### Request example ```shell -curl -L -X DELETE 'localhost/hx/hxdemo/push/label/post-90s/user' \ --H 'Authorization: Bearer YWMt5lyAUJnNEeyHUS2MdMYkPAAAAAAAAAAAAAAAAAAAAAEHMpqy501HZr2ms92z-Hz9AQMAAAF_SGRs1QBPGgBOIAaoCYWXntKF-h0vuvlyUCNB-IXTM4eEpSVqIdei9A' \ +curl -L -X DELETE 'http://XXXX/XXXX/XXXX/push/label/post-90s/user' \ +-H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ --data-raw '{ "usernames":["hx1","hx2"] diff --git a/shared/chat-sdk/restful-api/_reaction.mdx b/shared/chat-sdk/restful-api/_reaction.mdx index 15b244f0e..829ac3752 100644 --- a/shared/chat-sdk/restful-api/_reaction.mdx +++ b/shared/chat-sdk/restful-api/_reaction.mdx @@ -1,7 +1,8 @@ import * as data from '@site/data/variables'; import Authorization from '@docs/shared/chat-sdk/restful-api/shared/authorization.mdx'; -During one-to-one chats and group chats, users can reply a specified message with emojis, which adds fun and diversity to real-time chatting. In Chat, this feature is known as reaction. This page shows how to use the Chat RESTful APIs to implement reaction in your project. +During one-to-one chats and group chats, users can reply a specified message with emojis, which adds fun and diversity to real-time chatting. In Agora Chat, this feature is known as reaction. For a message, one emoji is counted as one reaction even if it is added repeatedly. A maximum of 20 reactions can be added for one message. To increase the upper limit, contact [support@agora.io](mailto:support@agora.io). +This page shows how to use the Agora Chat RESTful API to implement reaction in your project. Before calling the following methods, make sure you understand the call frequency limit of the Chat RESTful APIs as described in Limitations. @@ -38,7 +39,7 @@ The following table lists common request and response parameters of the Chat RES ## Create/Add a reaction -This method creates or adds a reaction to a specified message in one-to-one chats or group chats. +This method creates or adds a reaction to a specified message in one-to-one chats or group chats. A maximum of 20 reactions can be added for one message. For one message, if many users add the same reaction, these reactions are counted as one reaction. A message can have a maximum of 20 reactions. To raise the limit, contact [support@agora.io](mailto:support@agora.io). ### HTTP request @@ -107,7 +108,7 @@ curl -g -X POST 'http://XXXX/XXXX/XXXX/reaction/user/e1' -H 'Authorization: Bear "msgId": "msg3333", "msgType": "chat", "groupId": null, - "reaction": "message123456", + "reaction": "emoji_40", "createdAt": "2022-02-24T10:57:43.138934Z", "updatedAt": "2022-02-24T10:57:43.138939Z" } @@ -184,8 +185,8 @@ curl -g -X GET 'http://XXXX/XXXX/XXXX/reaction/user/{{userId}}?msgIdList=msgId1& "reactionList": [ { "reactionId": "944330310986837168", - "reaction": message123456, - "userCount": 0, + "reaction": "message123456", + "count": 3, "state": false, "userList": [ "test123", @@ -200,8 +201,8 @@ curl -g -X GET 'http://XXXX/XXXX/XXXX/reaction/user/{{userId}}?msgIdList=msgId1& "reactionList": [ { "reactionId": "945272584050659838", - "reaction": message123456, - "userCount": 0, + "reaction": "message123456", + "count": 1, "state": false, "userList": [ "test5" @@ -293,8 +294,10 @@ For the parameters and the detailed description, see [Common parameters](#param) | --- | --- | --- | --- | | `msgId` | String | The message ID. | Yes | | `message` | String | The ID of the emoji that is added as the reaction. | Yes | -| `limit` | Number | The number of reactions retrieved on each page when you retrieve the reactions with pagination. The value range is [1,100]. The default value is 100. | No | -| `cursor` | String | The starting page from which to retrieve data if you retrieve the reactions with pagination.| No | +| `limit` | Number | The number of users that added the reaction on each page when you retrieve the users with pagination. The value range is [1,50]. The default value is 50. | No | +| `cursor` | String | The cursor for specifying where to retrieve data if you retrieve the users with pagination.| No | + +
    If the pagination parameters are specified, the server returns the users that added the reaction in the ascending order of when reactions are added. If the pagination parameters are not specified, the server returns the first 50 users that added the reaction.
    #### Request header @@ -315,7 +318,7 @@ If the returned HTTP status code is `200`, the request succeeds, and the `data` | `reaction` | String | The emoji ID that is the same as the `message` parameter specified in the request body when [adding a reaction](#create). | | `count` | Number | The number of users that have added the reaction. | | `state` | Bool | Whether the user sending this request has added a reaction to this message:
    • `true`: Yes.
    • `false`: No.
    | -| `userList` | Array | The list of the users that have added this reaction. Note that this list only contains the last three user IDs to do so. | +| `userList` | Array | The list of the users that have added this reaction. Users are listed in the ascending order of the reaction addition time.| | `cursor` | String | The cursor that indicates that starting position of the next query. | For other fields and the detailed descriptions, see [Common parameters](#param). diff --git a/shared/chat-sdk/restful-api/_restful-overview.mdx b/shared/chat-sdk/restful-api/_restful-overview.mdx index 466b9cef9..9b69f7071 100644 --- a/shared/chat-sdk/restful-api/_restful-overview.mdx +++ b/shared/chat-sdk/restful-api/_restful-overview.mdx @@ -79,7 +79,7 @@ The total rate limit of the following methods is 100/second. ### Sending messages and uploading/downloading files -This group of methods enables you to send text, image, voice, video, CMD, extension, file, custom, and other types of messages, as well as to upload and download files from the server. +This group of methods enables you to send text, image, voice, video, CMD, extension, file, custom, and other types of messages, as well as uploading and downloading files from the server. | Name | Method | Request | Description | Rate Limits | | :--------------- | :--- | :------------------------------------------ | :------------------------------------------------- | :----- | @@ -122,7 +122,7 @@ This group of methods enables you to create, retrieve, modify, and delete chat g | Name | Method | Request | Description | Rate Limits | | :------------------------------ | :----- | :--------------------------------------------- | :----------------------------- | :----- | -| Retrieving all chat groups in the app by page | GET | `/{org_name}/{app_name}/chatgroups?limit={N}&cursor={cursor} ` | Retrieves the information of all the groups in the app by page. | 100/second | +| Retrieving all chat groups in the app by page | GET | `/{org_name}/{app_name}/chatgroups?limit={N}&cursor={cursor}` | Retrieves the information of all the groups in the app by page. | 100/second | | Retrieving all the chat groups the user joins | GET | `/{org_name}/{app_name}/users/{username}/joined_chatgroups` | Retrieves all the groups the user joins by specifying the user name. | 100/second | | Retrieving chat group details | GET | `/{org_name}/{app_name}/chatgroups/{group_ids}` | Retrieves group details by specifying the group ID. | 100/second | | Creating a chat group | POST | `/{org_name}/{app_name}/chatgroups` | Creates a chat group. | 100/second | @@ -190,6 +190,18 @@ This group of methods enables you to mute any user ID in one-to-one chats, group | Query the detailed information of global-mute | GET | `/{orgName}/{appName}/mutes/username` | Queries the detailed information of the global-mute settings of the specified user in one-to-one chats, group chats, or chatrooms.| 100/second | | Retrieve all globally muted users | GET | `/{orgName}/{appName}/mutes` | Retrieves all the users that have been globally muted in the app. | 100/second | +### Presence + +This group of methods enable you to set the presence of a user, subscribe to the presence of multiple users, retrieve the presence status of multiple users, and retrieve the subscriptions of a user. + +| Name | Method | Request | Description | Rate Limits | +| :------------- | :----- | :----------- | :------------------------ | :------------------------ | +| Setting the presence status of a user | POST | `/{org_name}/{app_name}/users/{username}/presence/{resource}/{status}` | Sets the presence status of a user by user ID. | 50/second | +| Subscribing to the presence status of multiple users | POST | `/{org_name}/{app_name}/users/{username}/presence/{expiry}` | Subscribes to the presence status of multiple users. | 50/second | +| Retrieving the presence status of multiple users | POST | `/{org_name}/{app_name}/users/{username}/presence` | Retrieves the presence status of multiple users. | 50/second | +| Unsubscribing from the presence status of multiple users | DELETE | `/{org_name}/{app_name}/users/{username}/presence` | Unsubscribes from the presence status of multiple users. | 50/second | +| Retrieving the subscriptions of a user | GET | `/{org_name}/{app_name}/users/{username}/presence/sublist?pageNum=1&pageSize=100` | Retrieves the subscriptions of a user. | 50/second | + ### Reaction This group of methods enable your chat users to reply the message with emojis. @@ -201,6 +213,28 @@ This group of methods enable your chat users to reply the message with emojis. | Delete a reaction | DELETE | `/{org_name}/{app_name}/reaction/user/{userId}` | Deletes a reaction. | 100/second | | Retrieve the detailed information of the reaction | GET | `/{org_name}/{app_name}/reaction/user/{userId}/detail` | Retrieves the detailed information of the reaction by specifying the message ID and reaction ID. | 100/second | +### Thread management + +This group of methods enable you to create a thread, modify a thread, delete a thread, and retrieve threads. + +| Name | Method | Request | Description | Rate Limits | +| :------------- | :----- | :---------------------------- | :--------------------- | +| Creating a thread | POST | `/{org_name}/{app_name}/thread` | Creates a thread. | 100/second | +| Modifying a thread | PUT | `/{org_name}/{app_name}/thread/{thread_id}` | Modifies a thread. | 100/second | +| Deleting a thread | DELETE | `/{org_name}/{app_name}/thread/{thread_id}` | Deletes a thread. | 100/second | +| Retrieving all the threads under the app | GET | `/{org_name}/{app_name}/thread?limit={limit}&cursor={cursor}&sort={sort}` | Retrieves all the threads under the app | 100/second | +| Retrieving all the threads a user joins under the app | GET | `/{org_name}/{app_name}/threads/user/{username}?limit={limit}&cursor={cursor}&sort={sort}` | Retrieves all the threads a user joins under the app | 100/second | +| Retrieving all the threads a user joins under a chat group | GET | `/{org_name}/{app_name}/threads/chatgroups/{group_id}/user/{username}?limit={limit}&cursor={cursor}&sort={sort}` | Retrieves all the threads a user joins by user ID and group ID. | 100/second | + +### Thread member management + +This group of methods enable you to join a thread and remove members from the thread. + +| Name | Method | Request | Description | Rate Limits | +| :----------------- | :----- | :------------- | :------------------- |:------------------- | +| Retrieving thread members | GET | `/{org_name}/{app_name}/thread/{thread_id}/users?limit={N}&cursor={cursor}` | Retrieves all the members in the specified thread. | 100/second | +| Adding multiple users to a thread | POST | `/{org_name}/{app_name}/thread/{thread_id}/users` | Adds multiple users to the specified thread. | 100/second | +| Removing multiple thread members | DELETE | `/{org_name}/{app_name}/threads/{thread_id}/users` |Removes multiple users from the specified thread. | 100/second | ## Request structure diff --git a/shared/chat-sdk/restful-api/_user-attributes-management.mdx b/shared/chat-sdk/restful-api/_user-attributes-management.mdx index 47722a3f8..2b4494b31 100644 --- a/shared/chat-sdk/restful-api/_user-attributes-management.mdx +++ b/shared/chat-sdk/restful-api/_user-attributes-management.mdx @@ -73,6 +73,19 @@ The request body is in the format of JSON String, and the length cannot exceed 4 | `Key` | String | Attribute name | Yes | | `Value` | String | Attribute value | Yes | +When you call this RESTful API to set the user's nickname, avatar, contact information, email address, gender, signature, birthday and extension fields, you must pass in the following keys to make sure that the client can obtain the settings from the server: + +| Field | Type | Description | +| :---------- | :----- | :----------------------------------------------------------- | +| `nickname` | String | The user nickname, which can contain at most 64 characters. | +| `avatarurl` | String | The user avatar URL, which can contain at most 256 characters. | +| `phone` | String | The user's phone number, which can contain at most 32 characters. | +| `mail` | String | The user's email address, which can contain at most 64 characters. | +| `gender` | Number | The user gender:
    • `1`:Male;
    • `2`:Female;
    • (Default) `0`: Unknown;
    • Other values are invalid.
    | +| `sign` | String | The user's signature, which can contain at most 256 characters. | +| `birth` | String | The user's birthday, which can contain at most 256 characters. | +| `ext` | String | The extension fields. | + ### HTTP response #### Response body @@ -95,7 +108,7 @@ The user attributes used in this example are named `ext`, `nickname`, and `avata ```shell # Replace {YourAppToken} with the app token generated in your server. -curl -X PUT -H 'Content-Type: application/x-www-form-urlencoded' -H 'Authorization: Bearer {YourAppToken}' -d 'avatar=http://www.agorachat.com/avatar.png&ext=ext&nickname=nickname' 'http://XXXX/XXXX/XXXX/metadata/user/XXXX' +curl -X PUT -H 'Content-Type: application/x-www-form-urlencoded' -H 'Authorization: Bearer {YourAppToken}' -d 'avatarurl=http://www.agorachat.com/avatar.png&ext=ext&nickname=nickname' 'http://XXXX/XXXX/XXXX/metadata/user/XXXX' ``` #### Response example @@ -106,7 +119,7 @@ curl -X PUT -H 'Content-Type: application/x-www-form-urlencoded' -H 'Authorizati "data": { "ext": "ext", "nickname": "nickname", - "avatar": "http://XXXX.png" + "avatarurl": "http://XXXX.png" }, "duration": 166 } diff --git a/shared/chat-sdk/restful-api/_user-system-registration.mdx b/shared/chat-sdk/restful-api/_user-system-registration.mdx index 4823a1e5e..005b02543 100644 --- a/shared/chat-sdk/restful-api/_user-system-registration.mdx +++ b/shared/chat-sdk/restful-api/_user-system-registration.mdx @@ -69,7 +69,7 @@ If the returned HTTP status code is not `200`, the request fails. You can refer ```shell # Replace {YourAppToken} with the app token generated in your server. -curl -X POST -H 'Content-Type: application/json' -H 'Authorization:Bearer {YourAppToken}' -i "https://XXXX/XXXX/XXXX/users" -d ' +curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization:Bearer {YourAppToken}' -i "https://XXXX/XXXX/XXXX/users" -d ' { "username": "user1", "password": "123", @@ -134,8 +134,7 @@ The request body is a JSONArray object, which contains the following fields: | :--------- | :----- | :---------------------------------------------------------------------------------------------------------------------------------------------------- | :------- | | `username` | String | The unique login account of the user. The username must be 64 bytes or less and cannot be empty. | Yes | | `password` | String | The user's login password. The length cannot exceed 64 bytes. | Yes | -| `nickname` | String | The nickname of the user displayed in the notification bar of the message push when the message is pushed. The length cannot exceed 100 bytes. The default value is null.
    This field is used to set the user nickname displayed in the message push, not the user nickname in the user attributes. | Yes | - +| `nickname` | String | The nickname that is displayed in the push notification bar of the recipient's client when a message from the user is pushed. The length of the nickname cannot exceed 100 characters, and the following character sets are supported:
  • 26 lowercase English letters (a-z)
  • 26 uppercase English letters (A-Z)
  • 10 numbers (0-9)
  • Chinese characters
  • Special characters

  • If no nickname is set, when a message from this user is pushed, the user ID of the message sender, instead of the nickname, is indicated in the notification details (`notification_display_style` is set to 1).
    The nickname can be different from the nickname in user attributes. However, Agora recommends that you use the same nickname for both. Therefore, if either nickname is updated, the other should be changed at the same time. To update the nickname in user attributes, see Setting user attributes.
    | No | ### HTTP response #### Response body @@ -818,7 +817,7 @@ For each App Key, the call frequency limit of this method is 100 per second. ### HTTP request ```html -POST https://{host}/{org_name}/{app_name}/users/{username}/disconnect +GET https://{host}/{org_name}/{app_name}/users/{username}/disconnect ``` #### Path parameter diff --git a/shared/chat-sdk/restful-api/chat-group-management/_create-delete-retrieve-groups.mdx b/shared/chat-sdk/restful-api/chat-group-management/_create-delete-retrieve-groups.mdx index 5fefef293..abcc41de6 100644 --- a/shared/chat-sdk/restful-api/chat-group-management/_create-delete-retrieve-groups.mdx +++ b/shared/chat-sdk/restful-api/chat-group-management/_create-delete-retrieve-groups.mdx @@ -67,12 +67,14 @@ For the descriptions of other path parameters, see [Common Parameters](#param). | Parameter | Type | Description | Required | | :------------- | :------ | :----------------------------------------------------------- | :------- | -| `groupname` | String | The group name. It cannot exceed 128 characters. The group name cannot contain "/" or spaces. You can use "+" to represent the space. | Yes | -| `desc` | String | The group description. It cannot exceed 512 characters. The group name cannot contain "/" or spaces. You can use "+" to represent the space. | Yes | +| `groupname` | String | The group name. It cannot exceed 128 characters. | Yes | +| `desc` | String | The group description. It cannot exceed 512 characters. | Yes | | `public` | Boolean | Whether the group is a public group. Public groups can be searched and chat users can apply to join a public group. Private groups cannot be searched, and chat users can join a private group only if the group owner or admin invites the user to join the group.
    • `true`: Yes
    • `false`: No
    | Yes | -| `maxusers` | String | The maximum number of chat group members (including the group owner). The default value is 200 and the maximum value is 2000. The upper limit varies with your price plans. For details, see [Pricing Plan Details](../../reference/pricing-plan-details#group). | No | +| `scale` | String | The group scale. The parameter value depends on the setting of `maxusers`.
    • (Default) `normal`: Normal group that has a maximum of 3000 members.
    • `large`: Large group that has more than 3000 members. You must set this parameter when you create a large group. Large groups do not support offline push.
    | No | +| `maxusers` | String | The maximum number of chat group members (including the group owner). The default value is 200. The upper limit varies with your price plans. For details, see [Pricing Plan Details]([Pricing Plan Details](../../reference/pricing-plan-details#group). | No | | `allowinvites` | Boolean | Whether a regular group member is allowed to invite other users to join the chat group.
    • `true`: Yes.
    • `false`: No. Only the group owner or admin can invite other users to join the chat group.
    | No | | `membersonly` | Boolean | Whether the user requesting to join the public group requires approval from the group owner or admin:
    • `true`: Yes.
    • `false`: (Default) No.
    | No | +| `invite_need_confirm` | Boolean | Whether the invitee needs to confirm the received group invitation before joining the group:
    • `true`: Yes.
    • `false`: No. The invitee automatically joins the chat group after receiving the group invitation.
    | No| | `owner` | String | The chat group owner. | Yes | | `members` | Array | Regular chat group members. This chat group member array does not contain the group owner. If you want to set this field, you can enter 1 to 100 elements in this array. | No | | `custom` | String | The extension information of the chat group. The extension information cannot exceed 1024 characters. | No | @@ -100,7 +102,7 @@ If the returned HTTP status code is not 200, the request fails. You can refer to curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer ' -d '{ "groupname": "testgroup", "desc": "test", - "public": true + "public": true, "maxusers": 300, "owner": "testuser", "members": [ @@ -268,7 +270,7 @@ GET https://{host}/{org_name}/{app_name}/chatgroups/{group_ids} | Parameter | Type | Description | Required | | :-------- | :----- | :----------------------------------------------------------- | :------- | -| `group_ids` | String | The ID of the group whose details you want to retrieve. You can type one or more group IDs that are separated with the comma (,). | Yes | +| `group_ids` | String | The ID of the group whose details you want to retrieve. You can type a maximum of 100 group IDs that are separated with the comma (,). | Yes | For other parameters and detailed descriptions, see [Common parameters](#param). @@ -300,6 +302,7 @@ If the returned HTTP status code is 200, the request succeeds, and the data fiel | `affiliations` | Array | The list of existing group members, including the group owner and regular group members, for example, `[{"owner":"user1"},{"member":"user2"},{"member":"user3"}]`. | | `public` | Boolean | Whether the chat group is a public group.
    • `true`: Yes.
    • `false`: No.
    | | `custom` | String | The extension information of the chat group. | +| `count` | Number | The number of retrieved chat groups. | For other parameters and detailed descriptions, see [Common parameters](#param). @@ -318,40 +321,39 @@ curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer If the limit and cursor parameters are not specified, the basic information of 10 chat groups on the first page is returned by default.
    +
    If neither the limit nor cursor parameter is specified, the server returns the latest 10 groups by creation time.
    #### Request header @@ -631,7 +633,7 @@ Retrieves all the chat groups that a user joins. ### HTTP request ```shell -GET https://{host}/{app_name}/users/{username}/joined_chatgroups?pagesize={}&pagenum={} +GET https://{host}/{org_name}/{app_name}/users/{username}/joined_chatgroups?pagesize={}&pagenum={} ``` #### Path parameter @@ -645,7 +647,7 @@ For the descriptions of path parameters of this method, see [Common parameters]( | `pagesize` | String | The number of chat groups to retrieve per page. The default value is `10`. The value range is [1,100]. | No | | `pagenum` | String | The start position for the next query. | No | -
    If the pagesize and pagenum parameters are not specified, the basic information of 10 chat groups on the first page is returned by default.
    +
    If neither `pagesize` nor `pagenum` is specified, the server returns the top 500 groups in the descending order of when the user joined the groups.
    #### Request header @@ -674,7 +676,7 @@ If the returned HTTP status code is not 200, the request fails. You can refer to #### Request example ```shell -curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer ' 'http://XXXX/XXXX/XXXX/users/user1/joined_chatgroups?pagesize=1&pagenum=100' +curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer ' 'http://XXXX/XXXX/XXXX/users/user1/joined_chatgroups?pagesize=100&pagenum=1' ``` #### Response example @@ -695,11 +697,11 @@ curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer If you pass in neither `pageSize` nor `cursor`, the server returns the top 500 users in the descending order of time when they are added to the block list. If you pass in only `pageSize`, but not `cursor`, the server returns a maximum of 50 users in the descending order of time when they are added to the block list.
    + #### Request header | Parameter | Type | Description | Required | @@ -82,26 +91,24 @@ If the returned HTTP status code is not 200, the request fails. You can refer to #### Request example ```shell -curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer ' 'http://XXXX/XXXX/XXXX/chatgroups/66016455491585/blocks/users' +curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer ' 'https://XXXX/XXXX/XXXX/chatgroups/66XXXX85/blocks/users?pageSize=2' ``` #### Response example ```json { - "action": "get", - "application": "8be024f0-XXXX-XXXX-b697-5d598d5f8402", - "uri": "http://XXXX/XXXX/XXXX/chatgroups/67178793598977/blocks/users", + "uri": " https://XXXX/XXXX/XXXX/chatgroups/66XXXX85/users/blocks/users", + "timestamp": 1682064422108, "entities": [], + "cursor": "MTA5OTAwMzMwNDUzNTA2ODY1NA==", + "count": 2, + "action": "get", "data": [ - "user2", - "user3" + "tst05", + "tst04" ], - "timestamp": 1543466293681, - "duration": 0, - "organization": "XXXX", - "applicationName": "XXXX", - "count": 2 + "duration": 52 } ``` diff --git a/shared/chat-sdk/restful-api/chat-group-management/_manage-group-members.mdx b/shared/chat-sdk/restful-api/chat-group-management/_manage-group-members.mdx index 8acd23f29..397c6f7f0 100644 --- a/shared/chat-sdk/restful-api/chat-group-management/_manage-group-members.mdx +++ b/shared/chat-sdk/restful-api/chat-group-management/_manage-group-members.mdx @@ -85,7 +85,8 @@ If the returned HTTP status code is 200, the request succeeds, and the `data` fi | Parameter | Type | Description | | :----- | :----- | :--------------------------------------- | | `owner` | String | The username of the group owner, for example, `{"owner":"user1"}`. | -| `member` | String | The username of group members, for example, `{"member":"user2"}`. | +| `member` | String | The username of a group admin or regular group member, for example, `{"member":"user2"}`. | +| `count` | String | The number of group members retrieved at this call of this API. | For other fields and descriptions, see [Common parameters](#param). @@ -117,7 +118,7 @@ curl -X GET -H 'Accept: application/json' 'http://XXXX/XXXX/XXXX/chatgroups/1013 "entities": [], "data": [ { - "member": "user1" + "owner": "user1" }, { "member": "user2" @@ -426,7 +427,7 @@ curl -X DELETE -H 'Accept: application/json' -H 'Authorization: Bearer
  • `true`: Success
  • `false`: Failure
  • | | `expire` | Long | The Unix timestamp when the mute state expires, in milliseconds. | -| `user` | String | The username of the muted chat group member.| +| `user` | String | The user ID of the muted chat group member.| For other fields and descriptions, see [Common parameter](#param). @@ -125,7 +125,7 @@ Removes the specified user from the chat group mute list. Once removed from the ### HTTP request ```shell -POST https://{host}/{org_name}/{app_name}/chatgroups/{group_id}/mute/{member_id} +DELETE https://{host}/{org_name}/{app_name}/chatgroups/{group_id}/mute/{member_id} ``` #### Path parameter @@ -133,7 +133,7 @@ POST https://{host}/{org_name}/{app_name}/chatgroups/{group_id}/mute/{member_id} | Parameter | Type | Description | Required | | :-------- | :----- | :----------------------------------------------------------- | :------- | | `group_id` | String | The group ID. | Yes | -| `member_id` | String | The group member ID. To remove more than one group member from the mute list, pass in multiple usernames separated by comma (,). For example, `{member1}, {member2}`. | Yes | +| `member_id` | String | The user ID of a group member to be removed from the chat group mute list. You can pass in a maximum of 60 user IDs that are separated by comma (,). For example, `{member1}, {member2}`. | Yes | For other parameters and detailed descriptions, see [Common parameters](#param). @@ -334,7 +334,7 @@ This method unmutes all the chat group members. Once unmuted, the chat group mem ### HTTP request ```shell -PUT https://{host}/{org_name}/{app_name}/chatgroups/{group_id}/ban +DELETE https://{host}/{org_name}/{app_name}/chatgroups/{group_id}/ban ``` #### Path parameter diff --git a/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-admins.mdx b/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-admins.mdx index fc5e1c652..9bc27bdcd 100644 --- a/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-admins.mdx +++ b/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-admins.mdx @@ -197,12 +197,14 @@ GET https://{host} /{org_name}/{app_name}/chatrooms/super_admin?pagenum={N}&page #### Path parameter +For parameters and detailed descriptions, see [Common parameters](#param). + +#### Query parameter + | Parameter | Type | Description | Required | | :--------- | :--- | :-------------------------------------- | :------- | -| `pagenum` | Int | The number of page on which chat room admins are retrieved. The default value is 1. | No | -| `pagesize` | Int | The number of super admins displayed on each page. The default value is 10. | No | - -For other parameters and detailed descriptions, see [Common parameters](#param). +| `pagenum` | Number | The number of page on which chat room admins are retrieved. The default value is 1. | No | +| `pagesize` | Number | The number of super admins displayed on each page. The default value is 10. | No | #### Request header @@ -219,8 +221,6 @@ If the returned HTTP status code is `200`, the request succeeds, and the respons | Parameter | Type | Descriptions | | :--------- | :--------- | :------------------------------- | -| `pagenum` | Int | The current page number. | -| `pagesize` | Int | The maximum number of super administrators displayed on each page. | | `data` | JSONArray | The array of usernames of super admins of the specified chat rooms. | | `count` | Number | The number of super admins that are returned. | @@ -241,19 +241,20 @@ curl -X GET http://XXXX/XXXX/XXXX/chatrooms/super_admin?pagenum=2&pagesize=2 -H ```json { "action": "get", - "application": "9fa492a0-XXXX-XXXX-b1b9-a76b05da6904", - "params": { - "pagesize": ["2"], - "pagenum": ["2"] - }, - "uri": "http://XXXX/XXXX/XXXX/chatrooms/super_admin", - "entities": [], - "data": ["hxtest1", "hxtest11", "hxtest10"], - "timestamp": 1596187292391, + "application": "2a8f5b13-XXXX-XXXX-958a-838fd47f1223", + "applicationName": "XXXX", + "count": 3, + "data": [ + "yifan4", + "yifan3", + "yifan2" + ], "duration": 0, + "entities": [], "organization": "XXXX", - "applicationName": "XXXX", - "count": 3 + "properties": {}, + "timestamp": 1681698118068, + "uri": "http://a1-hsb.easemob.com/easemob-demo/chatdemoui/chatrooms/super_admin" } ``` diff --git a/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-attributes.mdx b/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-attributes.mdx index 95f022c6c..bc2294ea6 100644 --- a/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-attributes.mdx +++ b/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-attributes.mdx @@ -185,6 +185,8 @@ Removes custom attributes set by the current user.
    This method is only used to remove the key-value pairs set by the current user. To remove the key-value pairs set by others, see Forcibly remove custom attributes.
    +You can remove a maximum of 10 custom attributes at each call of this API. + ### HTTP request ```html @@ -207,7 +209,7 @@ For the parameters and detailed descriptions, see [Common parameters](#param). | Parameter | Type | Required | Description | | :------------ | :----- | :------- | :------ | -| `keys` | Array | No | The keys of the custom attributes to remove. | +| `keys` | Array | No | The keys of the custom attributes to remove. You can pass in at most 10 keys each time. | ### HTTP response @@ -340,7 +342,7 @@ For the parameters and detailed descriptions, see [Common parameters](#param). | Parameter | Type | Required | Description | | :------------ | :----- | :------- | :------ | -| `keys` | Array | No | The keys of the custom attributes to remove. | +| `keys` | Array | No | The keys of the custom attributes to remove. You can pass in at most 10 keys. | ### HTTP response diff --git a/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-blocklist.mdx b/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-blocklist.mdx index 2282543f7..2ddad0810 100644 --- a/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-blocklist.mdx +++ b/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-blocklist.mdx @@ -106,7 +106,7 @@ curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer YWMt7Coyjusb ## Adding a user to the chat room block list -Adds the specified user to the chat room block list. Once added to the chat room block list, users receive a notification stating "You are kicked out of the chatroom `{chatroom_id}`" and can no longer join the chat room. They can neither send nor receive messages in the chat room. +Adds the specified user to the chat room block list. Once added to the chat room block list, users can no longer join the chat room. They can neither send nor receive messages in the chat room. You cannot add the chat room owner to the chat room block list. @@ -176,7 +176,7 @@ curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' - ## Adding multiple users to the chat room block list -Adds multiple users to the chat room block list. Once added to the chat room block list, users receive a notification stating "You are kicked out of the chatroom `{chatroom_id}`" and can no longer join the chat room. They can neither send nor receive messages in the chat room. +Adds multiple users to the chat room block list. Once added to the chat room block list, users can no longer join the chat room. They can neither send nor receive messages in the chat room. You can add a maximum of 60 users to the chat room block list at one time. You cannot add the chat room owner to the chat room block list. diff --git a/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-members.mdx b/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-members.mdx index 513f6ce93..56bec8e44 100644 --- a/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-members.mdx +++ b/shared/chat-sdk/restful-api/chatroom-management/_manage-chatroom-members.mdx @@ -237,7 +237,9 @@ If the returned HTTP status code is `200`, the request succeeds, and the respons | Field | Type | Description | | :------- | :----- | :------------------- | -| `member` | String | The username of a chat room member. | +| `owner` | String | The username of the chat room owner, for example, `{"owner":"user1"}`. | +| `member` | String | The username of a chat room admin or regular chat room member, for example, `{"member":"user2"}`. | +| `count` | String | The number of chat room members retrieved at this call of this API. | For other fields and detailed descriptions, see [Common parameters](#param). @@ -266,7 +268,7 @@ curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer `-1` indicates that the member is muted permanently. | Yes | -| `usernames` | String | The ID of the user to be muted. +| `usernames` | String | The array of user IDs of chat room members that are to be muted. You can pass in a maximum of 60 user IDs. ### HTTP response @@ -77,7 +77,7 @@ If the returned HTTP status code is `200`, the request succeeds, and the respons | :------- | :----- | :------------------------------------------------------ | | `result` | Bool | The mute result:
  • `true: `Success
  • `false`: Failure
  • | | `expire` | Number | The Unix timestamp (ms) when the mute state expires. | -| `user` | String | The username of the muted chat room member. | +| `user` | Array | The username of the muted chat room member. | For other fields and detailed descriptions, see [Common parameters](#param). @@ -142,8 +142,7 @@ DELETE https://{host}/{org_name}/{app_name}/chatrooms/{chatroom_id}/mute/{member | Parameter | Type | Description | Required | | :------- | :----- | :---------------------------------------------------------------------------------------------------------------------------------------- | :------- | -| `member` | String | The username of the chat room member to be unmuted.
    If you want to unmute multiple members, separate the member usernames with commas (","). In the URL, use "%2C" to represent ",". | Yes | - +| `member` | String | The username of the chat room member to be unmuted.
    You can pass in a maximum of 60 user IDs that are separated with commas (","). In the URL, use "%2C" to represent ",". | Yes | For other parameters and detailed descriptions, see [Common parameters](#param). #### Request header @@ -274,6 +273,8 @@ curl -X DELETE -H 'Accept: application/json' -H 'Authorization: Bearer ' -d '{ +```shell +curl -X POST http://XXXX.com/XXXX/testapp/thread -H 'Authorization: Bearer ' -H 'Content-Type:application/json' -d ' +{ "group_id": 179800091197441, "name": "1", "owner": "test4", @@ -102,7 +103,7 @@ curl -X POST http://XXXX.com/XXXX/testapp/thread -H 'Authorization: Bearer ' -d '{"name": "test4"}' ``` @@ -171,7 +172,7 @@ curl -X PUT http://XXXX.com/XXXX/testapp/thread/177916702949377 -H 'Authorizatio "duration": 4, "data": { "name": "test4" - } + }, "organization": "XXXX", "timestamp": 1650869972109, "uri": "http://XXXX.com/XXXX/testy/thread" @@ -219,7 +220,7 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example -```json +```shell curl -X DELETE http://XXXX.com/XXXX/testapp/thread/177916702949377 -H 'Authorization: Bearer ' ``` @@ -366,7 +367,7 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example -```json +```shell curl -X GET http://XXXX.com/XXXX/testapp/threads/user/test4 -H 'Authorization: Bearer ' ``` @@ -453,7 +454,7 @@ If the returned HTTP status code is not `200`, the request fails. You can refer #### Request example -```json +```shell curl -X GET http://XXXX.com/XXXX/testapp/threads/user/test4 -H 'Authorization: Bearer ' ```