Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
78a86da2
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
78a86da2
编写于
3月 10, 2023
作者:
Y
yuyaozhi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix notification error
Signed-off-by:
N
yuyaozhi
<
yuyaozhi@huawei.com
>
上级
d246a7c4
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
119 addition
and
105 deletion
+119
-105
zh-cn/application-dev/reference/apis/Readme-CN.md
zh-cn/application-dev/reference/apis/Readme-CN.md
+9
-0
zh-cn/application-dev/reference/apis/js-apis-inner-notification-notificationCommonDef.md
.../apis/js-apis-inner-notification-notificationCommonDef.md
+16
-14
zh-cn/application-dev/reference/apis/js-apis-notificationManager.md
...ication-dev/reference/apis/js-apis-notificationManager.md
+25
-25
zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md
...ation-dev/reference/apis/js-apis-notificationSubscribe.md
+60
-66
zh-cn/application-dev/website.md
zh-cn/application-dev/website.md
+9
-0
未找到文件。
zh-cn/application-dev/reference/apis/Readme-CN.md
浏览文件 @
78a86da2
...
...
@@ -131,6 +131,15 @@
-
[
CommonEventPublishData
](
js-apis-inner-commonEvent-commonEventPublishData.md
)
-
[
CommonEventSubscriber
](
js-apis-inner-commonEvent-commonEventSubscriber.md
)
-
[
CommonEventSubscribeInfo
](
js-apis-inner-commonEvent-commonEventSubscribeInfo.md
)
-
notification
-
[
NotificationActionButton
](
js-apis-inner-notification-notificationActionButton.md
)
-
[
NotificationCommonDef
](
js-apis-inner-notification-notificationCommonDef.md
)
-
[
NotificationContent
](
js-apis-inner-notification-notificationContent.md
)
-
[
NotificationFlags
](
js-apis-inner-notification-notificationFlags.md
)
-
[
NotificationRequest
](
js-apis-inner-notification-notificationRequest.md
)
-
[
NotificationSlot
](
js-apis-inner-notification-notificationSlot.md
)
-
[
NotificationTemplate
](
js-apis-inner-notification-notificationTemplate.md
)
-
[
NotificationUserInput
](
js-apis-inner-notification-notificationUserInput.md
)
-
包管理
-
[
@ohos.bundle.appControl (appControl模块)
](
js-apis-appControl.md
)
-
[
@ohos.bundle.bundleManager (bundleManager模块)
](
js-apis-bundleManager.md
)
...
...
zh-cn/application-dev/reference/apis/js-apis-inner-notification-
bundleOption
.md
→
zh-cn/application-dev/reference/apis/js-apis-inner-notification-
notificationCommonDef
.md
浏览文件 @
78a86da2
# BundleOption
BundleOption模块为指定应用的包信息。
# NotificationCommonDef
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## BundleOption
BundleOption模块为指定应用的包信息。
**系统能力**
:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 必填 | 说明 |
...
...
zh-cn/application-dev/reference/apis/js-apis-notificationManager.md
浏览文件 @
78a86da2
...
...
@@ -1005,7 +1005,7 @@ setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCall
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 设定通知使能回调函数。 |
...
...
@@ -1054,7 +1054,7 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| enable | boolean | 是 | 使能状态。 |
**错误码:**
...
...
@@ -1097,7 +1097,7 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>):
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------ |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 获取通知使能状态回调函数。 |
**错误码:**
...
...
@@ -1145,7 +1145,7 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
**返回值:**
...
...
@@ -1237,7 +1237,7 @@ isNotificationEnabled(): Promise\<boolean\>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
**返回值:**
...
...
@@ -1282,7 +1282,7 @@ displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<voi
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 设定角标使能回调函数。 |
...
...
@@ -1331,7 +1331,7 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| enable | boolean | 是 | 使能状态。 |
**错误码:**
...
...
@@ -1374,7 +1374,7 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------ |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 获取角标使能状态回调函数。 |
**错误码:**
...
...
@@ -1422,7 +1422,7 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
**返回值:**
...
...
@@ -1470,7 +1470,7 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCal
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| slot |
[
NotificationSlot
](
js-apis-inner-notification-notificationSlot.md
)
| 是 | 通知通道。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 设定通知通道回调函数。 |
...
...
@@ -1524,7 +1524,7 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| slot |
[
NotificationSlot
](
js-apis-inner-notification-notificationSlot.md
)
| 是 | 通知通道。 |
**错误码:**
...
...
@@ -1570,7 +1570,7 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<Notificati
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| callback | AsyncCallback
<Array
\<[
NotificationSlot
](
js-apis-inner-notification-notificationSlot.md
)\
>
> | 是 | 获取通知通道回调函数。 |
**错误码:**
...
...
@@ -1618,7 +1618,7 @@ getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
**返回值:**
...
...
@@ -1666,7 +1666,7 @@ getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): voi
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| callback | AsyncCallback
\<
number
\>
| 是 | 获取通知通道数量回调函数。 |
**错误码:**
...
...
@@ -1714,7 +1714,7 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
**返回值:**
...
...
@@ -2071,7 +2071,7 @@ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCall
| 参数名 | 类型 | 必填 | 说明 |
| --------- | --------------------- | ---- | ---------------------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 应用的包信息。 |
| groupName | string | 是 | 通知组名称。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 删除指定应用指定组下通知的回调函数。 |
...
...
@@ -2121,7 +2121,7 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------ | ---- | -------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 应用的包信息。 |
| groupName | string | 是 | 通知组名称。 |
**错误码:**
...
...
@@ -2933,7 +2933,7 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: As
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 应用的包信息。 |
| enable | boolean | 是 | 是否支持。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 应用程序是否支持分布式通知的回调函数。 |
...
...
@@ -2987,7 +2987,7 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<vo
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 应用的包。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 应用的包。 |
| enable | boolean | 是 | 是否支持。 |
**错误码:**
...
...
@@ -3032,7 +3032,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 应用的包。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 应用的包。 |
| callback | AsyncCallback
\<
boolean
\>
| 是 | 查询指定应用是否支持分布式通知的回调函数。 |
**错误码:**
...
...
@@ -3083,7 +3083,7 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------ | ---- | -------------------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 应用的包。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 应用的包。 |
**返回值:**
...
...
@@ -3440,7 +3440,7 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean,
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 应用的包信息。 |
| type |
[
SlotType
](
#slottype
)
| 是 | 指定渠道类型。 |
| enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 设置渠道使能回调函数。 |
...
...
@@ -3491,7 +3491,7 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean)
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 应用的包信息。 |
| type |
[
SlotType
](
#slottype
)
| 是 | 渠道类型。 |
| enable | boolean | 是 | 使能状态。 |
...
...
@@ -3534,7 +3534,7 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------- | ---- | ---------------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 应用的包信息。 |
| type |
[
SlotType
](
#slottype
)
| 是 | 渠道类型。 |
| callback | AsyncCallback
\<
boolean
\>
| 是 | 获取渠道使能状态回调函数。 |
...
...
@@ -3583,7 +3583,7 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ----------------------------- | ---- | -------------- |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
bundleOption.md
)
| 是 | 应用的包信息。 |
| bundle |
[
BundleOption
](
./js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 应用的包信息。 |
| type |
[
SlotType
](
#slottype
)
| 是 | 渠道类型。 |
**返回值:**
...
...
zh-cn/application-dev/reference/apis/js-apis-notificationSubscribe.md
浏览文件 @
78a86da2
...
...
@@ -9,7 +9,7 @@
## 导入模块
```
js
import
N
otificationSubscribe
from
'
@ohos.notificationSubscribe
'
;
import
n
otificationSubscribe
from
'
@ohos.notificationSubscribe
'
;
```
...
...
@@ -50,7 +50,7 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c
//subscribe回调
function
subscribeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`subscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
subscribe success
"
);
}
...
...
@@ -64,11 +64,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
...
...
@@ -103,7 +101,7 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>):
```
js
function
subscribeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`subscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
subscribe success
"
);
}
...
...
@@ -114,7 +112,7 @@ function onConsumeCallback(data) {
let
subscriber
=
{
onConsume
:
onConsumeCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
...
...
@@ -157,7 +155,7 @@ function onConsumeCallback(data) {
let
subscriber
=
{
onConsume
:
onConsumeCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
).
then
(()
=>
{
n
otificationSubscribe
.
subscribe
(
subscriber
).
then
(()
=>
{
console
.
info
(
"
subscribe success
"
);
});
```
...
...
@@ -198,7 +196,7 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>)
```
js
function
unsubscribeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
unsubscribe failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`unsubscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
unsubscribe success
"
);
}
...
...
@@ -209,11 +207,9 @@ function onDisconnectCallback() {
let
subscriber
=
{
onDisconnect
:
onDisconnectCallback
};
N
otificationSubscribe
.
unsubscribe
(
subscriber
,
unsubscribeCallback
);
n
otificationSubscribe
.
unsubscribe
(
subscriber
,
unsubscribeCallback
);
```
## NotificationSubscribe.unsubscribe
unsubscribe(subscriber: NotificationSubscriber): Promise
\<
void
\>
...
...
@@ -251,13 +247,11 @@ function onDisconnectCallback() {
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
...
...
@@ -274,7 +268,7 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ----------------------------------| ---- | -------------------- |
| bundle |
[
BundleOption
](
js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| notificationKey |
[
NotificationKey
](
js-apis-notification.md#notificationkey
)
| 是 | 通知键值。 |
| reason |
[
RemoveReason
](
#removereason
)
| 是 | 通知删除原因。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 删除指定通知回调函数。 |
...
...
@@ -296,7 +290,7 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
```
js
function
removeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
remove failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`remove failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
remove success
"
);
}
...
...
@@ -308,8 +302,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
);
```
...
...
@@ -330,7 +324,7 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | --------------- | ---- | ---------- |
| bundle |
[
BundleOption
](
js-apis-inner-notification-
bundleOption.md
)
| 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
| 是 | 指定应用的包信息。 |
| notificationKey |
[
NotificationKey
](
(js-apis-notification.md#notificationkey
)
) | 是 | 通知键值。 |
| reason |
[
RemoveReason
](
#removereason
)
| 是 | 通知删除原因。 |
...
...
@@ -357,13 +351,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
...
...
@@ -402,17 +394,15 @@ let hashCode = 'hashCode';
function
removeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
remove failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`remove failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
remove success
"
);
}
}
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
\>
...
...
@@ -447,14 +437,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
...
...
@@ -471,7 +459,7 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------------- |
| bundle |
[
BundleOption
](
(js-apis-inner-notification-
bundleOption.md
)
) | 是 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
(js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback
\<
void
\>
| 是 | 删除指定应用的所有通知回调函数。 |
**错误码:**
...
...
@@ -490,7 +478,7 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
```
js
function
removeAllCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
removeAll failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`removeAll failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
removeAll success
"
);
}
...
...
@@ -501,8 +489,6 @@ let bundle = {
NotificationSubscribe
.
removeAll
(
bundle
,
removeAllCallback
);
```
## NotificationSubscribe.removeAll
removeAll(callback: AsyncCallback
\<
void
\>
): void
...
...
@@ -536,17 +522,15 @@ removeAll(callback: AsyncCallback\<void\>): void
```
js
function
removeAllCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
removeAll failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`removeAll failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
removeAll success
"
);
}
}
N
otificationSubscribe
.
removeAll
(
removeAllCallback
);
n
otificationSubscribe
.
removeAll
(
removeAllCallback
);
```
## NotificationSubscribe.removeAll
removeAll(bundle?: BundleOption): Promise
\<
void
\>
...
...
@@ -563,7 +547,7 @@ removeAll(bundle?: BundleOption): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- |
| bundle |
[
BundleOption
](
(js-apis-inner-notification-
bundleOption.md
)
) | 否 | 指定应用的包信息。 |
| bundle |
[
BundleOption
](
(js-apis-inner-notification-
notificationCommonDef.md#bundleoption
)
) | 否 | 指定应用的包信息。 |
**错误码:**
...
...
@@ -580,7 +564,7 @@ removeAll(bundle?: BundleOption): Promise\<void\>
```
js
// 不指定应用时,删除所有通知
N
otificationSubscribe
.
removeAll
().
then
(()
=>
{
n
otificationSubscribe
.
removeAll
().
then
(()
=>
{
console
.
info
(
"
removeAll success
"
);
});
```
...
...
@@ -620,7 +604,7 @@ removeAll(userId: number, callback: AsyncCallback\<void>): void
```
js
function
removeAllCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
removeAll failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`removeAll failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
removeAll success
"
);
}
...
...
@@ -628,7 +612,7 @@ function removeAllCallback(err) {
let
userId
=
1
;
N
otificationSubscribe
.
removeAll
(
userId
,
removeAllCallback
);
n
otificationSubscribe
.
removeAll
(
userId
,
removeAllCallback
);
```
## Notification.removeAll
...
...
@@ -665,7 +649,7 @@ removeAll(userId: number): Promise\<void>
```
js
function
removeAllCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
removeAll failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`removeAll failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
removeAll success
"
);
}
...
...
@@ -673,11 +657,9 @@ function removeAllCallback(err) {
let
userId
=
1
;
N
otificationSubscribe
.
removeAll
(
userId
,
removeAllCallback
);
n
otificationSubscribe
.
removeAll
(
userId
,
removeAllCallback
);
```
## NotificationSubscriber
作为订阅通知接口
[
subscribe
](
#notificationsubscribe
)
的入参,提供订阅者接收到新通知、取消通知等的回调方法。
...
...
@@ -705,7 +687,7 @@ onConsume?: (data: [SubscribeCallbackData](js-apis-notification.md#subscribecall
```
javascript
function
subscribeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`subscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
subscribeCallback
"
);
}
...
...
@@ -721,7 +703,7 @@ let subscriber = {
onConsume
:
onConsumeCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
### onCancel
...
...
@@ -745,7 +727,7 @@ onCancel?:(data: [SubscribeCallbackData](js-apis-notification.md#subscribecallba
```
javascript
function
subscribeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`subscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
subscribeCallback
"
);
}
...
...
@@ -761,7 +743,7 @@ let subscriber = {
onCancel
:
onCancelCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
### onUpdate
...
...
@@ -785,7 +767,7 @@ onUpdate?:(data: [NotificationSortingMap](js-apis-notification.md#notificationso
```
javascript
function
subscribeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`subscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
subscribeCallback
"
);
}
...
...
@@ -799,7 +781,7 @@ let subscriber = {
onUpdate
:
onUpdateCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
### onConnect
...
...
@@ -817,7 +799,7 @@ onConnect?:() => void
```
javascript
function
subscribeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`subscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
subscribeCallback
"
);
}
...
...
@@ -831,7 +813,7 @@ let subscriber = {
onConnect
:
onConnectCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
### onDisconnect
...
...
@@ -849,14 +831,14 @@ onDisconnect?:() => void
```
javascript
function
subscribeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`subscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
subscribeCallback
"
);
}
};
function
unsubscribeCallback
(
err
)
{
if
(
err
.
code
)
{
console
.
info
(
"
unsubscribe failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`unsubscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
unsubscribeCallback
"
);
}
...
...
@@ -875,9 +857,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
...
...
@@ -895,7 +877,7 @@ onDestroy?:() => void
```
javascript
function
subscribeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`subscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
subscribeCallback
"
);
}
...
...
@@ -909,7 +891,7 @@ let subscriber = {
onDestroy
:
onDestroyCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
### onDoNotDisturbDateChange
...
...
@@ -933,7 +915,7 @@ onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notific
```
javascript
function
subscribeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`subscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
subscribeCallback
"
);
}
...
...
@@ -947,7 +929,7 @@ let subscriber = {
onDoNotDisturbDateChange
:
onDoNotDisturbDateChangeCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
...
...
@@ -972,7 +954,7 @@ onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](j
```
javascript
function
subscribeCallback
(
err
)
{
if
(
err
)
{
console
.
info
(
"
subscribe failed
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`subscribe failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
info
(
"
subscribeCallback
"
);
}
...
...
@@ -988,7 +970,7 @@ let subscriber = {
onEnabledNotificationChanged
:
onEnabledNotificationChangedCallback
};
N
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
n
otificationSubscribe
.
subscribe
(
subscriber
,
subscribeCallback
);
```
### onBadgeChanged<sup>10+</sup>
...
...
@@ -1042,3 +1024,15 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback);
| -------------------- | --- | -------------------- |
| CLICK_REASON_REMOVE | 1 | 点击通知后删除通知。 |
| CANCEL_REASON_REMOVE | 2 | 用户删除通知。 |
## BadgeNumberCallbackData<sup>10+</sup>
**系统能力**
:以下各项对应的系统能力均为SystemCapability.Notification.Notification
**系统API**
:此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 描述 |
| ----------- | ------ | ---- | ---- | ------------ |
| bundle | string | 是 | 否 | 应用的包名。 |
| uid | number | 是 | 否 | 应用的uid。 |
| badgeNumber | number | 是 | 否 | 角标个数。 |
zh-cn/application-dev/website.md
浏览文件 @
78a86da2
...
...
@@ -933,6 +933,15 @@
-
[
CommonEventPublishData
](
reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md
)
-
[
CommonEventSubscriber
](
reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md
)
-
[
CommonEventSubscribeInfo
](
reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.md
)
-
notification
-
[
NotificationActionButton
](
reference/apis/js-apis-inner-notification-notificationActionButton.md
)
-
[
NotificationCommonDef
](
reference/apis/js-apis-inner-notification-notificationCommonDef.md
)
-
[
NotificationContent
](
reference/apis/js-apis-inner-notification-notificationContent.md
)
-
[
NotificationFlags
](
reference/apis/js-apis-inner-notification-notificationFlags.md
)
-
[
NotificationRequest
](
reference/apis/js-apis-inner-notification-notificationRequest.md
)
-
[
NotificationSlot
](
reference/apis/js-apis-inner-notification-notificationSlot.md
)
-
[
NotificationTemplate
](
reference/apis/js-apis-inner-notification-notificationTemplate.md
)
-
[
NotificationUserInput
](
reference/apis/js-apis-inner-notification-notificationUserInput.md
)
-
包管理
-
[
@ohos.bundle.appControl (appControl模块)
](
reference/apis/js-apis-appControl.md
)
-
[
@ohos.bundle.bundleManager (bundleManager模块)
](
reference/apis/js-apis-bundleManager.md
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录