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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions docs/.vuepress/sidebar/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,16 @@ const documentSidebar = [
{ text: '发送推送 token 到环信服务器', link: 'push/push_send_token_to_server.html', only: ['react-native'] },
{ text: '解析推送消息', link: 'push/push_parsing.html', only: ['android', 'ios'] },
{ text: '统一获取消息方案', link: 'push/push_parsing_unified.html', only: ['android'] },
{ text: '设置通知的显示内容', link: 'push/push_display.html', only: ['android', 'ios', 'harmonyos', 'react-native', 'flutter'] },
{ text: '设置通知的显示内容',
children: [
{ text: '概述', link: 'push/push_display_overview.html', except: ['harmonyos']},
{ text: '设置推送通知的显示属性', link: 'push/push_display_attribute.html' },
{ text: '使用消息扩展字段', link: 'push/push_display_field.html', except: ['harmonyos']},
],
only: ['android', 'ios', 'harmonyos', 'react-native', 'flutter']
},
{ text: '设置通知方式和免打扰', link: 'push/push_notification_mode_dnd.html', only: ['android', 'ios', 'web', 'harmonyos', 'react-native', 'flutter']},
{ text: '设置推送模板', link: 'push/push_template.html', only: ['web']},
{ text: '设置推送模板', link: 'push/push_template.html', only: ['android', 'ios', 'web', 'harmonyos', 'react-native', 'flutter']},
{ text: '设置推送翻译', link: 'push/push_translation.html', only: ['android', 'ios', 'web', 'react-native', 'flutter']},
{ text: '设置推送扩展功能', link: 'push/push_extension.html', only: ['android', 'ios', 'web', 'react-native', 'flutter']},
{ text: '推送消息分类', link: 'push/push_message_classification.html', only: ['android'] },
Expand Down
243 changes: 0 additions & 243 deletions docs/document/android/push/push_display.md

This file was deleted.

48 changes: 48 additions & 0 deletions docs/document/android/push/push_display_attribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 设置和获取推送通知的显示属性

## 设置推送通知的显示属性

调用 `updatePushNickname` 方法设置推送通知中显示的昵称,如以下代码示例所示:

```java
// 需要异步处理。
EMClient.getInstance().pushManager().updatePushNickname("pushNickname");
```

调用 `updatePushDisplayStyle` 设置推送通知的显示样式,如下代码示例所示:

```java
// 设置为简单样式。
EMPushManager.DisplayStyle displayStyle = EMPushManager.DisplayStyle.SimpleBanner;
// 需要异步处理。
EMClient.getInstance().pushManager().updatePushDisplayStyle(displayStyle);
```

若要在通知栏中显示消息内容,需要设置通知显示样式 `DisplayStyle`。`DisplayStyle` 是枚举类型,有如下两种设置:

| 参数值 | 描述 |
| :--------------- | :---------------------- |
| (默认)`SimpleBanner` | 不论 `nickname` 是否设置,对于推送任何类型的消息,通知栏采用默认显示设置,即推送标题为**您有一条新消息**,推送内容为**请点击查看**。 |
| `MessageSummary` | `MessageSummary`:显示消息内容。设置的昵称只在 `DisplayStyle` 为 `MessageSummary` 时生效,在 `SimpleBanner` 时不生效。 |

下表以**单聊文本消息**为例介绍显示属性的设置。

对于**群聊**,下表中的**消息发送方的推送昵称**和**消息发送方的 IM 用户 ID**显示为**群组 ID**。

| 参数设置 | 推送显示 | 图片 |
| :--------- | :----- |:------------- |
| <br/> - `DisplayStyle`:(默认)`SimpleBanner`<br/> - `nickname`:设置或不设置 | <br/> - 推送标题:**您有一条新消息**<br/> - 推送内容:**请点击查看** | ![img](/images/android/push/push_displayattribute_1.png)|
| <br/> - `DisplayStyle`:`MessageSummary`<br/> - `nickname`:设置具体值 | <br/> - 推送标题:**您有一条新消息**<br/> - 推送内容:**消息发送方的推送昵称:消息内容** |![img](/images/android/push/push_displayattribute_2.png) |
| <br/> - `DisplayStyle`:`MessageSummary`<br/> - `nickname`:不设置 | <br/> - 推送标题:**您有一条新消息**<br/> - 推送内容:**消息发送方的 IM 用户 ID: 消息内容** | ![img](/images/android/push/push_displayattribute_3.png)|

## 获取推送通知的显示属性

你可以调用 `getPushConfigsFromServer` 获取推送通知中的显示属性,如以下代码示例所示:

```java
EMPushConfigs pushConfigs = EMClient.getInstance().pushManager().getPushConfigsFromServer();
// 获取推送显示昵称。
String nickname = pushConfigs.getDisplayNickname();
// 获取推送通知的显示样式。
EMPushManager.DisplayStyle style = pushConfigs.getDisplayStyle();
```
34 changes: 34 additions & 0 deletions docs/document/android/push/push_display_field.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 使用消息扩展字段设置推送通知显示内容

创建推送消息时,你可以设置消息扩展字段自定义要显示的推送标题 `em_push_title` 和推送内容 `em_push_content`。

```java
// 这里以文本消息为例,附件等类型的消息设置方法相同。
EMMessage message = EMMessage.createSendMessage(EMMessage.Type.TXT);
EMTextMessageBody txtBody = new EMTextMessageBody("message content");
// 设置要发送用户的用户 ID。
message.setTo("toChatUsername");
// 设置自定义推送提示。
JSONObject extObject = new JSONObject();
try {
extObject.put("em_push_title", "custom push title");
extObject.put("em_push_content", "custom push content");
} catch (JSONException e) {
e.printStackTrace();
}
// 将推送扩展设置到消息中。
message.setAttribute("em_apns_ext", extObject);
// 设置消息体。
message.addBody(txtBody);
// 设置消息回调。
message.setMessageStatusCallback(new CallBack() {...});
// 发送消息。
EMClient.getInstance().chatManager().sendMessage(message);
```

| 参数 | 描述 |
| :---------------- | :----------- |
| `toChatUsername` | 消息接收方 ID。 |
| `em_apns_ext` | 消息扩展,使用扩展的方式向推送中添加自定义字段,该值为固定值,不可修改。 |
| `em_push_title` | 自定义字段 key,用于设置自定义的标题,该值为固定值,不可修改。 |
| `em_push_content` | 自定义字段 key,用于设置自定义的内容,该值为固定值,不可修改。 |
13 changes: 13 additions & 0 deletions docs/document/android/push/push_display_overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 设置推送通知的显示内容

通知收到后,通知栏中显示的推送标题和内容可通过以下方式设置,配置的优先级为由低到高:

1. [**设置推送通知的显示属性**](push_display_attribute.html):使用默认的推送标题和内容,即推送通知的展示方式 `DisplayStyle` 采用默认的值(`SimpleBanner`)。推送标题为**您有一条新消息**,推送内容为**请点击查看**。
2. [**使用默认推送模板**](push_template.html#编辑默认推送模板):若有默认模板 `default`,发消息时无需指定。
3. [**使用消息扩展字段**](push_display_field.html):使用扩展字段自定义要显示的推送标题和推送内容,即 `em_push_title` 和 `em_push_content`。
4. [**接收方设置了推送模板**](push_template.html#消息接收方使用推送模板)。
5. [**使用自定义推送模板**](push_template.html#):发送消息时通过消息扩展字段指定推送模板名称。

:::tip
推送模板为离线推送的高级功能,使用前需要 [在环信控制台开启](push_template.html#开通服务)。
:::
2 changes: 1 addition & 1 deletion docs/document/android/push/push_extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

你可以利用扩展字段实现自定义推送设置,本文以强制推送和发送静默消息为例介绍如何实现推送扩展功能。

对于推送扩展字段,详见[离线推送扩展字段文档](/document/server-side/push_extension.html)。
对于推送扩展字段,详见 [离线推送扩展字段文档](/document/server-side/push_extension.html)。

## 设置自定义推送字段

Expand Down
Loading