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/send-receive-messages/project-implementation/android.mdx b/shared/chat-sdk/client-api/messages/send-receive-messages/project-implementation/android.mdx index 396708555..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 conversationId the user ID of the message recipient. +// 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 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. +// Set `ChatType` as `Chat`, `GroupChat`, or `ChatRoom` for one-to-one chat, group chat, or room chat. message.setChatType(ChatMessage.GroupChat); - // Send the message + // 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() { @@ -52,7 +54,7 @@ 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 MessageListener msgListener = new MessageListener() { 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 96bf5c74d..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. 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 83fe8940c..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,14 +10,14 @@ 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 = AC.message.create(option); - // Call send to send the message + // Call `send` to send the message conn.send(msg).then((res)=>{ console.log("Send message success",res); }).catch((e)=>{ 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/reference/_http-status-codes.mdx b/shared/chat-sdk/reference/_http-status-codes.mdx index 0023473aa..9c8d9131b 100644 --- a/shared/chat-sdk/reference/_http-status-codes.mdx +++ b/shared/chat-sdk/reference/_http-status-codes.mdx @@ -63,6 +63,9 @@ This status code indicates that the API request is rejected by the server due to | `403` | `forbidden_op` | "Forbidden operation on group owner!" | The error message returned because the specified operation cannot be performed on chat group owners, such as adding the chat group owner to block list. | | `403` | `forbidden_op` | "Can not join this group, reason:user: `{username}` has joined too many groups/chatroom!" | The error message returned because the number of chat groups or chat rooms joined by a user has reached the limit. | | `403` | `forbidden_op` | "This appKey has create too many groups/chatrooms!" | The number of chat groups or chat rooms created by using an App key has reached the limit. For details, see [Pricing plans](../reference/pricing-plan-details). | +| `403` | `exceed_limit` | "Invitee's contact max count" | The user receiving the friend request has reached the maximum number of contacts allowed.| +| `403` | `exceed_limit` | "Inviter's contact max count" | The user sending the friend request has reached the maximum number of contacts allowed. | + ### 404 Not Found This status code indicates that the specified resources of the API request could not be found by the server.