未验证 提交 131b4a54 编写于 作者: O openharmony_ci 提交者: Gitee

!23145 翻译完成 22891+21831:文档纠正补充

Merge pull request !23145 from ester.zhou/TR-22891
......@@ -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. |
| creatorUserId<sup>8+<sup> | number | No | ID of the user who creates the notification. |
| hashCode | string | No | Unique ID of the notification. |
| classification | string | No | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| groupName<sup>8+<sup> | string | No | Notification group name. |
| template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | No | Notification template. |
| isRemoveAllowed<sup>10+<sup> | boolean | No | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| source<sup>8+<sup> | number | No | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| distributedOption<sup>8+<sup> | [DistributedOptions](#distributedoptions) | No | Distributed notification options. |
| deviceId<sup>8+<sup> | string | No | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationFlags.md#notificationflags) | No | Notification flags. |
| removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | No | **WantAgent** instance to which the notification will be redirected when it is removed. |
| badgeNumber<sup>9+<sup> | 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. |
| creatorUserId<sup>8+<sup> | number | No | ID of the user who creates the notification. |
| hashCode | string | No | Unique ID of the notification. |
| classification | string | No | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| groupName<sup>8+<sup> | string | No | Notification group name. |
| template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | No | Notification template. |
| isRemoveAllowed<sup>8+<sup> | 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.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| source<sup>8+<sup> | number | No | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| distributedOption<sup>8+<sup> | [DistributedOptions](#distributedoptions) | No | Distributed notification options. |
| deviceId<sup>8+<sup> | string | No | Device ID of the notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationFlags.md#notificationflags) | No | Notification flags. |
| removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | No | **WantAgent** instance to which the notification will be redirected when it is removed. |
| badgeNumber<sup>9+<sup> | number | No | Number of notifications displayed on the application icon. |
## DistributedOptions
......
......@@ -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. |
......@@ -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<notificationManager.NotificationSlot>) {
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.requestEnableNotification<sup>10+<sup>
requestEnableNotification(context: UIAbilityContext, callback: AsyncCallback\<void\>): 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\<void\> | 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.requestEnableNotification<sup>10+<sup>
requestEnableNotification(context: UIAbilityContext): Promise\<void\>
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);
});
```
......
......@@ -443,9 +443,9 @@ notificationSubscribe.remove(hashCode, reason).then(() => {
console.info("remove success");
});
```
## NotificationSubscribe.remove
## NotificationSubscribe.remove<sup>10+<sup>
remove(hashCodes: Array\<string\>, reason: RemoveReason, callback: AsyncCallback\<void\>): void
remove(hashCodes: Array\<String\>, reason: RemoveReason, callback: AsyncCallback\<void\>): 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\<string\> | 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\<String\> | 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\<void\> | 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.remove<sup>10+<sup>
remove(hashCodes: Array\<string\>, reason: RemoveReason): Promise\<void\>
remove(hashCodes: Array\<String\>, reason: RemoveReason): Promise\<void\>
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\<string\> | Yes | Array of unique notification IDs.|
| hashCodes | Array\<String\> | Yes | Array of unique notification IDs.|
| reason | [RemoveReason](#removereason) | Yes | Reason for removing the notification. |
**Error codes**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册