未验证 提交 16318b01 编写于 作者: O openharmony_ci 提交者: Gitee

!15834 cherry-pick fix notification error

Merge pull request !15834 from yuyaozhi/monthly_20221018
...@@ -131,6 +131,15 @@ ...@@ -131,6 +131,15 @@
- [CommonEventPublishData](js-apis-inner-commonEvent-commonEventPublishData.md) - [CommonEventPublishData](js-apis-inner-commonEvent-commonEventPublishData.md)
- [CommonEventSubscriber](js-apis-inner-commonEvent-commonEventSubscriber.md) - [CommonEventSubscriber](js-apis-inner-commonEvent-commonEventSubscriber.md)
- [CommonEventSubscribeInfo](js-apis-inner-commonEvent-commonEventSubscribeInfo.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.appControl (appControl模块)](js-apis-appControl.md)
- [@ohos.bundle.bundleManager (bundleManager模块)](js-apis-bundleManager.md) - [@ohos.bundle.bundleManager (bundleManager模块)](js-apis-bundleManager.md)
......
# BundleOption # NotificationCommonDef
BundleOption模块为指定应用的包信息。 > **说明:**
>
> **说明:** > 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## BundleOption
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification BundleOption模块为指定应用的包信息。
| 名称 | 类型 | 必填 | 说明 | **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| ------ | ------ |---- | ------ |
| bundle | string | 是 | 应用的包信息。 | | 名称 | 类型 | 必填 | 说明 |
| uid | number | 否 | 用户ID。 | | ------ | ------ |---- | ------ |
| bundle | string | 是 | 应用的包信息。 |
| uid | number | 否 | 用户ID。 |
...@@ -893,8 +893,8 @@ function unsubscribeCallback(err) { ...@@ -893,8 +893,8 @@ function unsubscribeCallback(err) {
console.info("unsubscribe success"); console.info("unsubscribe success");
} }
} }
function onDisconnectCallback(data) { function onDisconnectCallback() {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("subscribe disconnect");
} }
let subscriber = { let subscriber = {
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
...@@ -925,8 +925,8 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\> ...@@ -925,8 +925,8 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
**示例:** **示例:**
```js ```js
function onDisconnectCallback(data) { function onDisconnectCallback() {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("subscribe disconnect");
} }
let subscriber = { let subscriber = {
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
......
...@@ -1005,7 +1005,7 @@ setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCall ...@@ -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 | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback\<void\> | 是 | 设定通知使能回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设定通知使能回调函数。 |
...@@ -1054,7 +1054,7 @@ setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<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 | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
**错误码:** **错误码:**
...@@ -1097,7 +1097,7 @@ isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<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\> | 是 | 获取通知使能状态回调函数。 | | callback | AsyncCallback\<void\> | 是 | 获取通知使能状态回调函数。 |
**错误码:** **错误码:**
...@@ -1145,7 +1145,7 @@ isNotificationEnabled(bundle: BundleOption): Promise\<boolean\> ...@@ -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\> ...@@ -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 ...@@ -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 | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback\<void\> | 是 | 设定角标使能回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设定角标使能回调函数。 |
...@@ -1331,7 +1331,7 @@ displayBadge(bundle: BundleOption, enable: boolean): Promise\<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 | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
**错误码:** **错误码:**
...@@ -1374,7 +1374,7 @@ isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void ...@@ -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\> | 是 | 获取角标使能状态回调函数。 | | callback | AsyncCallback\<void\> | 是 | 获取角标使能状态回调函数。 |
**错误码:** **错误码:**
...@@ -1422,7 +1422,7 @@ isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\> ...@@ -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 ...@@ -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) | 是 | 通知通道。 | | slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 是 | 通知通道。 |
| callback | AsyncCallback\<void\> | 是 | 设定通知通道回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设定通知通道回调函数。 |
...@@ -1524,7 +1524,7 @@ setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<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) | 是 | 通知通道。 | | slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | 是 | 通知通道。 |
**错误码:** **错误码:**
...@@ -1570,7 +1570,7 @@ getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<Notificati ...@@ -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)\>> | 是 | 获取通知通道回调函数。 | | callback | AsyncCallback<Array\<[NotificationSlot](js-apis-inner-notification-notificationSlot.md)\>> | 是 | 获取通知通道回调函数。 |
**错误码:** **错误码:**
...@@ -1618,7 +1618,7 @@ getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>> ...@@ -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 ...@@ -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\> | 是 | 获取通知通道数量回调函数。 | | callback | AsyncCallback\<number\> | 是 | 获取通知通道数量回调函数。 |
**错误码:** **错误码:**
...@@ -1714,7 +1714,7 @@ getSlotNumByBundle(bundle: BundleOption): Promise\<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 ...@@ -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 | 是 | 通知组名称。 | | groupName | string | 是 | 通知组名称。 |
| callback | AsyncCallback\<void\> | 是 | 删除指定应用指定组下通知的回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定应用指定组下通知的回调函数。 |
...@@ -2121,7 +2121,7 @@ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<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 | 是 | 通知组名称。 | | groupName | string | 是 | 通知组名称。 |
**错误码:** **错误码:**
...@@ -2933,7 +2933,7 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: As ...@@ -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 | 是 | 是否支持。 | | enable | boolean | 是 | 是否支持。 |
| callback | AsyncCallback\<void\> | 是 | 应用程序是否支持分布式通知的回调函数。 | | callback | AsyncCallback\<void\> | 是 | 应用程序是否支持分布式通知的回调函数。 |
...@@ -2987,7 +2987,7 @@ setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<vo ...@@ -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 | 是 | 是否支持。 | | enable | boolean | 是 | 是否支持。 |
**错误码:** **错误码:**
...@@ -3032,7 +3032,7 @@ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<bool ...@@ -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\> | 是 | 查询指定应用是否支持分布式通知的回调函数。 | | callback | AsyncCallback\<boolean\> | 是 | 查询指定应用是否支持分布式通知的回调函数。 |
**错误码:** **错误码:**
...@@ -3083,7 +3083,7 @@ isDistributedEnabledByBundle(bundle: BundleOption): Promise\<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, ...@@ -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) | 是 | 指定渠道类型。 | | type | [SlotType](#slottype) | 是 | 指定渠道类型。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
| callback | AsyncCallback\<void\> | 是 | 设置渠道使能回调函数。 | | callback | AsyncCallback\<void\> | 是 | 设置渠道使能回调函数。 |
...@@ -3491,7 +3491,7 @@ setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean) ...@@ -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) | 是 | 渠道类型。 | | type | [SlotType](#slottype) | 是 | 渠道类型。 |
| enable | boolean | 是 | 使能状态。 | | enable | boolean | 是 | 使能状态。 |
...@@ -3534,7 +3534,7 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncC ...@@ -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) | 是 | 渠道类型。 | | type | [SlotType](#slottype) | 是 | 渠道类型。 |
| callback | AsyncCallback\<boolean\> | 是 | 获取渠道使能状态回调函数。 | | callback | AsyncCallback\<boolean\> | 是 | 获取渠道使能状态回调函数。 |
...@@ -3583,7 +3583,7 @@ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolea ...@@ -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) | 是 | 渠道类型。 | | type | [SlotType](#slottype) | 是 | 渠道类型。 |
**返回值:** **返回值:**
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
## 导入模块 ## 导入模块
```js ```js
import NotificationSubscribe from '@ohos.notificationSubscribe'; import notificationSubscribe from '@ohos.notificationSubscribe';
``` ```
...@@ -30,8 +30,8 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c ...@@ -30,8 +30,8 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ---------------- | | ---------- | ------------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | subscriber | [NotificationSubscriber](js-apis-notification.md#notificationsubscriber) | 是 | 通知订阅对象。 |
| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 是 | 通知订阅信息。 | | info | [NotificationSubscribeInfo](js-apis-notification.md#notificationsubscribeinfo) | 是 | 通知订阅信息。 |
| callback | AsyncCallback\<void\> | 是 | 订阅动作回调函数。 | | callback | AsyncCallback\<void\> | 是 | 订阅动作回调函数。 |
**错误码:** **错误码:**
...@@ -50,7 +50,7 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c ...@@ -50,7 +50,7 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c
//subscribe回调 //subscribe回调
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribe success"); console.info("subscribe success");
} }
...@@ -64,11 +64,9 @@ let subscriber = { ...@@ -64,11 +64,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
...@@ -85,7 +83,7 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): ...@@ -85,7 +83,7 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>):
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------- | ---- | ---------------- | | ---------- | ---------------------- | ---- | ---------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | subscriber | [NotificationSubscriber](js-apis-notification.md#notificationsubscriber) | 是 | 通知订阅对象。 |
| callback | AsyncCallback\<void\> | 是 | 订阅动作回调函数。 | | callback | AsyncCallback\<void\> | 是 | 订阅动作回调函数。 |
**错误码:** **错误码:**
...@@ -103,7 +101,7 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): ...@@ -103,7 +101,7 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>):
```js ```js
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribe success"); console.info("subscribe success");
} }
...@@ -114,7 +112,7 @@ function onConsumeCallback(data) { ...@@ -114,7 +112,7 @@ function onConsumeCallback(data) {
let subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
...@@ -135,8 +133,8 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): ...@@ -135,8 +133,8 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo):
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ------------ | | ---------- | ------------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | subscriber | [NotificationSubscriber](js-apis-notification.md#notificationsubscriber) | 是 | 通知订阅对象。 |
| info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | 否 | 通知订阅信息。 | | info | [NotificationSubscribeInfo](js-apis-notification.md#notificationsubscribeinfo) | 否 | 通知订阅信息。 |
**错误码:** **错误码:**
...@@ -157,7 +155,7 @@ function onConsumeCallback(data) { ...@@ -157,7 +155,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");
}); });
``` ```
...@@ -180,7 +178,7 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>) ...@@ -180,7 +178,7 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------- | ---- | -------------------- | | ---------- | ---------------------- | ---- | -------------------- |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | subscriber | [NotificationSubscriber](js-apis-notification.md#notificationsubscriber) | 是 | 通知订阅对象。 |
| callback | AsyncCallback\<void\> | 是 | 取消订阅动作回调函数。 | | callback | AsyncCallback\<void\> | 是 | 取消订阅动作回调函数。 |
**错误码:** **错误码:**
...@@ -198,22 +196,20 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>) ...@@ -198,22 +196,20 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>)
```js ```js
function unsubscribeCallback(err) { function unsubscribeCallback(err) {
if (err) { if (err) {
console.info("unsubscribe failed " + JSON.stringify(err)); console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("unsubscribe success"); console.info("unsubscribe success");
} }
} }
function onDisconnectCallback(data) { function onDisconnectCallback() {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("subscribe disconnect");
} }
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\>
...@@ -230,7 +226,7 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\> ...@@ -230,7 +226,7 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------- | ---- | ------------ | | ---------- | ---------------------- | ---- | ------------ |
| subscriber | [NotificationSubscriber](#notificationsubscriber) | 是 | 通知订阅对象。 | | subscriber | [NotificationSubscriber](js-apis-notification.md#notificationsubscriber) | 是 | 通知订阅对象。 |
**错误码:** **错误码:**
...@@ -245,19 +241,17 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\> ...@@ -245,19 +241,17 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
**示例:** **示例:**
```js ```js
function onDisconnectCallback(data) { function onDisconnectCallback() {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("subscribe disconnect");
} }
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
...@@ -274,8 +268,8 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea ...@@ -274,8 +268,8 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------------- | ----------------------------------| ---- | -------------------- | | --------------- | ----------------------------------| ---- | -------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是 | 指定应用的包信息。 |
| notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 | | notificationKey | [NotificationKey](js-apis-notification.md#notificationkey) | 是 | 通知键值。 |
| reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 |
| callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 |
...@@ -296,7 +290,7 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea ...@@ -296,7 +290,7 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
```js ```js
function removeCallback(err) { function removeCallback(err) {
if (err) { if (err) {
console.info("remove failed " + JSON.stringify(err)); console.error(`remove failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("remove success"); console.info("remove success");
} }
...@@ -308,8 +302,8 @@ let notificationKey = { ...@@ -308,8 +302,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);
``` ```
...@@ -330,8 +324,8 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea ...@@ -330,8 +324,8 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------------- | --------------- | ---- | ---------- | | --------------- | --------------- | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | bundle | [BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption) | 是 | 指定应用的包信息。 |
| notificationKey | [NotificationKey](#notificationkey) | 是 | 通知键值。 | | notificationKey | [NotificationKey]((js-apis-notification.md#notificationkey)) | 是 | 通知键值。 |
| reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 |
**错误码:** **错误码:**
...@@ -357,13 +351,11 @@ let notificationKey = { ...@@ -357,13 +351,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
...@@ -380,7 +372,7 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): ...@@ -380,7 +372,7 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>):
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| hashCode | string | 是 | 通知唯一ID。可以通过[onConsume](#onconsume)回调的入参[SubscribeCallbackData](#subscribecallbackdata)获取其内部[NotificationRequest](#notificationrequest)对象中的hashCode。 | | hashCode | string | 是 | 通知唯一ID。可以通过[onConsume](#onconsume)回调的入参[SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)获取其内部[NotificationRequest](#notificationrequest)对象中的hashCode。 |
| reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 | | reason | [RemoveReason](#removereason) | 是 | 通知删除原因。 |
| callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定通知回调函数。 |
...@@ -402,17 +394,15 @@ let hashCode = 'hashCode'; ...@@ -402,17 +394,15 @@ let hashCode = 'hashCode';
function removeCallback(err) { function removeCallback(err) {
if (err) { if (err) {
console.info("remove failed " + JSON.stringify(err)); console.error(`remove failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("remove success"); console.info("remove success");
} }
} }
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\>
...@@ -447,14 +437,12 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\> ...@@ -447,14 +437,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
...@@ -471,7 +459,7 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void ...@@ -471,7 +459,7 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------------- | | -------- | --------------------- | ---- | ---------------------------- |
| bundle | [BundleOption](#bundleoption) | 是 | 指定应用的包信息。 | | bundle | [BundleOption]((js-apis-inner-notification-notificationCommonDef.md#bundleoption)) | 是 | 指定应用的包信息。 |
| callback | AsyncCallback\<void\> | 是 | 删除指定应用的所有通知回调函数。 | | callback | AsyncCallback\<void\> | 是 | 删除指定应用的所有通知回调函数。 |
**错误码:** **错误码:**
...@@ -490,7 +478,7 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void ...@@ -490,7 +478,7 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
```js ```js
function removeAllCallback(err) { function removeAllCallback(err) {
if (err) { if (err) {
console.info("removeAll failed " + JSON.stringify(err)); console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("removeAll success"); console.info("removeAll success");
} }
...@@ -501,8 +489,6 @@ let bundle = { ...@@ -501,8 +489,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
...@@ -536,17 +522,15 @@ removeAll(callback: AsyncCallback\<void\>): void ...@@ -536,17 +522,15 @@ removeAll(callback: AsyncCallback\<void\>): void
```js ```js
function removeAllCallback(err) { function removeAllCallback(err) {
if (err) { if (err) {
console.info("removeAll failed " + JSON.stringify(err)); console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("removeAll success"); console.info("removeAll success");
} }
} }
NotificationSubscribe.removeAll(removeAllCallback); notificationSubscribe.removeAll(removeAllCallback);
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
removeAll(bundle?: BundleOption): Promise\<void\> removeAll(bundle?: BundleOption): Promise\<void\>
...@@ -563,7 +547,7 @@ removeAll(bundle?: BundleOption): Promise\<void\> ...@@ -563,7 +547,7 @@ removeAll(bundle?: BundleOption): Promise\<void\>
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------ | ---- | ---------- | | ------ | ------------ | ---- | ---------- |
| bundle | [BundleOption](#bundleoption) | 否 | 指定应用的包信息。 | | bundle | [BundleOption]((js-apis-inner-notification-notificationCommonDef.md#bundleoption)) | 否 | 指定应用的包信息。 |
**错误码:** **错误码:**
...@@ -580,7 +564,7 @@ removeAll(bundle?: BundleOption): Promise\<void\> ...@@ -580,7 +564,7 @@ removeAll(bundle?: BundleOption): Promise\<void\>
```js ```js
// 不指定应用时,删除所有通知 // 不指定应用时,删除所有通知
NotificationSubscribe.removeAll().then(() => { notificationSubscribe.removeAll().then(() => {
console.info("removeAll success"); console.info("removeAll success");
}); });
``` ```
...@@ -620,7 +604,7 @@ removeAll(userId: number, callback: AsyncCallback\<void>): void ...@@ -620,7 +604,7 @@ removeAll(userId: number, callback: AsyncCallback\<void>): void
```js ```js
function removeAllCallback(err) { function removeAllCallback(err) {
if (err) { if (err) {
console.info("removeAll failed " + JSON.stringify(err)); console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("removeAll success"); console.info("removeAll success");
} }
...@@ -628,7 +612,7 @@ function removeAllCallback(err) { ...@@ -628,7 +612,7 @@ function removeAllCallback(err) {
let userId = 1; let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback); notificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
## Notification.removeAll ## Notification.removeAll
...@@ -665,7 +649,7 @@ removeAll(userId: number): Promise\<void> ...@@ -665,7 +649,7 @@ removeAll(userId: number): Promise\<void>
```js ```js
function removeAllCallback(err) { function removeAllCallback(err) {
if (err) { if (err) {
console.info("removeAll failed " + JSON.stringify(err)); console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("removeAll success"); console.info("removeAll success");
} }
...@@ -673,11 +657,9 @@ function removeAllCallback(err) { ...@@ -673,11 +657,9 @@ function removeAllCallback(err) {
let userId = 1; let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback); notificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
## NotificationSubscriber ## NotificationSubscriber
作为订阅通知接口[subscribe](#notificationsubscribe)的入参,提供订阅者接收到新通知、取消通知等的回调方法。 作为订阅通知接口[subscribe](#notificationsubscribe)的入参,提供订阅者接收到新通知、取消通知等的回调方法。
...@@ -686,7 +668,7 @@ NotificationSubscribe.removeAll(userId, removeAllCallback); ...@@ -686,7 +668,7 @@ NotificationSubscribe.removeAll(userId, removeAllCallback);
### onConsume ### onConsume
onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void onConsume?: (data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
接收到新通知的回调函数。 接收到新通知的回调函数。
...@@ -698,14 +680,14 @@ onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void ...@@ -698,14 +680,14 @@ onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 新接收到的通知信息。 | | data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | 是 | 新接收到的通知信息。 |
**示例:** **示例:**
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -721,12 +703,12 @@ let subscriber = { ...@@ -721,12 +703,12 @@ let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onCancel ### onCancel
onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void onCancel?:(data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
取消通知的回调函数。 取消通知的回调函数。
...@@ -738,14 +720,14 @@ onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void ...@@ -738,14 +720,14 @@ onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](#subscribecallbackdata) | 是 | 需要取消的通知信息。 | | data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | 是 | 需要取消的通知信息。 |
**示例:** **示例:**
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -761,12 +743,12 @@ let subscriber = { ...@@ -761,12 +743,12 @@ let subscriber = {
onCancel: onCancelCallback onCancel: onCancelCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onUpdate ### onUpdate
onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void onUpdate?:(data: [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) => void
更新通知排序的回调函数。 更新通知排序的回调函数。
...@@ -778,14 +760,14 @@ onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void ...@@ -778,14 +760,14 @@ onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](#notificationsortingmap) | 是 | 最新的通知排序列表。 | | data | [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) | 是 | 最新的通知排序列表。 |
**示例:** **示例:**
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -799,7 +781,7 @@ let subscriber = { ...@@ -799,7 +781,7 @@ let subscriber = {
onUpdate: onUpdateCallback onUpdate: onUpdateCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onConnect ### onConnect
...@@ -817,7 +799,7 @@ onConnect?:() => void ...@@ -817,7 +799,7 @@ onConnect?:() => void
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -831,7 +813,7 @@ let subscriber = { ...@@ -831,7 +813,7 @@ let subscriber = {
onConnect: onConnectCallback onConnect: onConnectCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onDisconnect ### onDisconnect
...@@ -849,14 +831,14 @@ onDisconnect?:() => void ...@@ -849,14 +831,14 @@ onDisconnect?:() => void
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
}; };
function unsubscribeCallback(err) { function unsubscribeCallback(err) {
if (err.code) { if (err.code) {
console.info("unsubscribe failed " + JSON.stringify(err)); console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("unsubscribeCallback"); console.info("unsubscribeCallback");
} }
...@@ -875,9 +857,9 @@ let subscriber = { ...@@ -875,9 +857,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
...@@ -895,7 +877,7 @@ onDestroy?:() => void ...@@ -895,7 +877,7 @@ onDestroy?:() => void
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -909,7 +891,7 @@ let subscriber = { ...@@ -909,7 +891,7 @@ let subscriber = {
onDestroy: onDestroyCallback onDestroy: onDestroyCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onDoNotDisturbDateChange ### onDoNotDisturbDateChange
...@@ -933,7 +915,7 @@ onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notific ...@@ -933,7 +915,7 @@ onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notific
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -947,13 +929,13 @@ let subscriber = { ...@@ -947,13 +929,13 @@ let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onEnabledNotificationChanged ### onEnabledNotificationChanged
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata)) => void onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata)) => void
监听应用通知使能变化。 监听应用通知使能变化。
...@@ -965,14 +947,14 @@ onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](# ...@@ -965,14 +947,14 @@ onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdata)\> | 是 | 回调返回监听到的应用信息。 | | callback | AsyncCallback\<[EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata)\> | 是 | 回调返回监听到的应用信息。 |
**示例:** **示例:**
```javascript ```javascript
function subscribeCallback(err) { function subscribeCallback(err) {
if (err) { if (err) {
console.info("subscribe failed " + JSON.stringify(err)); console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else { } else {
console.info("subscribeCallback"); console.info("subscribeCallback");
} }
...@@ -988,107 +970,49 @@ let subscriber = { ...@@ -988,107 +970,49 @@ let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback onEnabledNotificationChanged: onEnabledNotificationChangedCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
## BundleOption ### onBadgeChanged<sup>10+</sup>
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ------ | ------ |---- | --- | ------ |
| bundle | string | 是 | 是 | 应用的包信息。 |
| uid | number | 是 | 是 | 用户ID。 |
## NotificationKey
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----- | ------ | ---- | --- | -------- |
| id | number | 是 | 是 | 通知ID。 |
| label | string | 是 | 是 | 通知标签。 |
## SubscribeCallbackData
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification onBadgeChanged?:(data: [BadgeNumberCallbackData](#badgenumbercallbackdata)) => void
**系统API**:此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------- | ------------------------------------------------- | -------- | -------- | -------- |
| request | [NotificationRequest](js-apis-notificationManager.md#notificationrequest) | 是 | 否 | 通知内容。 |
| sortingMap | [NotificationSortingMap](#notificationsortingmap) | 是 | 否 | 排序信息。 |
| reason | number | 是 | 否 | 删除原因。 |
| sound | string | 是 | 否 | 通知声音。 |
| vibrationValues | Array\<number\> | 是 | 否 | 通知震动。 |
## EnabledNotificationCallbackData
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 描述 | 监听应用角标个数变化。
| ------ | ------- | ---------------- | ---------------- | ---------------- |
| bundle | string | 是 | 否 | 应用的包名。 |
| uid | number | 是 | 否 | 应用的uid。 |
| enable | boolean | 是 | 否 | 应用通知使能状态。 |
**系统能力**:SystemCapability.Notification.Notification
## NotificationSorting
提供有关活动通知的排序信息。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
**系统API**: 此接口为系统接口,三方应用不支持调用。 **系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 说明 | **参数:**
| -------- | ------------------------------------- | ---- | --- | ------------ |
| slot | [NotificationSlot](js-apis-notificationManager.md#notificationslot) | 是 | 否 | 通知通道内容。 |
| hashCode | string | 是 | 否 | 通知唯一标识。 |
| ranking | number | 是 | 否 | 通知排序序号。 |
## NotificationSortingMap
提供关于已订阅的所有通知中活动通知的排序信息
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | ------------------------------------------------------------ | ---- | --- | ---------------- |
| sortings | {[key: string]: [NotificationSorting](#notificationsorting)} | 是 | 否 | 通知排序信息数组。 |
| sortedHashCode | Array\<string\> | 是 | 否 | 通知唯一标识数组。 |
## NotificationSubscribeInfo
设置订阅所需通知的发布者的信息。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
**系统API**: 此接口为系统接口,三方应用不支持调用。 | 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[BadgeNumberCallbackData](#badgenumbercallbackdata)\> | 是 | 回调返回监听到的应用信息。 |
| 名称 | 类型 | 可读 | 可写 | 说明 | **示例:**
| ----------- | --------------- | --- | ---- | ------------------------------- |
| bundleNames | Array\<string\> | 是 | 是 | 指定订阅哪些包名的APP发来的通知。 |
| userId | number | 是 | 是 | 指定订阅哪个用户下发来的通知。 |
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
## NotificationUserInput function onBadgeChangedCallback(data) {
console.info("bundle: ", data.bundle);
console.info("uid: ", data.uid);
console.info("badgeNumber: ", data.badgeNumber);
};
保存用户输入的通知消息。 let subscriber = {
onBadgeChanged: onBadgeChangedCallback
};
**系统能力**:SystemCapability.Notification.Notification notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | 是 | 是 | 用户输入时用于标识此输入的key。 |
## RemoveReason ## RemoveReason
...@@ -1099,4 +1023,16 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -1099,4 +1023,16 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
| 名称 | 值 | 说明 | | 名称 | 值 | 说明 |
| -------------------- | --- | -------------------- | | -------------------- | --- | -------------------- |
| CLICK_REASON_REMOVE | 1 | 点击通知后删除通知。 | | CLICK_REASON_REMOVE | 1 | 点击通知后删除通知。 |
| CANCEL_REASON_REMOVE | 2 | 用户删除通知。 | | CANCEL_REASON_REMOVE | 2 | 用户删除通知。 |
\ No newline at end of file
## BadgeNumberCallbackData<sup>10+</sup>
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
**系统API**:此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 描述 |
| ----------- | ------ | ---- | ---- | ------------ |
| bundle | string | 是 | 否 | 应用的包名。 |
| uid | number | 是 | 否 | 应用的uid。 |
| badgeNumber | number | 是 | 否 | 角标个数。 |
...@@ -17,22 +17,22 @@ import notification from '@system.notification'; ...@@ -17,22 +17,22 @@ import notification from '@system.notification';
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | 名称 | 类型 | 必填 | 说明 |
| ----------- | --- | ---- | ---------------------------------------------- | ---- | ------------------------- | | ----------- | ---------------------------------------------- | ---- | ------------------------- |
| bundleName | 是 | 是 | string | 是 | 单击通知后要重定向到的应用程序的Bundle名。 | | bundleName | string | 是 | 单击通知后要重定向到的应用程序的Bundle名。 |
| abilityName | 是 | 是 | string | 是 | 单击通知后要重定向到的应用程序的Ability名称。 | | abilityName | string | 是 | 单击通知后要重定向到的应用程序的Ability名称。 |
| uri | 是 | 是 | string | 否 | 要重定向到的页面的uri。 | | uri | string | 否 | 要重定向到的页面的uri。 |
## ShowNotificationOptions ## ShowNotificationOptions
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification **系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
| 名称 | 可读 | 可写 | 类型 | 必填 | 描述 | | 名称 | 类型 | 必填 | 说明 |
| ------------- | --- | ---- | ---------------------------------------------- | ---- | ------------------------- | | ------------- | ---------------------------------------------- | ---- | ------------------------- |
| contentTitle | 是 | 是 | string | 否 | 通知标题。 | | contentTitle | string | 否 | 通知标题。 |
| contentText | 是 | 是 | string | 否 | 通知内容。 | | contentText | string | 否 | 通知内容。 |
| clickAction | 是 | 是 | ActionResult | 否 | 通知被点击后触发的行为。 | | clickAction | ActionResult | 否 | 通知被点击后触发的行为。 |
## notification.show ## notification.show
......
...@@ -933,6 +933,15 @@ ...@@ -933,6 +933,15 @@
- [CommonEventPublishData](reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md) - [CommonEventPublishData](reference/apis/js-apis-inner-commonEvent-commonEventPublishData.md)
- [CommonEventSubscriber](reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md) - [CommonEventSubscriber](reference/apis/js-apis-inner-commonEvent-commonEventSubscriber.md)
- [CommonEventSubscribeInfo](reference/apis/js-apis-inner-commonEvent-commonEventSubscribeInfo.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.appControl (appControl模块)](reference/apis/js-apis-appControl.md)
- [@ohos.bundle.bundleManager (bundleManager模块)](reference/apis/js-apis-bundleManager.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.
先完成此消息的编辑!
想要评论请 注册