From 8be9fffc31e7b6ba96d38a8ef15ae8a50eb2ebf7 Mon Sep 17 00:00:00 2001 From: zyjhandsome Date: Mon, 9 Jan 2023 19:51:29 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=8A=E9=80=9A=E7=9F=A5=E3=80=8B=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=86=85=E5=AE=B9=E4=BC=98=E5=8C=96=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=961=E4=B8=AA=E5=9B=BE=E7=89=87=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E5=AF=BC=E5=85=A5=E7=9A=84=E6=A8=A1=E5=9D=97=E4=B8=8E?= =?UTF-8?q?namespace=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zyjhandsome --- .../notification/notification-subscription.md | 21 +++--- .../notification/progress-bar-notification.md | 3 +- .../notification/text-notification.md | 4 +- .../apis/js-apis-notificationSubscribe.md | 68 +++++++------------ 4 files changed, 38 insertions(+), 58 deletions(-) diff --git a/zh-cn/application-dev/notification/notification-subscription.md b/zh-cn/application-dev/notification/notification-subscription.md index 9b4e787b50..e8200f3e3f 100644 --- a/zh-cn/application-dev/notification/notification-subscription.md +++ b/zh-cn/application-dev/notification/notification-subscription.md @@ -20,17 +20,16 @@ **表2** 通知订阅回调接口介绍 -| | | -| -------- | -------- | | **接口名** | **描述** | -| onConsume?:(data: SubscribeCallbackData) => void | 通知回调。 | -| onCancel?:(data: SubscribeCallbackData) => void | 通知取消回调。 | -| onUpdate?:(data: NotificationSortingMap) => void | 通知排序更新回调。 | -| onConnect?:() => void; | 订阅成功回调。 | -| onDisconnect?:() => void; | 取消订阅回调。 | -| onDestroy?:() => void | 与通知子系统断开回调。 | +| -------- | -------- | +| onConsume?:(data: SubscribeCallbackData) => void | 通知回调。 | +| onCancel?:(data: SubscribeCallbackData) => void | 通知取消回调。 | +| onUpdate?:(data: NotificationSortingMap) => void | 通知排序更新回调。 | +| onConnect?:() => void; | 订阅成功回调。 | +| onDisconnect?:() => void; | 取消订阅回调。 | +| onDestroy?:() => void | 与通知子系统断开回调。 | | onDoNotDisturbDateChange?:(mode: notification.DoNotDisturbDate) => void | 免打扰时间选项变更回调。 | -| onEnabledNotificationChanged?:(callbackData: EnabledNotificationCallbackData) => void | 通知开关变更回调。 | +| onEnabledNotificationChanged?:(callbackData: EnabledNotificationCallbackData) => void | 通知开关变更回调。 | ## 开发步骤 @@ -40,7 +39,7 @@ 2. 导入通知订阅模块。 ```ts - import NotificationSubscribe from '@ohos.notificationSubscribe'; + import notificationSubscribe from '@ohos.notificationSubscribe'; ``` 3. 创建订阅者对象。 @@ -73,7 +72,7 @@ 4. 发起通知订阅。 ```ts - NotificationSubscribe.subscribe(subscriber, (err, data) => { // callback形式调用异步接口 + notificationSubscribe.subscribe(subscriber, (err, data) => { // callback形式调用异步接口 if (err) { console.error(`[ANS] failed to subscribe, error[${err}]`); return; diff --git a/zh-cn/application-dev/notification/progress-bar-notification.md b/zh-cn/application-dev/notification/progress-bar-notification.md index 961753fc84..01eedfb58f 100644 --- a/zh-cn/application-dev/notification/progress-bar-notification.md +++ b/zh-cn/application-dev/notification/progress-bar-notification.md @@ -12,9 +12,8 @@ [isSupportTemplate()](../reference/apis/js-apis-notificationManager.md#notificationissupporttemplate)是查询模板是否支持接口,目前仅支持进度条模板。 -| | | -| -------- | -------- | | **接口名** | **描述** | +| -------- | -------- | | isSupportTemplate(templateName: string, callback: AsyncCallback<boolean>): void | 查询模板是否存在。 | diff --git a/zh-cn/application-dev/notification/text-notification.md b/zh-cn/application-dev/notification/text-notification.md index e1f8e3f6b8..e5aac8d662 100644 --- a/zh-cn/application-dev/notification/text-notification.md +++ b/zh-cn/application-dev/notification/text-notification.md @@ -16,8 +16,8 @@ 目前系统仅通知栏订阅了通知,将通知显示在通知栏里。基础类型通知呈现效果示意图如下所示。 - - **图1** 基础类型通知呈现效果示意图  ![zh-cn_image_0000001466462305](figures/zh-cn_image_0000001466462305.png) +**图1** 基础类型通知呈现效果示意图 +![zh-cn_image_0000001466462305](figures/zh-cn_image_0000001466462305.png) ## 接口说明 diff --git a/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md b/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md index cc3438f5a4..241039f313 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md @@ -9,7 +9,7 @@ ## 导入模块 ```js -import NotificationSubscribe from '@ohos.notificationSubscribe'; +import notificationSubscribe from '@ohos.notificationSubscribe'; ``` @@ -62,11 +62,9 @@ let subscriber = { let info = { bundleNames: ["bundleName1","bundleName2"] }; -NotificationSubscribe.subscribe(subscriber, info, subscribeCallback); +notificationSubscribe.subscribe(subscriber, info, subscribeCallback); ``` - - ## NotificationSubscribe.subscribe subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\): void @@ -110,7 +108,7 @@ function onConsumeCallback(data) { let subscriber = { onConsume: onConsumeCallback }; -NotificationSubscribe.subscribe(subscriber, subscribeCallback); +notificationSubscribe.subscribe(subscriber, subscribeCallback); ``` @@ -151,7 +149,7 @@ function onConsumeCallback(data) { let subscriber = { onConsume: onConsumeCallback }; -NotificationSubscribe.subscribe(subscriber).then(() => { +notificationSubscribe.subscribe(subscriber).then(() => { console.info("subscribe success"); }); ``` @@ -201,11 +199,9 @@ function onDisconnectCallback(data) { let subscriber = { onDisconnect: onDisconnectCallback }; -NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); +notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); ``` - - ## NotificationSubscribe.unsubscribe unsubscribe(subscriber: NotificationSubscriber): Promise\ @@ -241,13 +237,11 @@ function onDisconnectCallback(data) { let subscriber = { onDisconnect: onDisconnectCallback }; -NotificationSubscribe.unsubscribe(subscriber).then(() => { +notificationSubscribe.unsubscribe(subscriber).then(() => { console.info("unsubscribe success"); }); ``` - - ## NotificationSubscribe.remove remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason, callback: AsyncCallback\): void @@ -296,8 +290,8 @@ let notificationKey = { id: 0, label: "label", }; -let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; -NotificationSubscribe.remove(bundle, notificationKey, reason, removeCallback); +let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; +notificationSubscribe.remove(bundle, notificationKey, reason, removeCallback); ``` @@ -343,13 +337,11 @@ let notificationKey = { label: "label", }; let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; -NotificationSubscribe.remove(bundle, notificationKey, reason).then(() => { +notificationSubscribe.remove(bundle, notificationKey, reason).then(() => { console.info("remove success"); }); ``` - - ## NotificationSubscribe.remove remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\): void @@ -392,11 +384,9 @@ function removeCallback(err) { } } let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; -NotificationSubscribe.remove(hashCode, reason, removeCallback); +notificationSubscribe.remove(hashCode, reason, removeCallback); ``` - - ## NotificationSubscribe.remove remove(hashCode: string, reason: RemoveReason): Promise\ @@ -429,14 +419,12 @@ remove(hashCode: string, reason: RemoveReason): Promise\ ```js let hashCode = 'hashCode'; -let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; -NotificationSubscribe.remove(hashCode, reason).then(() => { +let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; +notificationSubscribe.remove(hashCode, reason).then(() => { console.info("remove success"); }); ``` - - ## NotificationSubscribe.removeAll removeAll(bundle: BundleOption, callback: AsyncCallback\): void @@ -481,8 +469,6 @@ let bundle = { NotificationSubscribe.removeAll(bundle, removeAllCallback); ``` - - ## NotificationSubscribe.removeAll removeAll(callback: AsyncCallback\): void @@ -520,11 +506,9 @@ function removeAllCallback(err) { } } -NotificationSubscribe.removeAll(removeAllCallback); +notificationSubscribe.removeAll(removeAllCallback); ``` - - ## NotificationSubscribe.removeAll removeAll(bundle?: BundleOption): Promise\ @@ -556,7 +540,7 @@ removeAll(bundle?: BundleOption): Promise\ ```js // 不指定应用时,删除所有通知 -NotificationSubscribe.removeAll().then(() => { +notificationSubscribe.removeAll().then(() => { console.info("removeAll success"); }); ``` @@ -602,7 +586,7 @@ function removeAllCallback(err) { let userId = 1; -NotificationSubscribe.removeAll(userId, removeAllCallback); +notificationSubscribe.removeAll(userId, removeAllCallback); ``` ## Notification.removeAll @@ -645,11 +629,9 @@ function removeAllCallback(err) { let userId = 1; -NotificationSubscribe.removeAll(userId, removeAllCallback); +notificationSubscribe.removeAll(userId, removeAllCallback); ``` - - ## NotificationSubscriber 作为订阅通知接口[subscribe](#notificationsubscribe)的入参,提供订阅者接收到新通知、取消通知等的回调方法。 @@ -693,7 +675,7 @@ let subscriber = { onConsume: onConsumeCallback }; -NotificationSubscribe.subscribe(subscriber, subscribeCallback); +notificationSubscribe.subscribe(subscriber, subscribeCallback); ``` ### onCancel @@ -733,7 +715,7 @@ let subscriber = { onCancel: onCancelCallback }; -NotificationSubscribe.subscribe(subscriber, subscribeCallback); +notificationSubscribe.subscribe(subscriber, subscribeCallback); ``` ### onUpdate @@ -771,7 +753,7 @@ let subscriber = { onUpdate: onUpdateCallback }; -NotificationSubscribe.subscribe(subscriber, subscribeCallback); +notificationSubscribe.subscribe(subscriber, subscribeCallback); ``` ### onConnect @@ -803,7 +785,7 @@ let subscriber = { onConnect: onConnectCallback }; -NotificationSubscribe.subscribe(subscriber, subscribeCallback); +notificationSubscribe.subscribe(subscriber, subscribeCallback); ``` ### onDisconnect @@ -847,9 +829,9 @@ let subscriber = { }; // 订阅通知后会收到onConnect回调 -NotificationSubscribe.subscribe(subscriber, subscribeCallback); +notificationSubscribe.subscribe(subscriber, subscribeCallback); // 取消订阅后会收到onDisconnect回调 -NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); +notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); ``` ### onDestroy @@ -881,7 +863,7 @@ let subscriber = { onDestroy: onDestroyCallback }; -NotificationSubscribe.subscribe(subscriber, subscribeCallback); +notificationSubscribe.subscribe(subscriber, subscribeCallback); ``` ### onDoNotDisturbDateChange @@ -919,7 +901,7 @@ let subscriber = { onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback }; -NotificationSubscribe.subscribe(subscriber, subscribeCallback); +notificationSubscribe.subscribe(subscriber, subscribeCallback); ``` @@ -960,7 +942,7 @@ let subscriber = { onEnabledNotificationChanged: onEnabledNotificationChangedCallback }; -NotificationSubscribe.subscribe(subscriber, subscribeCallback); +notificationSubscribe.subscribe(subscriber, subscribeCallback); ``` ## BundleOption -- GitLab