diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md index 9ad267c45ee6c702c5e81af064f169b74dc597ac..be6d3472df78e2755b5d00854c84d0e36b71a8de 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationRequest.md @@ -10,45 +10,45 @@ The **NotificationRequest** module provides APIs for defining the notification r **System capability**: SystemCapability.Notification.Notification -| Name | Type | Mandatory| Description | -| --------------------- | --------------------------------------------- | --- | -------------------------- | -| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | Yes | Notification content. | -| id | number | No | Notification ID. | -| slotType | [SlotType](js-apis-notificationManager.md#slottype) | No | Notification slot type. | -| isOngoing | boolean | No | Whether the notification is an ongoing notification. | -| isUnremovable | boolean | No | Whether the notification can be removed. | -| deliveryTime | number | No | Time when the notification is sent. | -| tapDismissed | boolean | No | Whether the notification is automatically cleared. | -| autoDeletedTime | number | No | Time when the notification is automatically cleared. | -| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | No | **WantAgent** instance to which the notification will be redirected after being clicked.| -| extraInfo | {[key: string]: any} | No | Extended parameters. | -| color | number | No | Background color of the notification. Not supported currently.| -| colorEnabled | boolean | No | Whether the notification background color can be enabled. Not supported currently.| -| isAlertOnce | boolean | No | Whether the notification triggers an alert only once.| -| isStopwatch | boolean | No | Whether to display the stopwatch. | -| isCountDown | boolean | No | Whether to display the countdown time. | -| isFloatingIcon | boolean | No | Whether the notification is displayed as a floating icon in the status bar. | -| label | string | No | Notification label. | -| badgeIconStyle | number | No | Notification badge type. Not supported currently. | -| showDeliveryTime | boolean | No | Whether to display the time when the notification is delivered. | -| actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | No | Buttons in the notification. Up to three buttons are allowed. | -| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | No | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB.| -| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | No | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB.| -| creatorBundleName | string | No | Name of the bundle that creates the notification. | -| creatorUid | number | No | UID used for creating the notification. | -| creatorPid | number | No | PID used for creating the notification. | -| creatorUserId8+ | number | No | ID of the user who creates the notification. | -| hashCode | string | No | Unique ID of the notification. | -| classification | string | No | Notification category.
**System API**: This is a system API and cannot be called by third-party applications. | -| groupName8+ | string | No | Notification group name. | -| template8+ | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | No | Notification template. | -| isRemoveAllowed10+ | boolean | No | Whether the notification can be removed.
**System API**: This is a system API and cannot be called by third-party applications. | -| source8+ | number | No | Notification source.
**System API**: This is a system API and cannot be called by third-party applications. | -| distributedOption8+ | [DistributedOptions](#distributedoptions) | No | Distributed notification options. | -| deviceId8+ | string | No | Device ID of the notification source.
**System API**: This is a system API and cannot be called by third-party applications. | -| notificationFlags8+ | [NotificationFlags](js-apis-inner-notification-notificationFlags.md#notificationflags) | No | Notification flags. | -| removalWantAgent9+ | [WantAgent](js-apis-app-ability-wantAgent.md) | No | **WantAgent** instance to which the notification will be redirected when it is removed. | -| badgeNumber9+ | number | No | Number of notifications displayed on the application icon. | +| Name | Type | Mandatory| Description | +|-------------------------------| --------------------------------------------- | --- |-----------------------------------------------------------------------| +| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | Yes | Notification content. | +| id | number | No | Notification ID. | +| slotType | [SlotType](js-apis-notificationManager.md#slottype) | No | Notification slot type. | +| isOngoing | boolean | No | Whether the notification is an ongoing notification. | +| isUnremovable | boolean | No | Whether the notification can be removed. This parameter applies to continuous notification tasks, such as navigation and music playback. If a notifiation is not removable, it will not be deleted when the user touches the delete button below the notification, but it can still be deleted by swiping left on the notification and touching the delete button. | +| deliveryTime | number | No | Time when the notification is sent. | +| tapDismissed | boolean | No | Whether the notification is automatically cleared. | +| autoDeletedTime | number | No | Time when the notification is automatically cleared. | +| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | No | **WantAgent** instance to which the notification will be redirected after being clicked. | +| extraInfo | {[key: string]: any} | No | Extended parameters. | +| color | number | No | Background color of the notification. Not supported currently. | +| colorEnabled | boolean | No | Whether the notification background color can be enabled. Not supported currently. | +| isAlertOnce | boolean | No | Whether the notification triggers an alert only once. | +| isStopwatch | boolean | No | Whether to display the stopwatch. | +| isCountDown | boolean | No | Whether to display the countdown time. | +| isFloatingIcon | boolean | No | Whether the notification is displayed as a floating icon in the status bar. | +| label | string | No | Notification label. | +| badgeIconStyle | number | No | Notification badge type. Not supported currently. | +| showDeliveryTime | boolean | No | Whether to display the time when the notification is delivered. | +| actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | No | Buttons in the notification. Up to three buttons are allowed. | +| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | No | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB. | +| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | No | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB. | +| creatorBundleName | string | No | Name of the bundle that creates the notification. | +| creatorUid | number | No | UID used for creating the notification. | +| creatorPid | number | No | PID used for creating the notification. | +| creatorUserId8+ | number | No | ID of the user who creates the notification. | +| hashCode | string | No | Unique ID of the notification. | +| classification | string | No | Notification category.
**System API**: This is a system API and cannot be called by third-party applications. | +| groupName8+ | string | No | Notification group name. | +| template8+ | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | No | Notification template. | +| isRemoveAllowed8+ | boolean | No | Whether the notification can be removed. If a notifiation is not removable, it will not be deleted when the user touches the delete button below the notification, but it can still be deleted by swiping left on the notification and touching the delete button.
**System API**: This is a system API and cannot be called by third-party applications.| +| source8+ | number | No | Notification source.
**System API**: This is a system API and cannot be called by third-party applications. | +| distributedOption8+ | [DistributedOptions](#distributedoptions) | No | Distributed notification options. | +| deviceId8+ | string | No | Device ID of the notification source.
**System API**: This is a system API and cannot be called by third-party applications. | +| notificationFlags8+ | [NotificationFlags](js-apis-inner-notification-notificationFlags.md#notificationflags) | No | Notification flags. | +| removalWantAgent9+ | [WantAgent](js-apis-app-ability-wantAgent.md) | No | **WantAgent** instance to which the notification will be redirected when it is removed. | +| badgeNumber9+ | number | No | Number of notifications displayed on the application icon. | ## DistributedOptions diff --git a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md index 73a6bab743f76ff7d139723b0c491b35bcb3772b..afea772afef9616c93c2cdaca2e422aa5313315a 100644 --- a/en/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md +++ b/en/application-dev/reference/apis/js-apis-inner-notification-notificationSorting.md @@ -12,8 +12,8 @@ The **NotificationSorting** module provides APIs for defining the sorting inform **System API**: This is a system API and cannot be called by third-party applications. -| Name | Type | Mandatory| Description | -| -------------------- | --------------------- | --- | ------------------------------------------ | -| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | Yes | Notification slot type. | -| level | number | Yes | Notification level. If this parameter is not set, the default value is used based on the notification slot type.| -| desc | string | Yes | Description of the notification slot. | +| Name | Type | Mandatory| Description | +|---------| --------------------- | --- |------------------------| +| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | Yes | Notification slot type. | +| ranking | number | Yes | Notification level. If this parameter is not set, the default value is used based on the notification slot type.| +| hashCode | string | Yes | Unique ID of the notification. | diff --git a/en/application-dev/reference/apis/js-apis-notificationManager.md b/en/application-dev/reference/apis/js-apis-notificationManager.md index 765b21c01a7bdc8910aa994ad8d33140cb4802fd..206dd80d0c86c4c811538569f99f5d4b3cdc8c7b 100644 --- a/en/application-dev/reference/apis/js-apis-notificationManager.md +++ b/en/application-dev/reference/apis/js-apis-notificationManager.md @@ -751,7 +751,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ let slotType: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION; notificationManager.getSlot(slotType).then((data: notificationManager.NotificationSlot) => { - console.info("getSlot success, data: " + JSON.stringify(data)); + console.info("getSlot success, data: " + JSON.stringify(data)); }); ``` @@ -784,11 +784,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ```ts // getSlots callback function getSlotsCallback(err: Base.BusinessError, data: Array) { - if (err) { - console.error(`getSlots failed, code is ${err.code}, message is ${err.message}`); - } else { - console.info(`getSlots success, data is ${JSON.stringify(data)}`); - } + if (err) { + console.error(`getSlots failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info(`getSlots success, data is ${JSON.stringify(data)}`); + } } notificationManager.getSlots(getSlotsCallback); ``` @@ -855,11 +855,11 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ```ts // removeSlot callback function removeSlotCallback(err: Base.BusinessError) { - if (err) { - console.error(`removeSlot failed, code is ${err.code}, message is ${err.message}`); - } else { - console.info("removeSlot success"); - } + if (err) { + console.error(`removeSlot failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("removeSlot success"); + } } let slotType = notificationManager.SlotType.SOCIAL_COMMUNICATION; notificationManager.removeSlot(slotType, removeSlotCallback); @@ -1485,7 +1485,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ```ts let bundle: notificationManager.BundleOption = { - bundle: "bundleName1", + bundle: "bundleName1", }; notificationManager.isBadgeDisplayed(bundle).then((data: boolean) => { @@ -1519,7 +1519,7 @@ Sets the notification badge number. This API uses a promise to return the result **Example** ```ts -let badgeNumber: number = 10 +let badgeNumber: number = 10; notificationManager.setBadgeNumber(badgeNumber).then(() => { console.info("displayBadge success"); @@ -1563,7 +1563,7 @@ function setBadgeNumberCallback(err: Base.BusinessError) { } } -let badgeNumber: number = 10 +let badgeNumber: number = 10; notificationManager.setBadgeNumber(badgeNumber, setBadgeNumberCallback); ``` @@ -1611,7 +1611,7 @@ function setSlotByBundleCallback(err: Base.BusinessError) { let bundle: notificationManager.BundleOption = { bundle: "bundleName1", }; -let notificationSlot: notificationManager.NotificationSlots = { +let notificationSlot: notificationManager.NotificationSlot = { type: notificationManager.SlotType.SOCIAL_COMMUNICATION }; notificationManager.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); @@ -1798,7 +1798,7 @@ function getSlotNumByBundleCallback(err: Base.BusinessError, data: number) { } let bundle: notificationManager.BundleOption = { - bundle: "bundleName1", + bundle: "bundleName1", }; notificationManager.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); @@ -1843,7 +1843,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ```ts let bundle: notificationManager.BundleOption = { - bundle: "bundleName1", + bundle: "bundleName1", }; notificationManager.getSlotNumByBundle(bundle).then((data: number) => { @@ -2264,7 +2264,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ **Example** ```ts -function setDoNotDisturbDateCallback(err: notificationManager.BundleOption) { +function setDoNotDisturbDateCallback(err: Base.BusinessError) { if (err) { console.error(`setDoNotDisturbDate failed, code is ${err.code}, message is ${err.message}`); } else { @@ -2502,7 +2502,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ ```ts notificationManager.getDoNotDisturbDate().then((data: notificationManager.DoNotDisturbDate) => { - console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data)); + console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data)); }); ``` @@ -2672,7 +2672,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ **Example** ```ts -notificationManager.isSupportDoNotDisturbMode().then((data: data) => { +notificationManager.isSupportDoNotDisturbMode().then((data: boolean) => { console.info("supportDoNotDisturbMode success, data: " + JSON.stringify(data)); }); ``` @@ -2821,7 +2821,76 @@ notificationManager.requestEnableNotification().then(() => { }); ``` +## notificationManager.requestEnableNotification10+ + +requestEnableNotification(context: UIAbilityContext, callback: AsyncCallback\): void + +Requests notification to be enabled for this application in a modal. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Notification.Notification + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------ | ---- |--------------------| +| context | UIAbilityContext | Yes | Ability context bound to the notification dialog box.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | +**Error codes** + +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 1600001 | Internal error. | +| 1600002 | Marshalling or unmarshalling error. | +| 1600003 | Failed to connect service. | + +**Example** + +```javascript +function requestEnableNotificationCallback(err) { + if (err) { + console.error(`requestEnableNotification failed, code is ${err.code}, message is ${err.message}`); + } else { + console.info("requestEnableNotification success"); + } +}; + +notificationManager.requestEnableNotification(globalThis.uicontext, requestEnableNotificationCallback); +``` + +## notificationManager.requestEnableNotification10+ + +requestEnableNotification(context: UIAbilityContext): Promise\ + +Requests notification to be enabled for this application in a modal. This API uses a promise to return the result. + +**System capability**: SystemCapability.Notification.Notification + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------ | ---- |--------------------| +| context | UIAbilityContext | Yes | Ability context bound to the notification dialog box.| + +**Error codes** + +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 1600001 | Internal error. | +| 1600002 | Marshalling or unmarshalling error. | +| 1600003 | Failed to connect service. | + +**Example** + +```javascript +notificationManager.requestEnableNotification(globalThis.uicontext).then(() => { + console.info("requestEnableNotification success"); +}); +``` ## notificationManager.setDistributedEnable @@ -3032,7 +3101,7 @@ let bundle: notificationManager.BundleOption = { bundle: "bundleName1", }; -let enable: boolean = true +let enable: boolean = true; notificationManager.setDistributedEnableByBundle(bundle, enable, setDistributedEnableByBundleCallback); ``` @@ -3077,7 +3146,7 @@ let bundle: notificationManager.BundleOption = { bundle: "bundleName1", }; -let enable: boolean = true +let enable: boolean = true; notificationManager.setDistributedEnableByBundle(bundle, enable).then(() => { console.info("setDistributedEnableByBundle success"); @@ -3865,7 +3934,7 @@ For details about the error codes, see [Notification Error Codes](../errorcodes/ let userId: number = 100; notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data: boolean) => { - console.info('getSyncNotificationEnabledWithoutApp, data:' + data); + console.info('getSyncNotificationEnabledWithoutApp, data:' + data); }); ``` diff --git a/en/application-dev/reference/apis/js-apis-notificationSubscribe.md b/en/application-dev/reference/apis/js-apis-notificationSubscribe.md index 10a7091a75c1e9354921fe46bdbc1ce4bccb1a2e..b9c7bb055262735c5eb790764acb2cd4c861ebe1 100644 --- a/en/application-dev/reference/apis/js-apis-notificationSubscribe.md +++ b/en/application-dev/reference/apis/js-apis-notificationSubscribe.md @@ -443,9 +443,9 @@ notificationSubscribe.remove(hashCode, reason).then(() => { console.info("remove success"); }); ``` -## NotificationSubscribe.remove +## NotificationSubscribe.remove10+ -remove(hashCodes: Array\, reason: RemoveReason, callback: AsyncCallback\): void +remove(hashCodes: Array\, reason: RemoveReason, callback: AsyncCallback\): void Removes specified notifications. This API uses an asynchronous callback to return the result. @@ -459,7 +459,7 @@ Removes specified notifications. This API uses an asynchronous callback to retur | Name | Type | Mandatory| Description | |-----------|-------------------------------| ---- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| hashCodes | Array\ | Yes | Array of unique notification IDs. It is the **hashCode** in the [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) object of [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) of the [onConsume](js-apis-inner-notification-notificationSubscriber.md#onConsume) callback.| +| hashCodes | Array\ | Yes | Array of unique notification IDs. It is the **hashCode** in the [NotificationRequest](js-apis-inner-notification-notificationRequest.md#notificationrequest) object of [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) of the [onConsume](js-apis-inner-notification-notificationSubscriber.md#onConsume) callback.| | reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. | | callback | AsyncCallback\ | Yes | Callback used to return the result. | @@ -489,9 +489,9 @@ let reason = notificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; notificationSubscribe.remove(hashCodes, reason, removeCallback); ``` -## NotificationSubscribe.remove +## NotificationSubscribe.remove10+ -remove(hashCodes: Array\, reason: RemoveReason): Promise\ +remove(hashCodes: Array\, reason: RemoveReason): Promise\ Removes specified notifications. This API uses a promise to return the result. @@ -505,7 +505,7 @@ Removes specified notifications. This API uses a promise to return the result. | Name | Type | Mandatory| Description | |-----------|-------------------------------| ---- |-------------| -| hashCodes | Array\ | Yes | Array of unique notification IDs.| +| hashCodes | Array\ | Yes | Array of unique notification IDs.| | reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. | **Error codes**