提交 8be9fffc 编写于 作者: zyjhandsome's avatar zyjhandsome

《通知》相关内容优化,优化1个图片格式,导入的模块与namespace保持一致。

Signed-off-by: zyjhandsome's avatarzyjhandsome <zyjhandsome@126.com>
上级 b6aa70ca
...@@ -20,9 +20,8 @@ ...@@ -20,9 +20,8 @@
**表2** 通知订阅回调接口介绍 **表2** 通知订阅回调接口介绍
| | |
| -------- | -------- |
| **接口名** | **描述** | | **接口名** | **描述** |
| -------- | -------- |
| onConsume?:(data:&nbsp;SubscribeCallbackData)&nbsp;=&gt;&nbsp;void | 通知回调。 | | onConsume?:(data:&nbsp;SubscribeCallbackData)&nbsp;=&gt;&nbsp;void | 通知回调。 |
| onCancel?:(data:&nbsp;SubscribeCallbackData)&nbsp;=&gt;&nbsp;void | 通知取消回调。 | | onCancel?:(data:&nbsp;SubscribeCallbackData)&nbsp;=&gt;&nbsp;void | 通知取消回调。 |
| onUpdate?:(data:&nbsp;NotificationSortingMap)&nbsp;=&gt;&nbsp;void | 通知排序更新回调。 | | onUpdate?:(data:&nbsp;NotificationSortingMap)&nbsp;=&gt;&nbsp;void | 通知排序更新回调。 |
...@@ -40,7 +39,7 @@ ...@@ -40,7 +39,7 @@
2. 导入通知订阅模块。 2. 导入通知订阅模块。
```ts ```ts
import NotificationSubscribe from '@ohos.notificationSubscribe'; import notificationSubscribe from '@ohos.notificationSubscribe';
``` ```
3. 创建订阅者对象。 3. 创建订阅者对象。
...@@ -73,7 +72,7 @@ ...@@ -73,7 +72,7 @@
4. 发起通知订阅。 4. 发起通知订阅。
```ts ```ts
NotificationSubscribe.subscribe(subscriber, (err, data) => { // callback形式调用异步接口 notificationSubscribe.subscribe(subscriber, (err, data) => { // callback形式调用异步接口
if (err) { if (err) {
console.error(`[ANS] failed to subscribe, error[${err}]`); console.error(`[ANS] failed to subscribe, error[${err}]`);
return; return;
......
...@@ -12,9 +12,8 @@ ...@@ -12,9 +12,8 @@
[isSupportTemplate()](../reference/apis/js-apis-notificationManager.md#notificationissupporttemplate)是查询模板是否支持接口,目前仅支持进度条模板。 [isSupportTemplate()](../reference/apis/js-apis-notificationManager.md#notificationissupporttemplate)是查询模板是否支持接口,目前仅支持进度条模板。
| | |
| -------- | -------- |
| **接口名** | **描述** | | **接口名** | **描述** |
| -------- | -------- |
| isSupportTemplate(templateName:&nbsp;string,&nbsp;callback:&nbsp;AsyncCallback&lt;boolean&gt;):&nbsp;void | 查询模板是否存在。 | | isSupportTemplate(templateName:&nbsp;string,&nbsp;callback:&nbsp;AsyncCallback&lt;boolean&gt;):&nbsp;void | 查询模板是否存在。 |
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
目前系统仅通知栏订阅了通知,将通知显示在通知栏里。基础类型通知呈现效果示意图如下所示。 目前系统仅通知栏订阅了通知,将通知显示在通知栏里。基础类型通知呈现效果示意图如下所示。
**图1** 基础类型通知呈现效果示意图
**图1** 基础类型通知呈现效果示意图  ![zh-cn_image_0000001466462305](figures/zh-cn_image_0000001466462305.png) ![zh-cn_image_0000001466462305](figures/zh-cn_image_0000001466462305.png)
## 接口说明 ## 接口说明
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
## 导入模块 ## 导入模块
```js ```js
import NotificationSubscribe from '@ohos.notificationSubscribe'; import notificationSubscribe from '@ohos.notificationSubscribe';
``` ```
...@@ -62,11 +62,9 @@ let subscriber = { ...@@ -62,11 +62,9 @@ let subscriber = {
let info = { let info = {
bundleNames: ["bundleName1","bundleName2"] bundleNames: ["bundleName1","bundleName2"]
}; };
NotificationSubscribe.subscribe(subscriber, info, subscribeCallback); notificationSubscribe.subscribe(subscriber, info, subscribeCallback);
``` ```
## NotificationSubscribe.subscribe ## NotificationSubscribe.subscribe
subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
...@@ -110,7 +108,7 @@ function onConsumeCallback(data) { ...@@ -110,7 +108,7 @@ function onConsumeCallback(data) {
let subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
...@@ -151,7 +149,7 @@ function onConsumeCallback(data) { ...@@ -151,7 +149,7 @@ function onConsumeCallback(data) {
let subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
NotificationSubscribe.subscribe(subscriber).then(() => { notificationSubscribe.subscribe(subscriber).then(() => {
console.info("subscribe success"); console.info("subscribe success");
}); });
``` ```
...@@ -201,11 +199,9 @@ function onDisconnectCallback(data) { ...@@ -201,11 +199,9 @@ function onDisconnectCallback(data) {
let subscriber = { let subscriber = {
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
}; };
NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
``` ```
## NotificationSubscribe.unsubscribe ## NotificationSubscribe.unsubscribe
unsubscribe(subscriber: NotificationSubscriber): Promise\<void\> unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
...@@ -241,13 +237,11 @@ function onDisconnectCallback(data) { ...@@ -241,13 +237,11 @@ function onDisconnectCallback(data) {
let subscriber = { let subscriber = {
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
}; };
NotificationSubscribe.unsubscribe(subscriber).then(() => { notificationSubscribe.unsubscribe(subscriber).then(() => {
console.info("unsubscribe success"); console.info("unsubscribe success");
}); });
``` ```
## NotificationSubscribe.remove ## NotificationSubscribe.remove
remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason, callback: AsyncCallback\<void\>): void remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason, callback: AsyncCallback\<void\>): void
...@@ -296,8 +290,8 @@ let notificationKey = { ...@@ -296,8 +290,8 @@ let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
}; };
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(bundle, notificationKey, reason, removeCallback); notificationSubscribe.remove(bundle, notificationKey, reason, removeCallback);
``` ```
...@@ -343,13 +337,11 @@ let notificationKey = { ...@@ -343,13 +337,11 @@ let notificationKey = {
label: "label", label: "label",
}; };
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(bundle, notificationKey, reason).then(() => { notificationSubscribe.remove(bundle, notificationKey, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
``` ```
## NotificationSubscribe.remove ## NotificationSubscribe.remove
remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): void remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): void
...@@ -392,11 +384,9 @@ function removeCallback(err) { ...@@ -392,11 +384,9 @@ function removeCallback(err) {
} }
} }
let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
NotificationSubscribe.remove(hashCode, reason, removeCallback); notificationSubscribe.remove(hashCode, reason, removeCallback);
``` ```
## NotificationSubscribe.remove ## NotificationSubscribe.remove
remove(hashCode: string, reason: RemoveReason): Promise\<void\> remove(hashCode: string, reason: RemoveReason): Promise\<void\>
...@@ -429,14 +419,12 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\> ...@@ -429,14 +419,12 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\>
```js ```js
let hashCode = 'hashCode'; let hashCode = 'hashCode';
let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(hashCode, reason).then(() => { notificationSubscribe.remove(hashCode, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
...@@ -481,8 +469,6 @@ let bundle = { ...@@ -481,8 +469,6 @@ let bundle = {
NotificationSubscribe.removeAll(bundle, removeAllCallback); NotificationSubscribe.removeAll(bundle, removeAllCallback);
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
removeAll(callback: AsyncCallback\<void\>): void removeAll(callback: AsyncCallback\<void\>): void
...@@ -520,11 +506,9 @@ function removeAllCallback(err) { ...@@ -520,11 +506,9 @@ function removeAllCallback(err) {
} }
} }
NotificationSubscribe.removeAll(removeAllCallback); notificationSubscribe.removeAll(removeAllCallback);
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
removeAll(bundle?: BundleOption): Promise\<void\> removeAll(bundle?: BundleOption): Promise\<void\>
...@@ -556,7 +540,7 @@ removeAll(bundle?: BundleOption): Promise\<void\> ...@@ -556,7 +540,7 @@ removeAll(bundle?: BundleOption): Promise\<void\>
```js ```js
// 不指定应用时,删除所有通知 // 不指定应用时,删除所有通知
NotificationSubscribe.removeAll().then(() => { notificationSubscribe.removeAll().then(() => {
console.info("removeAll success"); console.info("removeAll success");
}); });
``` ```
...@@ -602,7 +586,7 @@ function removeAllCallback(err) { ...@@ -602,7 +586,7 @@ function removeAllCallback(err) {
let userId = 1; let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback); notificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
## Notification.removeAll ## Notification.removeAll
...@@ -645,11 +629,9 @@ function removeAllCallback(err) { ...@@ -645,11 +629,9 @@ function removeAllCallback(err) {
let userId = 1; let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback); notificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
## NotificationSubscriber ## NotificationSubscriber
作为订阅通知接口[subscribe](#notificationsubscribe)的入参,提供订阅者接收到新通知、取消通知等的回调方法。 作为订阅通知接口[subscribe](#notificationsubscribe)的入参,提供订阅者接收到新通知、取消通知等的回调方法。
...@@ -693,7 +675,7 @@ let subscriber = { ...@@ -693,7 +675,7 @@ let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onCancel ### onCancel
...@@ -733,7 +715,7 @@ let subscriber = { ...@@ -733,7 +715,7 @@ let subscriber = {
onCancel: onCancelCallback onCancel: onCancelCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onUpdate ### onUpdate
...@@ -771,7 +753,7 @@ let subscriber = { ...@@ -771,7 +753,7 @@ let subscriber = {
onUpdate: onUpdateCallback onUpdate: onUpdateCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onConnect ### onConnect
...@@ -803,7 +785,7 @@ let subscriber = { ...@@ -803,7 +785,7 @@ let subscriber = {
onConnect: onConnectCallback onConnect: onConnectCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onDisconnect ### onDisconnect
...@@ -847,9 +829,9 @@ let subscriber = { ...@@ -847,9 +829,9 @@ let subscriber = {
}; };
// 订阅通知后会收到onConnect回调 // 订阅通知后会收到onConnect回调
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
// 取消订阅后会收到onDisconnect回调 // 取消订阅后会收到onDisconnect回调
NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
``` ```
### onDestroy ### onDestroy
...@@ -881,7 +863,7 @@ let subscriber = { ...@@ -881,7 +863,7 @@ let subscriber = {
onDestroy: onDestroyCallback onDestroy: onDestroyCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onDoNotDisturbDateChange ### onDoNotDisturbDateChange
...@@ -919,7 +901,7 @@ let subscriber = { ...@@ -919,7 +901,7 @@ let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
...@@ -960,7 +942,7 @@ let subscriber = { ...@@ -960,7 +942,7 @@ let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback onEnabledNotificationChanged: onEnabledNotificationChangedCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
## BundleOption ## BundleOption
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册