Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
357ef5e4
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
提交
357ef5e4
编写于
5月 08, 2023
作者:
X
xinking129
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
d.ts push on/off added
Signed-off-by:
N
xinking129
<
xinxin13@huawei.com
>
上级
2ba182a6
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
105 addition
and
0 deletion
+105
-0
zh-cn/application-dev/reference/apis/js-apis-notificationManager.md
...ication-dev/reference/apis/js-apis-notificationManager.md
+105
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-notificationManager.md
浏览文件 @
357ef5e4
...
@@ -3975,6 +3975,91 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) =>
...
@@ -3975,6 +3975,91 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) =>
});
});
```
```
## notificationManager.on
on(type: 'checkNotification', callback: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void;
订阅检查通知的回调。
**系统能力**
:SystemCapability.Notification.Notification
**系统API**
:此接口为系统接口,三方应用不支持调用。
**需要权限**
:ohos.permission.NOTIFICATION_CONTROLLER and ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- |
| type | checkNotification | 是 | 要侦听的回调的类型。 |
| callback | (checkInfo:
[
NotificationCheckInfo
](
#NotificationCheckInfo
)
) =>
[
NotificationCheckResult
](
#NotificationCheckResult
)
| 是 | 消息验证函数指针。 |
**错误码:**
错误码详细介绍请参考
[
errcode-notification
](
../errorcodes/errorcode-notification.md
)
。
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
**示例:**
```
ts
try
{
notificationManager
.
on
(
"
checkNotification
"
,
OnCheckNotification
);
}
catch
(
error
){
console
.
info
(
`notificationManager.on error:
${
JSON
.
stringify
(
error
)}
`
);
}
function
OnCheckNotification
(
info
:
notificationManager
.
NotificationCheckInfo
)
{
console
.
info
(
`====>OnCheckNotification info:
${
JSON
.
stringify
(
info
)}
`
);
if
(
info
.
notificationId
==
1
){
return
{
code
:
1
,
message
:
"
testMsg1
"
}
}
else
{
return
{
code
:
0
,
message
:
"
testMsg0
"
}
}
}
```
## notificationManager.off
off(type: 'checkNotification', callback?: (checkInfo: NotificationCheckInfo) => NotificationCheckResult): void;
取消订阅检查通知的回调。
**系统能力**
:SystemCapability.Notification.Notification
**系统API**
:此接口为系统接口,三方应用不支持调用。
**需要权限**
:ohos.permission.NOTIFICATION_CONTROLLER and ohos.permission.NOTIFICATION_AGENT_CONTROLLER
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- |
| type | checkNotification | 是 | 要侦听的回调的类型。 |
| callback | (checkInfo:
[
NotificationCheckInfo
](
#NotificationCheckInfo
)
) =>
[
NotificationCheckResult
](
#NotificationCheckResult
)
| 否 | 消息验证函数指针。 |
**错误码:**
错误码详细介绍请参考
[
errcode-notification
](
../errorcodes/errorcode-notification.md
)
。
| 错误码ID | 错误信息 |
| -------- | ----------------------------------- |
| 202 | Not system application to call the interface. |
| 401 | The parameter check failed. |
| 1600001 | Internal error. |
**示例:**
```
ts
try
{
notificationManager
.
off
(
"
checkNotification
"
);
}
catch
(
error
){
console
.
info
(
`notificationManager.off error:
${
JSON
.
stringify
(
error
)}
`
);
}
```
## DoNotDisturbDate
## DoNotDisturbDate
...
@@ -4067,3 +4152,23 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) =>
...
@@ -4067,3 +4152,23 @@ notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) =>
| TYPE_NORMAL | 0 | 一般通知。 |
| TYPE_NORMAL | 0 | 一般通知。 |
| TYPE_CONTINUOUS | 1 | 连续通知。 |
| TYPE_CONTINUOUS | 1 | 连续通知。 |
| TYPE_TIMER | 2 | 计划通知。 |
| TYPE_TIMER | 2 | 计划通知。 |
## NotificationCheckInfo
通知检查参数。
| 名称 | 类型 | 说明 |
| -------------------- | -------- | ---------- |
| bundleName | string | bundle名称。 |
| notificationId | number | 通知Id。 |
| contentType |
[
ContentType
](
#ContentType
)
| 通知类型。 |
## NotificationCheckResult
通知检查结果。
| 名称 | 类型 | 说明 |
| -------------------- | -------- | ---------- |
| code | number | 0-display, 1-no display。 |
| message | string | 结果信息。 |
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录