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
+ 112.4.3
@@ -88,6 +91,18 @@ The following figure shows the API call sequence of generating an Agora Chat tok
commons-codec1.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