未验证 提交 fe8d03f8 编写于 作者: O openharmony_ci 提交者: Gitee

!2569 通知接口文档修改

Merge pull request !2569 from FangJinliang/br_333
...@@ -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的接口完成通知订阅、取消订阅、发布通知、取消通知功能。
......
...@@ -185,7 +185,7 @@ Notification.cancel(0, "label", cancelCallback) ...@@ -185,7 +185,7 @@ Notification.cancel(0, "label", cancelCallback)
## Notification.cancel ## Notification.cancel
cancel(id:number, label?string): Promise\<void\> cancel(id:number, label?: string): Promise\<void\>
取消与指定id相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。 取消与指定id相匹配的已发布通知,label可以指定也可以不指定(Promise形式)。
...@@ -2109,7 +2109,7 @@ Notification.supportDoNotDisturbMode().then((data) => { ...@@ -2109,7 +2109,7 @@ Notification.supportDoNotDisturbMode().then((data) => {
isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): void isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): void
查询模板是否存在。 查询模板是否存在(Callback形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2137,7 +2137,7 @@ Notification.isSupportTemplate(templateName, isSupportTemplateCallback); ...@@ -2137,7 +2137,7 @@ Notification.isSupportTemplate(templateName, isSupportTemplateCallback);
isSupportTemplate(templateName: string): Promise\<boolean\> isSupportTemplate(templateName: string): Promise\<boolean\>
查询模板是否存在。 查询模板是否存在(Promise形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2169,7 +2169,7 @@ Notification.isSupportTemplate(templateName).then((data) => { ...@@ -2169,7 +2169,7 @@ Notification.isSupportTemplate(templateName).then((data) => {
requestEnableNotification(callback: AsyncCallback\<void\>): void requestEnableNotification(callback: AsyncCallback\<void\>): void
应用请求通知使能。 应用请求通知使能(Callback形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2195,7 +2195,7 @@ Notification.requestEnabledNotification(requestEnabledNotificationCallback); ...@@ -2195,7 +2195,7 @@ Notification.requestEnabledNotification(requestEnabledNotificationCallback);
requestEnableNotification(): Promise\<void\> requestEnableNotification(): Promise\<void\>
应用请求通知使能。 应用请求通知使能(Promise形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2213,7 +2213,7 @@ Notification.requestEnableNotification() ...@@ -2213,7 +2213,7 @@ Notification.requestEnableNotification()
enableDistributed(enable: boolean, callback: AsyncCallback\<void\>): void enableDistributed(enable: boolean, callback: AsyncCallback\<void\>): void
设置设备是否支持分布式通知。 设置设备是否支持分布式通知(Callback形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2242,7 +2242,7 @@ Notification.enableDistributed(enable, enabledNotificationCallback); ...@@ -2242,7 +2242,7 @@ Notification.enableDistributed(enable, enabledNotificationCallback);
enableDistributed(enable: boolean): Promise\<void> enableDistributed(enable: boolean): Promise\<void>
设置设备是否支持分布式通知。 设置设备是否支持分布式通知(Promise形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2268,7 +2268,7 @@ Notification.enableDistributed(enable) ...@@ -2268,7 +2268,7 @@ Notification.enableDistributed(enable)
isDistributedEnabled(callback: AsyncCallback\<boolean>): void isDistributedEnabled(callback: AsyncCallback\<boolean>): void
获取设备是否支持分布式通知。 获取设备是否支持分布式通知(Callback形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2294,7 +2294,7 @@ Notification.enableDistributed(isDistributedEnabledCallback); ...@@ -2294,7 +2294,7 @@ Notification.enableDistributed(isDistributedEnabledCallback);
isDistributedEnabled(): Promise\<boolean> isDistributedEnabled(): Promise\<boolean>
获取设备是否支持分布式通知。 获取设备是否支持分布式通知(Promise形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2318,7 +2318,7 @@ Notification.isDistributedEnabled() ...@@ -2318,7 +2318,7 @@ Notification.isDistributedEnabled()
enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void
根据应用的包设置应用程序是否支持分布式通知。 根据应用的包设置应用程序是否支持分布式通知(Callback形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2352,7 +2352,7 @@ Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundle ...@@ -2352,7 +2352,7 @@ Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundle
根据bundleenableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise<void> 根据bundleenableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise<void>
根据应用的包设置应用程序是否支持分布式通知。 根据应用的包设置应用程序是否支持分布式通知(Promise形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2382,7 +2382,7 @@ Notification.enableDistributedByBundle(bundle, enable) ...@@ -2382,7 +2382,7 @@ Notification.enableDistributedByBundle(bundle, enable)
isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void
根据应用的包获取应用程序是否支持分布式通知。 根据应用的包获取应用程序是否支持分布式通知(Callback形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2413,7 +2413,7 @@ Notification.enableDistributedByBundle(bundle, isDistributedEnabledByBundleCallb ...@@ -2413,7 +2413,7 @@ Notification.enableDistributedByBundle(bundle, isDistributedEnabledByBundleCallb
isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean> isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
根据应用的包获取应用程序是否支持分布式通知。 根据应用的包获取应用程序是否支持分布式通知(Promise形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2447,7 +2447,7 @@ Notification.isDistributedEnabledByBundle(bundle) ...@@ -2447,7 +2447,7 @@ Notification.isDistributedEnabledByBundle(bundle)
getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
获取通知的提醒方式。 获取通知的提醒方式(Callback形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2473,7 +2473,7 @@ Notification.getDeviceRemindType(getDeviceRemindTypeCallback); ...@@ -2473,7 +2473,7 @@ Notification.getDeviceRemindType(getDeviceRemindTypeCallback);
getDeviceRemindType(): Promise\<DeviceRemindType\> getDeviceRemindType(): Promise\<DeviceRemindType\>
获取通知的提醒方式。 获取通知的提醒方式(Promise形式)
**系统能力**:SystemCapability.Notification.Notification **系统能力**:SystemCapability.Notification.Notification
...@@ -2852,9 +2852,9 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -2852,9 +2852,9 @@ Notification.subscribe(subscriber, subscribeCallback);
| --------------------------------- | ----------- | ------------------ | | --------------------------------- | ----------- | ------------------ |
| LEVEL_NONE | 0 | 表示关闭通知功能。 | | LEVEL_NONE | 0 | 表示关闭通知功能。 |
| LEVEL_MIN | 1 | 启用通知功能,但通知不启用。 | | LEVEL_MIN | 1 | 启用通知功能,但通知不启用。 |
| LEVEL_LOW | 2 | 通知和通止功能都启用。 | | LEVEL_LOW | 2 | 通知和通知功能都启用。 |
| LEVEL_DEFAULT | 3 | 通知和通止功能都启用。 | | LEVEL_DEFAULT | 3 | 通知和通知功能都启用。 |
| LEVEL_HIGH | 4 | 通知和通止功能都启用。 | | LEVEL_HIGH | 4 | 通知和通知功能都启用。 |
## BundleOption ## BundleOption
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册