提交 8eb02673 编写于 作者: F fangjinliang

document modify

Signed-off-by: Nfangjinliang <fangjinliang1@huawei.com>
上级 c2f1522e
...@@ -131,33 +131,7 @@ var subscriber = { ...@@ -131,33 +131,7 @@ var subscriber = {
### 通知发送 ### 通知发送
通知发布前,先查询应用通知使能开关是否打开,新安装的应用使能默认是关闭状态。 通知发布前,先要确认通知发送使能是否开启,新安装的应用使能默认是关闭状态,需要到通知设置里开启。
##### 开启通知使能
先查询通知使能
```js
var bundle = {
bundle: "bundleName1",
}
Notification.isNotificationEnabled(bundle).then((data) => {
console.info("===>isNotificationEnabled success===>");
});
```
若使能为false关闭状态,需要开启使能
```js
var bundle = {
bundle: "bundleName1",
}
Notification.enableNotification(bundle, true, async(err) => {
console.log("===>enableNotification success===>");
});
```
##### 通知发布 ##### 通知发布
...@@ -170,7 +144,7 @@ Notification.enableNotification(bundle, true, async(err) => { ...@@ -170,7 +144,7 @@ Notification.enableNotification(bundle, true, async(err) => {
var notificationRequest = { var notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: "test_title", title: "test_title",
text: "test_text", text: "test_text",
...@@ -197,25 +171,18 @@ wantAgent使用详见[wantAgent开发文档](https://gitee.com/openharmony/docs/ ...@@ -197,25 +171,18 @@ wantAgent使用详见[wantAgent开发文档](https://gitee.com/openharmony/docs/
```js ```js
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.wantAgent';
import { OperationType, Flags } from '@ohos.wantagent';
//WantAgentInfo对象 //WantAgentInfo对象
var wantAgentInfo = { var wantAgentInfo = {
wants: [ wants: [
{ {
deviceId: 'deviceId', bundleName: 'ohos.samples.eTSNotification',
bundleName: 'com.example.myapplication', abilityName: 'ohos.samples.eTSNotification.MainAbility',
abilityName: 'com.example.myapplication.MainAbility', }
action: 'REMINDER_EVENT_REMOVE_NOTIFICATION', ],
entities: ['entity1'], operationType: wantAgent.OperationType.START_ABILITY,
type: 'MIMETYPE', requestCode: 0,
uri: 'key={true,true,false}', wantAgentFlags:[wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
parameters: { myKey0: 1111 },
}
],
operationType: OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[Flags.UPDATE_PRESENT_FLAG]
} }
//wantAgent对象 //wantAgent对象
...@@ -241,7 +208,7 @@ wantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) ...@@ -241,7 +208,7 @@ wantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
//构造NotificationRequest对象 //构造NotificationRequest对象
var notificationRequest = { var notificationRequest = {
content: { content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: "AceApplication_Title", title: "AceApplication_Title",
text: "AceApplication_Text", text: "AceApplication_Text",
...@@ -251,7 +218,7 @@ var notificationRequest = { ...@@ -251,7 +218,7 @@ var notificationRequest = {
id: 1, id: 1,
label: 'TEST', label: 'TEST',
wantAgent: WantAgent, wantAgent: WantAgent,
slotType: notify.SlotType.OTHER_TYPES, slotType: Notification.SlotType.OTHER_TYPES,
deliveryTime: new Date().getTime() deliveryTime: new Date().getTime()
} }
...@@ -284,9 +251,9 @@ Notification.cancel(1, "label", cancelCallback) ...@@ -284,9 +251,9 @@ Notification.cancel(1, "label", cancelCallback)
针对通知开发,有以下示例工程可供参考: 针对通知开发,有以下示例工程可供参考:
- notification - [Notification](https://gitee.com/openharmony/app_samples/tree/master/Notification/Notification)
本示例展示了在eTS中如何使用Notification的接口完成通知订阅、取消订阅、发布通知、取消通知、查询和开启通知使能功能。 本示例展示了在eTS中如何使用Notification的接口完成通知订阅、取消订阅、发布通知、取消通知功能。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册