Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/.vuepress/sidebar/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ const documentSidebar = [
{ text: '修改消息', link: 'message_modify.html' },
{
text: '消息翻译',
collapsible: true,
children: [
{ text: '翻译消息内容', link: 'message_translation_text.html' },
{ text: '获取翻译语言列表', link: 'message_translation_language_list.html' },
Expand Down
49 changes: 10 additions & 39 deletions docs/document/flutter/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class _MyHomePageState extends State<MyHomePage> {

ScrollController scrollController = ScrollController();
String _username = "";
String _password = "";
String _token = "";
String _messageContent = "";
String _chatId = "";
final List<String> _logText = [];
Expand Down Expand Up @@ -127,8 +127,8 @@ class _MyHomePageState extends State<MyHomePage> {
onChanged: (username) => _username = username,
),
TextField(
decoration: const InputDecoration(hintText: "Enter password"),
onChanged: (password) => _password = password,
decoration: const InputDecoration(hintText: "Enter token"),
onChanged: (token) => _token = token,
),
const SizedBox(height: 10),
Row(
Expand Down Expand Up @@ -158,18 +158,6 @@ class _MyHomePageState extends State<MyHomePage> {
),
),
),
const SizedBox(width: 10),
Expanded(
child: TextButton(
onPressed: _signUp,
child: const Text("SIGN UP"),
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all(Colors.white),
backgroundColor:
MaterialStateProperty.all(Colors.lightBlue),
),
),
),
],
),
const SizedBox(height: 10),
Expand Down Expand Up @@ -218,9 +206,6 @@ class _MyHomePageState extends State<MyHomePage> {
void _signOut() async {
}

void _signUp() async {
}

void _sendMessage() async {
}

Expand All @@ -243,9 +228,9 @@ class _MyHomePageState extends State<MyHomePage> {

```dart
void _initSDK() async {
EMOptions options = EMOptions(
appKey: "<#Your AppKey#>",
autoLogin: false,
EMOptions options = EMOptions.withAppKey(
"<#Your AppKey#>",
autoLogin: false,
);
await EMClient.getInstance.init(options);
// 通知 SDK UI 已准备好。该方法执行后才会收到 `EMChatRoomEventHandler`、`EMContactEventHandler` 和 `EMGroupEventHandler` 回调。
Expand All @@ -259,19 +244,20 @@ void _initSDK() async {

在生产环境中,为了安全考虑,你需要在你的应用服务器集成 [获取 App Token API](/document/server-side/easemob_app_token.html) 和 [获取用户 Token API](/document/server-side/easemob_user_token.html) 实现获取 Token 的业务逻辑,使你的用户从你的应用服务器获取 Token。


### 添加登录

在 `_signIn` 方法中添加登录代码。

```dart
void _signIn() async {
if (_username.isEmpty || _password.isEmpty) {
_addLogToConsole("username or password is null");
if (_username.isEmpty || _token.isEmpty) {
_addLogToConsole("username or token is null");
return;
}

try {
await EMClient.getInstance.login(_username, _password);
await EMClient.getInstance.loginWithToken(_username, _token);
_addLogToConsole("sign in succeed, username: $_username");
} on EMError catch (e) {
_addLogToConsole("sign in failed, e: ${e.code} , ${e.description}");
Expand Down Expand Up @@ -445,18 +431,3 @@ flutter run
运行结果如下:

<img src="/images/flutter/simulator_screen_shot1.png" width="500" />

参考以下步骤发送和接收文本消息:

1. 输入任意用户名(如 `flutter001` 和 `flutter002`)和密码 `1`,点击 `SIGN UP` 创建用户;
2. 以 `flutter001` 身份登录 Demo,将 `Enter the username you want to send` 输如为 `flutter002`, 发送文本消息;

<img src="/images/flutter/simulator_screen_shot2.png" width="500" />

3. 以 `flutter002` 身份登录 Demo,查看 Log 信息确认是否都到消息。

<img src="/images/flutter/simulator_screen_shot3.png" width="500" />

## 后续步骤

为保障通信安全,在正式生产环境中,你需要在自己的 app 服务端生成 Token。详见[使用 App Token 鉴权](/product/easemob_app_token.html)。
4 changes: 3 additions & 1 deletion docs/document/server-side/message_translation_detect.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ POST https://{host}/{org_name}/{app_name}/translate/detect
如果返回的 HTTP 状态码为 `200`,表示请求成功,响应包体的 `data` 中包含以下字段:

| 参数 | 类型 | 描述 |
| :-------------- | :----- | :------- | --------------------------------- |
| :-------------- | :----- | :------- |
| `language` | String | 检测出的文本的目标语言。 |
| `score` | Int | 检测出的语言与实际相符的可能性。 |
| `isTranslationSupported` | String | 是否支持翻译该类语言的文本:<br/> - `true`:支持 <br/> - `false`:不支持 |

如果返回的 HTTP 状态码非 `200`,表示请求失败。你可以参考 [错误码](error.html) 了解可能的原因。

## 示例

### 请求示例
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
## HTTP 请求

```http
POST https://{host}/{org_name}/{app_name}/translate/support/language
GET https://{host}/{org_name}/{app_name}/translate/support/language
```

### 路径参数
Expand All @@ -50,19 +50,19 @@ POST https://{host}/{org_name}/{app_name}/translate/support/language
如果返回的 HTTP 状态码为 `200`,表示请求成功,响应包体中包含以下字段:

| 参数 | 类型 | 描述 |
| :-------------- | :----- | :------- | --------------------------------- |
| :-------------- | :----- | :------- |
| `code` | String | 语言代码。 |
| `name` | String | 语言名称。 |
| `nativeName` | String | 语言在其起源地的名称,例如,英语在英国称为 `English`。|

如果返回的 HTTP 状态码非 `200`,表示请求失败。你可以参考 [响应状态码](error.html) 了解可能的原因。
如果返回的 HTTP 状态码非 `200`,表示请求失败。你可以参考 [错误码](error.html) 了解可能的原因。

## 示例

### 请求示例

```shell
curl -i -X POST "https://XXXX/XXXX/XXXX/translate/support/language" \
curl -X GET "https://XXXX/XXXX/XXXX/translate/support/language" \
-H "Authorization: Bearer <YourAppToken>"
```

Expand Down
6 changes: 3 additions & 3 deletions docs/document/server-side/message_translation_text.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ POST https://{host}/{org_name}/{app_name}/translate
如果返回的 HTTP 状态码为 `200`,表示请求成功,响应包体中包含以下字段:

| 参数 | 类型 | 描述 |
| :-------------- | :----- | :------- | --------------------------------- |
| :-------------- | :----- | :------- |
| `translations` | JSON Array | 翻译结果。 |
| - `text` | String | 翻译后的文本。 |
| - `to` | String | 翻译目标语言的代码。|

如果返回的 HTTP 状态码非 `200`,表示请求失败。你可以参考 [响应状态码](error.html) 了解可能的原因。
如果返回的 HTTP 状态码非 `200`,表示请求失败。你可以参考 [错误码](error.html) 了解可能的原因。

## 示例

### 请求示例

```shell
curl -i -X POST "https://XXXX/XXXX/XXXX/translate" \
curl -X POST "https://XXXX/XXXX/XXXX/translate" \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer <YourAppToken>" \
-d '{
Expand Down
3 changes: 3 additions & 0 deletions docs/product/limitationapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ API 限流周期按照 UTC 时间计算,即当日的 00:00:00 至次日的 00:
| * 批量撤回消息 | POST | /{org_name}/{app_name}/messages/batch_recall | 100 次/秒/App Key | 100 次/秒 |
| 服务端单向删除会话 | DELETE | /{org_name}/{app_name}/users/{userName}/user_channel | 5 次/分钟/单用户 ID,100 次/秒/App Key | 100 次/秒 |
| 修改消息 | PUT | /{org_name}/{app_name}/messages/rewrite/{msg_id} | 100 次/秒/App Key | 50 条/秒 |
| 翻译消息内容 | POST | /{org_name}/{app_name}/translate | 100 次/秒/App Key | 50 条/秒 |
| 获取翻译语言列表 | GET | /{org_name}/{app_name}/translate/support/language | 100 次/秒/App Key | 50 条/秒 |
| 检测文本的源语言 | POST | /{org_name}/{app_name}/translate/detect | 100 次/秒/App Key | 50 条/秒 |
| 根据消息 ID 单向删除单聊漫游消息 | DELETE | /{org_name}/{app_name}/rest/message/roaming/chat/user/{userId}?userId={userId}&msgIdList={msgIdList} | 100 次/秒/App Key | 50 次/秒 |
| 根据消息 ID 单向删除群聊漫游消息 | DELETE | /{org_name}/{app_name}/rest/message/roaming/group/user/{userId}?groupId={groupId}&msgIdList={msgIdList} | 100 次/秒/App Key | |
| 单向清空指定用户的漫游消息 | POST | /{org_name}/{app_name}/rest/message/roaming/user/{userId}/delete/all | 100 次/秒/App Key | 100 次/秒 |
Expand Down
6 changes: 6 additions & 0 deletions docs/product/product_dynamics.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 产品动态

## 2025-07

| 动态名称 | 动态描述 | 发布时间 | 相关文档 |
| :----- | :------- | :---------------- | :---------------- |
| 消息翻译 RESTful API | 消息翻译支持以下三个 RESTful API:<br/> - 翻译消息内容 <br/> - 获取翻译语言列表 <br/> - 检测文本的源语言 | 2025-7-2 | <br/> - [翻译消息内容](/document/server-side/message_translation_text.html) <br/> - [获取翻译语言列表](/document/server-side/message_translation_language_list.html) <br/> - [检测文本的源语言](/document/server-side/message_translation_detect.html) |

## 2025-06

#### Android/iOS SDK 4.15.1 发版
Expand Down
Loading