Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
8be9fffc
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8be9fffc
编写于
1月 09, 2023
作者:
zyjhandsome
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
《通知》相关内容优化,优化1个图片格式,导入的模块与namespace保持一致。
Signed-off-by:
zyjhandsome
<
zyjhandsome@126.com
>
上级
b6aa70ca
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
58 deletion
+38
-58
zh-cn/application-dev/notification/notification-subscription.md
...application-dev/notification/notification-subscription.md
+10
-11
zh-cn/application-dev/notification/progress-bar-notification.md
...application-dev/notification/progress-bar-notification.md
+1
-2
zh-cn/application-dev/notification/text-notification.md
zh-cn/application-dev/notification/text-notification.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md
...ation-dev/reference/apis/js-apis-notificationSubscribe.md
+25
-43
未找到文件。
zh-cn/application-dev/notification/notification-subscription.md
浏览文件 @
8be9fffc
...
...
@@ -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
N
otificationSubscribe
from
'
@ohos.notificationSubscribe
'
;
import
n
otificationSubscribe
from
'
@ohos.notificationSubscribe
'
;
```
3.
创建订阅者对象。
...
...
@@ -73,7 +72,7 @@
4.
发起通知订阅。
```
ts
N
otificationSubscribe
.
subscribe
(
subscriber
,
(
err
,
data
)
=>
{
// callback形式调用异步接口
n
otificationSubscribe
.
subscribe
(
subscriber
,
(
err
,
data
)
=>
{
// callback形式调用异步接口
if
(
err
)
{
console
.
error
(
`[ANS] failed to subscribe, error[
${
err
}
]`
);
return
;
...
...
zh-cn/application-dev/notification/progress-bar-notification.md
浏览文件 @
8be9fffc
...
...
@@ -12,9 +12,8 @@
[
isSupportTemplate()
](
../reference/apis/js-apis-notificationManager.md#notificationissupporttemplate
)
是查询模板是否支持接口,目前仅支持进度条模板。
| | |
| -------- | -------- |
|
**接口名**
|
**描述**
|
| -------- | -------- |
| isSupportTemplate(templateName:
string,
callback:
AsyncCallback
<
boolean
>
):
void | 查询模板是否存在。 |
...
...
zh-cn/application-dev/notification/text-notification.md
浏览文件 @
8be9fffc
...
...
@@ -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
)
## 接口说明
...
...
zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md
浏览文件 @
8be9fffc
...
...
@@ -9,7 +9,7 @@
## 导入模块
```
js
import
N
otificationSubscribe
from
'
@ohos.notificationSubscribe
'
;
import
n
otificationSubscribe
from
'
@ohos.notificationSubscribe
'
;
```
...
...
@@ -62,11 +62,9 @@ let subscriber = {
let
info
=
{
bundleNames
:
[
"
bundleName1
"
,
"
bundleName2
"
]
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
info
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
info
,
subscribeCallback
);
```
## NotificationSubscribe.subscribe
subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback
\<
void
\>
): void
...
...
@@ -110,7 +108,7 @@ function onConsumeCallback(data) {
let
subscriber
=
{
onConsume
:
onConsumeCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
...
...
@@ -151,7 +149,7 @@ function onConsumeCallback(data) {
let
subscriber
=
{
onConsume
:
onConsumeCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
).
then
(()
=>
{
n
otificationSubscribe
.
subscribe
(
subscriber
).
then
(()
=>
{
console
.
info
(
"
subscribe success
"
);
});
```
...
...
@@ -201,11 +199,9 @@ function onDisconnectCallback(data) {
let
subscriber
=
{
onDisconnect
:
onDisconnectCallback
};
N
otificationSubscribe
.
unsubscribe
(
subscriber
,
unsubscribeCallback
);
n
otificationSubscribe
.
unsubscribe
(
subscriber
,
unsubscribeCallback
);
```
## NotificationSubscribe.unsubscribe
unsubscribe(subscriber: NotificationSubscriber): Promise
\<
void
\>
...
...
@@ -241,13 +237,11 @@ function onDisconnectCallback(data) {
let
subscriber
=
{
onDisconnect
:
onDisconnectCallback
};
N
otificationSubscribe
.
unsubscribe
(
subscriber
).
then
(()
=>
{
n
otificationSubscribe
.
unsubscribe
(
subscriber
).
then
(()
=>
{
console
.
info
(
"
unsubscribe success
"
);
});
```
## NotificationSubscribe.remove
remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason, callback: AsyncCallback
\<
void
\>
): void
...
...
@@ -296,8 +290,8 @@ let notificationKey = {
id
:
0
,
label
:
"
label
"
,
};
let
reason
=
N
otificationSubscribe
.
RemoveReason
.
CLICK_REASON_REMOVE
;
N
otificationSubscribe
.
remove
(
bundle
,
notificationKey
,
reason
,
removeCallback
);
let
reason
=
n
otificationSubscribe
.
RemoveReason
.
CLICK_REASON_REMOVE
;
n
otificationSubscribe
.
remove
(
bundle
,
notificationKey
,
reason
,
removeCallback
);
```
...
...
@@ -343,13 +337,11 @@ let notificationKey = {
label
:
"
label
"
,
};
let
reason
=
NotificationSubscribe
.
RemoveReason
.
CLICK_REASON_REMOVE
;
N
otificationSubscribe
.
remove
(
bundle
,
notificationKey
,
reason
).
then
(()
=>
{
n
otificationSubscribe
.
remove
(
bundle
,
notificationKey
,
reason
).
then
(()
=>
{
console
.
info
(
"
remove success
"
);
});
```
## NotificationSubscribe.remove
remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback
\<
void
\>
): void
...
...
@@ -392,11 +384,9 @@ function removeCallback(err) {
}
}
let
reason
=
NotificationSubscribe
.
RemoveReason
.
CANCEL_REASON_REMOVE
;
N
otificationSubscribe
.
remove
(
hashCode
,
reason
,
removeCallback
);
n
otificationSubscribe
.
remove
(
hashCode
,
reason
,
removeCallback
);
```
## NotificationSubscribe.remove
remove(hashCode: string, reason: RemoveReason): Promise
\<
void
\>
...
...
@@ -429,14 +419,12 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\>
```
js
let
hashCode
=
'
hashCode
'
;
let
reason
=
N
otificationSubscribe
.
RemoveReason
.
CLICK_REASON_REMOVE
;
N
otificationSubscribe
.
remove
(
hashCode
,
reason
).
then
(()
=>
{
let
reason
=
n
otificationSubscribe
.
RemoveReason
.
CLICK_REASON_REMOVE
;
n
otificationSubscribe
.
remove
(
hashCode
,
reason
).
then
(()
=>
{
console
.
info
(
"
remove success
"
);
});
```
## NotificationSubscribe.removeAll
removeAll(bundle: BundleOption, callback: AsyncCallback
\<
void
\>
): void
...
...
@@ -481,8 +469,6 @@ let bundle = {
NotificationSubscribe
.
removeAll
(
bundle
,
removeAllCallback
);
```
## NotificationSubscribe.removeAll
removeAll(callback: AsyncCallback
\<
void
\>
): void
...
...
@@ -520,11 +506,9 @@ function removeAllCallback(err) {
}
}
N
otificationSubscribe
.
removeAll
(
removeAllCallback
);
n
otificationSubscribe
.
removeAll
(
removeAllCallback
);
```
## NotificationSubscribe.removeAll
removeAll(bundle?: BundleOption): Promise
\<
void
\>
...
...
@@ -556,7 +540,7 @@ removeAll(bundle?: BundleOption): Promise\<void\>
```
js
// 不指定应用时,删除所有通知
N
otificationSubscribe
.
removeAll
().
then
(()
=>
{
n
otificationSubscribe
.
removeAll
().
then
(()
=>
{
console
.
info
(
"
removeAll success
"
);
});
```
...
...
@@ -602,7 +586,7 @@ function removeAllCallback(err) {
let
userId
=
1
;
N
otificationSubscribe
.
removeAll
(
userId
,
removeAllCallback
);
n
otificationSubscribe
.
removeAll
(
userId
,
removeAllCallback
);
```
## Notification.removeAll
...
...
@@ -645,11 +629,9 @@ function removeAllCallback(err) {
let
userId
=
1
;
N
otificationSubscribe
.
removeAll
(
userId
,
removeAllCallback
);
n
otificationSubscribe
.
removeAll
(
userId
,
removeAllCallback
);
```
## NotificationSubscriber
作为订阅通知接口
[
subscribe
](
#notificationsubscribe
)
的入参,提供订阅者接收到新通知、取消通知等的回调方法。
...
...
@@ -693,7 +675,7 @@ let subscriber = {
onConsume
:
onConsumeCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
### onCancel
...
...
@@ -733,7 +715,7 @@ let subscriber = {
onCancel
:
onCancelCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
### onUpdate
...
...
@@ -771,7 +753,7 @@ let subscriber = {
onUpdate
:
onUpdateCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
### onConnect
...
...
@@ -803,7 +785,7 @@ let subscriber = {
onConnect
:
onConnectCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
### onDisconnect
...
...
@@ -847,9 +829,9 @@ let subscriber = {
};
// 订阅通知后会收到onConnect回调
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
// 取消订阅后会收到onDisconnect回调
N
otificationSubscribe
.
unsubscribe
(
subscriber
,
unsubscribeCallback
);
n
otificationSubscribe
.
unsubscribe
(
subscriber
,
unsubscribeCallback
);
```
### onDestroy
...
...
@@ -881,7 +863,7 @@ let subscriber = {
onDestroy
:
onDestroyCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
### onDoNotDisturbDateChange
...
...
@@ -919,7 +901,7 @@ let subscriber = {
onDoNotDisturbDateChange
:
onDoNotDisturbDateChangeCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
...
...
@@ -960,7 +942,7 @@ let subscriber = {
onEnabledNotificationChanged
:
onEnabledNotificationChangedCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
## BundleOption
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录