提交 4875877c 编写于 作者: E ester.zhou

Update docs (17712)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 7ec35625
......@@ -309,7 +309,7 @@ Set **icon**, **label**, and **skills** under **abilities** in the **module.json
| [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)|
| exported | Whether the UIAbility component can be called by other applications.<br>- **true**: The UIAbility component can be called by other applications.<br>- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
| continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).<br>- **true**: The UIAbility component can be migrated.<br>- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)|
| [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.<br>Configuring rule:<br>- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)<br>- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)|
| [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.<br>Configuration rules:<br>- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)<br>- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)|
| backgroundModes | Continuous tasks of the UIAbility component. <br>Continuous tasks are classified into the following types:<br>- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.<br>- **audioPlayback**: audio playback service.<br>- **audioRecording**: audio recording service.<br>- **location**: location and navigation services.<br>- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).<br>- **multiDeviceConnection**: multi-device interconnection service.<br>- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)<br>- **voip**: voice/video call and VoIP services.<br>- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)|
| startWindowIcon | Index to the icon file of the UIAbility component startup page. Example: **$media:icon**.<br>The value is a string with a maximum of 255 bytes.| String| No|
| startWindowBackground | Index to the background color resource file of the UIAbility component startup page. Example: **$color:red**.<br>The value is a string with a maximum of 255 bytes.| String| No|
......
......@@ -10,7 +10,7 @@ Quick fix is a technical means provided by the OpenHarmony system for developers
* The bundle name and application version number configured in the quick fix package must be the same as those of the installed application. Otherwise, the deployment will fail.
* Make sure the version of the quick fix package to deploy is later than that of the one previously deployed. Otherwise, the deployment will fail.
* The signature information of the quick fix package must be the same as that of the application to be fixed. Otherwise, the deployment will fail.
* Installing an application update will delete quick fix package.
* Installing an application update will delete the quick fix package.
## Structure of the Quick Fix Package
......
......@@ -10,7 +10,7 @@
## Creating an ArkTS Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next.
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png)
......
......@@ -10,7 +10,7 @@
## Creating an ArkTS Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next.
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png)
......
......@@ -8,7 +8,7 @@
## Creating a JavaScript Project
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click Next.
1. If you are opening DevEco Studio for the first time, click **Create Project**. If a project is already open, choose **File** > **New** > **Create Project** from the menu bar. On the **Choose Your Ability Template** page, select **Application** (or **Atomic Service**, depending on your project), select **Empty Ability** as the template, and click **Next**.
![createProject](figures/createProject.png)
......
......@@ -3,6 +3,7 @@
The **CommonEvent** module provides common event capabilities, including the capabilities to publish, subscribe to, and unsubscribe from common events, as well obtaining and setting the common event result code and result data.
> **NOTE**
>
> - The APIs provided by this module are no longer maintained since API version 9. You are advised to use [@ohos.commonEventManager](js-apis-commonEventManager.md).
>
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -19,14 +20,16 @@ A system common event is an event that is published by a system service or syste
For details about the definitions of all system common events, see [System Common Events](./commonEvent-definitions.md).
## CommonEvent.publish
## CommonEvent.publish<sup>(deprecated)</sup>
```ts
publish(event: string, callback: AsyncCallback<void>): void
```
publish(event: string, callback: AsyncCallback\<void>): void
Publishes a common event. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.publish](js-apis-commonEventManager.md#commoneventmanagerpublish) instead.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
......@@ -52,14 +55,16 @@ function publishCB(err) {
CommonEvent.publish("event", publishCB);
```
## CommonEvent.publish
## CommonEvent.publish<sup>(deprecated)</sup>
```ts
publish(event: string, options: CommonEventPublishData, callback: AsyncCallback<void>): void
```
publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
Publishes a common event with given attributes. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.publish](js-apis-commonEventManager.md#commoneventmanagerpublish-1) instead.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
......@@ -68,7 +73,7 @@ Publishes a common event with given attributes. This API uses an asynchronous ca
| -------- | ---------------------- | ---- | ---------------------- |
| event | string | Yes | Name of the common event to publish. |
| options | [CommonEventPublishData](./js-apis-inner-commonEvent-commonEventPublishData.md) | Yes | Attributes of the common event to publish.|
| callback | syncCallback\<void> | Yes | Callback used to return the result. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
......@@ -94,14 +99,16 @@ function publishCB(err) {
CommonEvent.publish("event", options, publishCB);
```
## CommonEvent.publishAsUser<sup>8+</sup>
## CommonEvent.publishAsUser<sup>(deprecated)</sup>
```ts
publishAsUser(event: string, userId: number, callback: AsyncCallback<void>): void
```
publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): void
Publishes a common event to a specific user. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [commonEventManager.publishAsUser](js-apis-commonEventManager.md#commoneventmanagerpublishasuser) instead.
**System capability**: SystemCapability.Notification.CommonEvent
**System API**: This is a system API and cannot be called by third-party applications.
......@@ -133,14 +140,16 @@ let userId = 100;
CommonEvent.publishAsUser("event", userId, publishCB);
```
## CommonEvent.publishAsUser<sup>8+</sup>
## CommonEvent.publishAsUser<sup>(deprecated)</sup>
```ts
publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback<void>): void
```
publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
Publishes a common event with given attributes to a specific user. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [commonEventManager.publishAsUser](js-apis-commonEventManager.md#commoneventmanagerpublishasuser-1) instead.
**System capability**: SystemCapability.Notification.CommonEvent
**System API**: This is a system API and cannot be called by third-party applications.
......@@ -180,14 +189,16 @@ let userId = 100;
CommonEvent.publishAsUser("event", userId, options, publishCB);
```
## CommonEvent.createSubscriber
## CommonEvent.createSubscriber<sup>(deprecated)</sup>
```ts
createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback<CommonEventSubscriber>): void
```
createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void
Creates a subscriber. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.createSubscriber](js-apis-commonEventManager.md#commoneventmanagercreatesubscriber) instead.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
......@@ -222,14 +233,16 @@ function createCB(err, commonEventSubscriber) {
CommonEvent.createSubscriber(subscribeInfo, createCB);
```
## CommonEvent.createSubscriber
## CommonEvent.createSubscriber<sup>(deprecated)</sup>
```ts
createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise<CommonEventSubscriber>
```
createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber>
Creates a subscriber. This API uses a promise to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.createSubscriber](js-apis-commonEventManager.md#commoneventmanagercreatesubscriber-1) instead.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
......@@ -262,14 +275,16 @@ CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => {
});
```
## CommonEvent.subscribe
## CommonEvent.subscribe<sup>(deprecated)</sup>
```ts
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback<CommonEventData>): void
```
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void
Subscribes to common events. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.subscribe](js-apis-commonEventManager.md#commoneventmanagersubscribe) instead.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
......@@ -314,14 +329,16 @@ function createCB(err, commonEventSubscriber) {
CommonEvent.createSubscriber(subscribeInfo, createCB);
```
## CommonEvent.unsubscribe
## CommonEvent.unsubscribe<sup>(deprecated)</sup>
```ts
unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback<void>): void
```
unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void
Unsubscribes from common events. This API uses an asynchronous callback to return the result.
> **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [commonEventManager.subscribe](js-apis-commonEventManager.md#commoneventmanagerunsubscribe) instead.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
......
......@@ -39,7 +39,6 @@ Publishes a common event and executes an asynchronous callback after the event i
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
......@@ -87,7 +86,6 @@ Publishes a common event with given attributes. This API uses an asynchronous ca
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
......@@ -144,8 +142,6 @@ Publishes a common event to a specific user. This API uses an asynchronous callb
| ID| Error Message |
| -------- | ----------------------------------- |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
......@@ -199,9 +195,7 @@ Publishes a common event with given attributes to a specific user. This API uses
| ID| Error Message |
| -------- | ----------------------------------- |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not System services. |
| 1500004 | not System services or System app. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
| 1500009 | error obtaining system parameters. |
......@@ -251,17 +245,8 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul
| subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. |
| callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
**Example**
```ts
let subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
......@@ -307,14 +292,6 @@ Creates a subscriber. This API uses a promise to return the result.
| --------------------------------------------------------- | ---------------- |
| Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Promise used to return the subscriber object.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
**Example**
```ts
......@@ -356,7 +333,6 @@ Subscribes to common events. This API uses an asynchronous callback to return th
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 801 | capability not supported. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
......@@ -426,7 +402,6 @@ Unsubscribes from common events. This API uses an asynchronous callback to retur
| ID| Error Message |
| -------- | ----------------------------------- |
| 401 | The parameter check failed. |
| 801 | capability not supported. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
......@@ -495,6 +470,8 @@ Removes a sticky common event. This API uses an asynchronous callback to return
**Required permissions**: ohos.permission.COMMONEVENT_STICKY
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
......@@ -508,12 +485,9 @@ Removes a sticky common event. This API uses an asynchronous callback to return
| ID| Error Message |
| -------- | ----------------------------------- |
| 201 | The application dose not have permission to call the interface. |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not system service. |
| 1500007 | The message send error. |
| 1500008 | The CEMS error. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
**Example**
......@@ -525,7 +499,6 @@ CommonEventManager.removeStickyCommonEvent("sticky_event", (err) => {
return;
}
console.info(`Remove sticky event AsyncCallback success`);
}
});
```
......@@ -539,6 +512,8 @@ Removes a sticky common event. This API uses a promise to return the result.
**Required permissions**: ohos.permission.COMMONEVENT_STICKY
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -557,20 +532,102 @@ Removes a sticky common event. This API uses a promise to return the result.
| ID| Error Message |
| -------- | ----------------------------------- |
| 201 | The application dose not have permission to call the interface. |
| 202 | not system app. |
| 401 | The parameter check failed. |
| 1500004 | not system service. |
| 1500007 | The message send error. |
| 1500008 | The CEMS error. |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
**Example**
```ts
commonEventManager.removeStickyCommonEvent("sticky_event").then(() => {
CommonEventManager.removeStickyCommonEvent("sticky_event").then(() => {
console.info(`Remove sticky event AsyncCallback success`);
}).catch ((err) => {
console.info(`Remove sticky event AsyncCallback failed, errCode: ${err.code}, errMes: ${err.message}`);
});
```
## CommonEventManager.setStaticSubscriberState<sup>10+</sup>
setStaticSubscriberState(enable: boolean, callback: AsyncCallback\<void>): void;
Enables or disables static subscription for the current application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------- |
| enable | boolean | Yes | Whether static subscription is enabled.<br> **true**: enabled.<br>**false**: disabled.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
**Example**
```ts
CommonEventManager.setStaticSubscriberState(true, (err) => {
if (!err) {
console.info(`Set static subscriber state callback failed, err is null.`);
return;
}
if (err.code) {
console.info(`Set static subscriber state callback failed, errCode: ${err.code}, errMes: ${err.message}`);
return;
}
console.info(`Set static subscriber state callback success`);
});
```
## CommonEventManager.setStaticSubscriberState<sup>10+</sup>
setStaticSubscriberState(enable: boolean): Promise\<void>;
Enables or disables static subscription for the current application. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------- |
| enable | boolean | Yes | Whether static subscription is enabled.<br> **true**: enabled.<br>**false**: disabled.|
**Return value**
| Type | Description |
| -------------- | ---------------------------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md).
| ID| Error Message |
| -------- | ----------------------------------- |
| 1500007 | error sending message to Common Event Service. |
| 1500008 | Common Event Service does not complete initialization. |
**Example**
```ts
CommonEventManager.setStaticSubscriberState(false).then(() => {
console.info(`Set static subscriber state promise success`);
}).catch ((err) => {
console.info(`Set static subscriber state promise failed, errCode: ${err.code}, errMes: ${err.message}`);
});
```
# CommonEventData
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description |
......
# CommonEventPublishData
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description |
......
# CommonEventSubscribeInfo
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description |
......
# CommonEventSubscriber
## getCode
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Usage
Before using the **CommonEventSubscriber** module, you must obtain a **subscriber** object by calling **CommonEvent.createSubscriber**.
```ts
getCode(callback: AsyncCallback<number>): void
import CommonEvent from '@ohos.commonEvent';
let subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information.
let subscribeInfo = {
events: ["event"]
};
// Callback for subscriber creation.
function createCB(err, commonEventSubscriber) {
if (err.code) {
console.error(`createSubscriber failed, code is ${err.code}`);
} else {
console.info("createSubscriber");
subscriber = commonEventSubscriber;
}
}
// Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, createCB);
```
## getCode
getCode(callback: AsyncCallback\<number>): void
Obtains the code of this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
......@@ -19,8 +48,6 @@ Obtains the code of this common event. This API uses an asynchronous callback to
**Example**
```ts
let subscriber; // Subscriber object successfully created.
// Callback for result code obtaining of an ordered common event.
function getCodeCB(err, code) {
if (err.code) {
......@@ -34,9 +61,7 @@ subscriber.getCode(getCodeCB);
## getCode
```ts
getCode(): Promise<number>
```
getCode(): Promise\<number>
Obtains the code of this common event. This API uses a promise to return the result.
......@@ -51,8 +76,6 @@ Obtains the code of this common event. This API uses a promise to return the res
**Example**
```ts
let subscriber; // Subscriber object successfully created.
subscriber.getCode().then((code) => {
console.info("getCode " + JSON.stringify(code));
}).catch((err) => {
......@@ -62,9 +85,7 @@ subscriber.getCode().then((code) => {
## setCode
```ts
setCode(code: number, callback: AsyncCallback<void>): void
```
setCode(code: number, callback: AsyncCallback\<void>): void
Sets the code for this common event. This API uses an asynchronous callback to return the result.
......@@ -80,8 +101,6 @@ Sets the code for this common event. This API uses an asynchronous callback to r
**Example**
```ts
let subscriber; // Subscriber object successfully created.
// Callback for result code setting of an ordered common event.
function setCodeCB(err) {
if (err.code) {
......@@ -95,9 +114,7 @@ subscriber.setCode(1, setCodeCB);
## setCode
```ts
setCode(code: number): Promise<void>
```
setCode(code: number): Promise\<void>
Sets the code for this common event. This API uses a promise to return the result.
......@@ -118,8 +135,6 @@ Sets the code for this common event. This API uses a promise to return the resul
**Example**
```ts
let subscriber; // Subscriber object successfully created.
subscriber.setCode(1).then(() => {
console.info("setCode");
}).catch((err) => {
......@@ -129,9 +144,7 @@ subscriber.setCode(1).then(() => {
## getData
```ts
getData(callback: AsyncCallback<string>): void
```
getData(callback: AsyncCallback\<string>): void
Obtains the data of this common event. This API uses an asynchronous callback to return the result.
......@@ -146,8 +159,6 @@ Obtains the data of this common event. This API uses an asynchronous callback to
**Example**
```ts
let subscriber; // Subscriber object successfully created.
// Callback for result data obtaining of an ordered common event.
function getDataCB(err, data) {
if (err.code) {
......@@ -161,9 +172,7 @@ subscriber.getData(getDataCB);
## getData
```ts
getData(): Promise<string>
```
getData(): Promise\<string>
Obtains the data of this common event. This API uses a promise to return the result.
......@@ -178,8 +187,6 @@ Obtains the data of this common event. This API uses a promise to return the res
**Example**
```ts
let subscriber; // Subscriber object successfully created.
subscriber.getData().then((data) => {
console.info("getData " + JSON.stringify(data));
}).catch((err) => {
......@@ -205,8 +212,6 @@ Sets the data for this common event. This API uses an asynchronous callback to r
**Example**
```ts
let subscriber; // Subscriber object successfully created.
// Callback for result data setting of an ordered common event
function setDataCB(err) {
if (err.code) {
......@@ -220,9 +225,7 @@ subscriber.setData("publish_data_changed", setDataCB);
## setData
```ts
setData(data: string): Promise<void>
```
setData(data: string): Promise\<void>
Sets the data for this common event. This API uses a promise to return the result.
......@@ -243,8 +246,6 @@ Sets the data for this common event. This API uses a promise to return the resul
**Example**
```ts
let subscriber; // Subscriber object successfully created.
subscriber.setData("publish_data_changed").then(() => {
console.info("setData");
}).catch((err) => {
......@@ -254,9 +255,7 @@ subscriber.setData("publish_data_changed").then(() => {
## setCodeAndData
```ts
setCodeAndData(code: number, data: string, callback:AsyncCallback<void>): void
```
setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
Sets the code and data for this common event. This API uses an asynchronous callback to return the result.
......@@ -273,8 +272,6 @@ Sets the code and data for this common event. This API uses an asynchronous call
**Example**
```ts
let subscriber; // Subscriber object successfully created.
// Callback for code and data setting of an ordered common event.
function setCodeDataCB(err) {
if (err.code) {
......@@ -288,9 +285,7 @@ subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCB);
## setCodeAndData
```ts
setCodeAndData(code: number, data: string): Promise<void>
```
setCodeAndData(code: number, data: string): Promise\<void>
Sets the code and data for this common event. This API uses a promise to return the result.
......@@ -312,8 +307,6 @@ Sets the code and data for this common event. This API uses a promise to return
**Example**
```ts
let subscriber; // Subscriber object successfully created.
subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
console.info("setCodeAndData");
}).catch((err) => {
......@@ -323,9 +316,7 @@ subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
## isOrderedCommonEvent
```ts
isOrderedCommonEvent(callback: AsyncCallback<boolean>): void
```
isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result.
......@@ -340,8 +331,6 @@ Checks whether this common event is an ordered one. This API uses an asynchronou
**Example**
```ts
let subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is an ordered one.
function isOrderedCB(err, isOrdered) {
if (err.code) {
......@@ -355,9 +344,7 @@ subscriber.isOrderedCommonEvent(isOrderedCB);
## isOrderedCommonEvent
```ts
isOrderedCommonEvent(): Promise<boolean>
```
isOrderedCommonEvent(): Promise\<boolean>
Checks whether this common event is an ordered one. This API uses a promise to return the result.
......@@ -372,8 +359,6 @@ Checks whether this common event is an ordered one. This API uses a promise to r
**Example**
```ts
let subscriber; // Subscriber object successfully created.
subscriber.isOrderedCommonEvent().then((isOrdered) => {
console.info("isOrdered " + JSON.stringify(isOrdered));
}).catch((err) => {
......@@ -383,9 +368,7 @@ subscriber.isOrderedCommonEvent().then((isOrdered) => {
## isStickyCommonEvent
```ts
isStickyCommonEvent(callback: AsyncCallback<boolean>): void
```
isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result.
......@@ -400,8 +383,6 @@ Checks whether this common event is a sticky one. This API uses an asynchronous
**Example**
```ts
let subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is a sticky one.
function isStickyCB(err, isSticky) {
if (err.code) {
......@@ -415,9 +396,7 @@ subscriber.isStickyCommonEvent(isStickyCB);
## isStickyCommonEvent
```ts
isStickyCommonEvent(): Promise<boolean>
```
isStickyCommonEvent(): Promise\<boolean>
Checks whether this common event is a sticky one. This API uses a promise to return the result.
......@@ -432,8 +411,6 @@ Checks whether this common event is a sticky one. This API uses a promise to ret
**Example**
```ts
let subscriber; // Subscriber object successfully created.
subscriber.isStickyCommonEvent().then((isSticky) => {
console.info("isSticky " + JSON.stringify(isSticky));
}).catch((err) => {
......@@ -443,9 +420,7 @@ subscriber.isStickyCommonEvent().then((isSticky) => {
## abortCommonEvent
```ts
abortCommonEvent(callback: AsyncCallback<void>): void
```
abortCommonEvent(callback: AsyncCallback\<void>): void
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
......@@ -460,8 +435,6 @@ Aborts this common event. After the abort, the common event is not sent to the n
**Example**
```ts
let subscriber; // Subscriber object successfully created.
// Callback for common event aborting.
function abortCB(err) {
if (err.code) {
......@@ -475,9 +448,7 @@ subscriber.abortCommonEvent(abortCB);
## abortCommonEvent
```ts
abortCommonEvent(): Promise<void>
```
abortCommonEvent(): Promise\<void>
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This API takes effect only for ordered common events. It uses a promise to return the result.
......@@ -492,8 +463,6 @@ Aborts this common event. After the abort, the common event is not sent to the n
**Example**
```ts
let subscriber; // Subscriber object successfully created.
subscriber.abortCommonEvent().then(() => {
console.info("abortCommonEvent");
}).catch((err) => {
......@@ -503,9 +472,7 @@ subscriber.abortCommonEvent().then(() => {
## clearAbortCommonEvent
```ts
clearAbortCommonEvent(callback: AsyncCallback<void>): void
```
clearAbortCommonEvent(callback: AsyncCallback\<void>): void
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
......@@ -520,8 +487,6 @@ Clears the aborted state of this common event. This API takes effect only for or
**Example**
```ts
let subscriber; // Subscriber object successfully created.
// Callback for clearing the aborted state of the current common event.
function clearAbortCB(err) {
if (err.code) {
......@@ -535,9 +500,7 @@ subscriber.clearAbortCommonEvent(clearAbortCB);
## clearAbortCommonEvent
```ts
clearAbortCommonEvent(): Promise<void>
```
clearAbortCommonEvent(): Promise\<void>
Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses a promise to return the result.
......@@ -552,8 +515,6 @@ Clears the aborted state of this common event. This API takes effect only for or
**Example**
```ts
let subscriber; // Subscriber object successfully created.
subscriber.clearAbortCommonEvent().then(() => {
console.info("clearAbortCommonEvent");
}).catch((err) => {
......@@ -563,9 +524,7 @@ subscriber.clearAbortCommonEvent().then(() => {
## getAbortCommonEvent
```ts
getAbortCommonEvent(callback: AsyncCallback<boolean>): void
```
getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
......@@ -580,8 +539,6 @@ Checks whether this common event is in the aborted state. This API takes effect
**Example**
```ts
let subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is in the aborted state.
function getAbortCB(err, abortEvent) {
if (err.code) {
......@@ -595,9 +552,7 @@ subscriber.getAbortCommonEvent(getAbortCB);
## getAbortCommonEvent
```ts
getAbortCommonEvent(): Promise<boolean>
```
getAbortCommonEvent(): Promise\<boolean>
Checks whether this common event is in the aborted state. This API takes effect only for ordered common events. It uses a promise to return the result.
......@@ -612,8 +567,6 @@ Checks whether this common event is in the aborted state. This API takes effect
**Example**
```ts
let subscriber; // Subscriber object successfully created.
subscriber.getAbortCommonEvent().then((abortEvent) => {
console.info("abortCommonEvent " + JSON.stringify(abortEvent));
}).catch((err) => {
......@@ -623,9 +576,7 @@ subscriber.getAbortCommonEvent().then((abortEvent) => {
## getSubscribeInfo
```ts
getSubscribeInfo(callback: AsyncCallback<CommonEventSubscribeInfo>): void
```
getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
Obtains the subscriber information. This API uses an asynchronous callback to return the result.
......@@ -640,8 +591,6 @@ Obtains the subscriber information. This API uses an asynchronous callback to re
**Example**
```ts
let subscriber; // Subscriber object successfully created.
// Callback for subscriber information obtaining.
function getCB(err, subscribeInfo) {
if (err.code) {
......@@ -655,9 +604,7 @@ subscriber.getSubscribeInfo(getCB);
## getSubscribeInfo
```ts
getSubscribeInfo(): Promise<CommonEventSubscribeInfo>
```
getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
Obtains the subscriber information. This API uses a promise to return the result.
......@@ -672,8 +619,6 @@ Obtains the subscriber information. This API uses a promise to return the result
**Example**
```ts
let subscriber; // Subscriber object successfully created.
subscriber.getSubscribeInfo().then((subscribeInfo) => {
console.info("subscribeInfo " + JSON.stringify(subscribeInfo));
}).catch((err) => {
......@@ -683,9 +628,7 @@ subscriber.getSubscribeInfo().then((subscribeInfo) => {
## finishCommonEvent<sup>9+</sup>
```ts
finishCommonEvent(callback: AsyncCallback<void>): void
```
finishCommonEvent(callback: AsyncCallback\<void>): void
Finishes this common event. This API takes effect only for ordered common events. It uses an asynchronous callback to return the result.
......@@ -700,14 +643,13 @@ Finishes this common event. This API takes effect only for ordered common events
**Example**
```ts
let subscriber; // Subscriber object successfully created.
// Callback for ordered common event finishing.
function finishCB(err) {
if (err.code) {
console.error(`finishCommonEvent failed, code is ${err.code}, message is ${err.message}`);
} else {
} else {
console.info("FinishCommonEvent");
}
}
subscriber.finishCommonEvent(finishCB);
......@@ -715,9 +657,7 @@ subscriber.finishCommonEvent(finishCB);
## finishCommonEvent<sup>9+</sup>
```ts
finishCommonEvent(): Promise<void\>
```
finishCommonEvent(): Promise\<void>
Finishes this common event. This API takes effect only for ordered common events. It uses a promise to return the result.
......@@ -732,8 +672,6 @@ Finishes this common event. This API takes effect only for ordered common events
**Example**
```ts
let subscriber; // Subscriber object successfully created.
subscriber.finishCommonEvent().then(() => {
console.info("FinishCommonEvent");
}).catch((err) => {
......
......@@ -8,9 +8,9 @@ The **NotificationActionButton** module describes the button displayed in the no
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| Name | Type | Read-only| Mandatory| Description |
| --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title | string | Yes | Yes | Button title. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** of the button.|
| extras | { [key: string]: any } | Yes | Yes | Extra information of the button. |
| userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | Yes | Yes | User input object. |
| title | string | No | Yes | Button title. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | No | Yes | **WantAgent** of the button.|
| extras | { [key: string]: any } | No | No | Extra information of the button. |
| userInput<sup>8+</sup> | [NotificationUserInput](js-apis-inner-notification-notificationUserInput.md) | No | No | User input object. |
......@@ -10,7 +10,7 @@ Provides the bundle information of an application.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Mandatory| Description |
| ------ | ------ |---- | ------ |
| bundle | string | Yes| Bundle information of the application.|
| uid | number | No| User ID.|
| Name | Type | Read-only| Mandatory| Description |
| ------ | ------ | ---- | ---- | ------ |
| bundle | string | No | Yes| Bundle information of the application.|
| uid | number | No | No| User ID.|
......@@ -8,13 +8,13 @@ The **NotificationContent** module describes the notification content.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| Name | Type | Read-only| Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
| contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | Yes | Yes | Notification content type. |
| normal | [NotificationBasicContent](#notificationbasiccontent) | Yes | Yes | Normal text. |
| longText | [NotificationLongTextContent](#notificationlongtextcontent) | Yes | Yes | Long text.|
| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text. |
| picture | [NotificationPictureContent](#notificationpicturecontent) | Yes | Yes | Picture-attached. |
| contentType | [ContentType](./js-apis-notificationManager.md#contenttype) | No | Yes | Notification content type. |
| normal | [NotificationBasicContent](#notificationbasiccontent) | No | No | Normal text. |
| longText | [NotificationLongTextContent](#notificationlongtextcontent) | No | No | Long text.|
| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | No | No | Multi-line text. |
| picture | [NotificationPictureContent](#notificationpicturecontent) | No | No | Picture-attached. |
## NotificationBasicContent
......@@ -22,11 +22,11 @@ Describes the normal text notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| Name | Type | Read-only| Mandatory| Description |
| -------------- | ------ | ---- | ---- | ---------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| title | string | No | Yes | Notification title. |
| text | string | No | Yes | Notification content. |
| additionalText | string | No | No | Additional information of the notification.|
## NotificationLongTextContent
......@@ -35,14 +35,14 @@ Describes the long text notification.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| Name | Type | Read-only| Mandatory| Description |
| -------------- | ------ | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| longText | string | Yes | Yes | Long text of the notification. |
| briefText | string | Yes | Yes | Brief text of the notification.|
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. |
| title | string | No | Yes | Notification title. |
| text | string | No | Yes | Notification content. |
| additionalText | string | No | No | Additional information of the notification.|
| longText | string | No | Yes | Long text of the notification. |
| briefText | string | No | Yes | Brief text of the notification. |
| expandedTitle | string | No | Yes | Title of the notification in the expanded state. |
## NotificationMultiLineContent
......@@ -53,12 +53,12 @@ Describes the multi-line text notification.
| Name | Type | Readable| Writable| Description |
| -------------- | --------------- | --- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.|
| longTitle | string | Yes | Yes | Title of the notification in the expanded state. |
| lines | Array\<string\> | Yes | Yes | Multi-line text of the notification. |
| title | string | No | Yes | Notification title. |
| text | string | No | Yes | Notification content. |
| additionalText | string | No | No | Additional information of the notification.|
| briefText | string | No | Yes | Brief text of the notification.|
| longTitle | string | No | Yes | Title of the notification in the expanded state. |
| lines | Array\<string\> | No | Yes | Multi-line text of the notification. |
## NotificationPictureContent
......@@ -69,9 +69,9 @@ Describes the picture-attached notification.
| Name | Type | Readable| Writable| Description |
| -------------- | -------------- | ---- | --- | -------------------------------- |
| title | string | Yes | Yes | Notification title. |
| text | string | Yes | Yes | Notification content. |
| additionalText | string | Yes | Yes | Additional information of the notification.|
| briefText | string | Yes | Yes | Brief text of the notification.|
| expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. |
| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Picture attached to the notification. |
| title | string | No | Yes | Notification title. |
| text | string | No | Yes | Notification content. |
| additionalText | string | No | No | Additional information of the notification.|
| briefText | string | No | Yes | Brief text of the notification.|
| expandedTitle | string | No | Yes | Title of the notification in the expanded state. |
| picture | [image.PixelMap](js-apis-image.md#pixelmap7) | No | Yes | Picture attached to the notification. |
......@@ -8,7 +8,7 @@ The **NotificationFlags** module implements a **NotificationFlags** instance.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| Name | Type | Read-only| Mandatory| Description |
| ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable the sound alert for the notification. |
| vibrationEnabled | [NotificationFlagStatus](#notificationflagstatus) | Yes | No | Whether to enable vibration for the notification. |
......
......@@ -8,45 +8,45 @@ The **NotificationRequest** module describes the notification request.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| Name | Type | Read-only| Mandatory| Description |
| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | Yes | Yes | Notification content. |
| id | number | Yes | Yes | Notification ID. |
| slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | Yes | Notification slot type. |
| isOngoing | boolean | Yes | Yes | Whether the notification is an ongoing notification. |
| isUnremovable | boolean | Yes | Yes | Whether the notification can be removed. |
| deliveryTime | number | Yes | Yes | Time when the notification is sent. |
| tapDismissed | boolean | Yes | Yes | Whether the notification is automatically cleared. |
| autoDeletedTime | number | Yes | Yes | Time when the notification is automatically cleared. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected after being clicked.|
| extraInfo | {[key: string]: any} | Yes | Yes | Extended parameters. |
| color | number | Yes | Yes | Background color of the notification. Not supported currently.|
| colorEnabled | boolean | Yes | Yes | Whether the notification background color can be enabled. Not supported currently.|
| isAlertOnce | boolean | Yes | Yes | Whether the notification triggers an alert only once.|
| isStopwatch | boolean | Yes | Yes | Whether to display the stopwatch. |
| isCountDown | boolean | Yes | Yes | Whether to display the countdown time. |
| isFloatingIcon | boolean | Yes | Yes | Whether the notification is displayed as a floating icon in the status bar. |
| label | string | Yes | Yes | Notification label. |
| badgeIconStyle | number | Yes | Yes | Notification badge type. |
| showDeliveryTime | boolean | Yes | Yes | Whether to display the time when the notification is delivered. |
| actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | Yes | Yes | Buttons in the notification. Up to three buttons are allowed. |
| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB.|
| largeIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes | Yes | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB.|
| content | [NotificationContent](js-apis-inner-notification-notificationContent.md#notificationcontent) | No | Yes | Notification content. |
| id | number | No | No | Notification ID. |
| slotType | [SlotType](js-apis-notificationManager.md#slottype) | Yes | No | Notification slot type. |
| isOngoing | boolean | No | No | Whether the notification is an ongoing notification. |
| isUnremovable | boolean | No | No | Whether the notification can be removed. |
| deliveryTime | number | No | No | Time when the notification is sent. |
| tapDismissed | boolean | No | No | Whether the notification is automatically cleared. |
| autoDeletedTime | number | No | No | Time when the notification is automatically cleared. |
| wantAgent | [WantAgent](js-apis-app-ability-wantAgent.md) | No | No | **WantAgent** instance to which the notification will be redirected after being clicked.|
| extraInfo | {[key: string]: any} | No | No | Extended parameters. |
| color | number | No | No | Background color of the notification. Not supported currently.|
| colorEnabled | boolean | No | No | Whether the notification background color can be enabled. Not supported currently.|
| isAlertOnce | boolean | No | No | Whether the notification triggers an alert only once.|
| isStopwatch | boolean | No | No | Whether to display the stopwatch. |
| isCountDown | boolean | No | No | Whether to display the countdown time. |
| isFloatingIcon | boolean | No | No | Whether the notification is displayed as a floating icon in the status bar. |
| label | string | No | No | Notification label. |
| badgeIconStyle | number | No | No | Notification badge type. Not supported currently. |
| showDeliveryTime | boolean | No | No | Whether to display the time when the notification is delivered. |
| actionButtons | Array\<[NotificationActionButton](js-apis-inner-notification-notificationActionButton.md)\> | No | No | Buttons in the notification. Up to three buttons are allowed. |
| smallIcon | [image.PixelMap](js-apis-image.md#pixelmap7) | No | 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 | No | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB.|
| creatorBundleName | string | Yes | No | Name of the bundle that creates the notification. |
| creatorUid<sup>8+<sup> | number | Yes | No | UID used for creating the notification. |
| creatorPid | number | Yes | No | PID used for creating the notification. |
| creatorUserId| number | Yes | No | ID of the user who creates the notification. |
| creatorUserId | number | Yes | No | ID of the user who creates the notification. |
| hashCode | string | Yes | No | Unique ID of the notification. |
| classification | string | Yes | Yes | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| groupName<sup>8+<sup> | string | Yes | Yes | Notification group name. |
| template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | Yes | Yes | Notification template. |
| classification | string | No | 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 | No | Notification group name. |
| template<sup>8+<sup> | [NotificationTemplate](./js-apis-inner-notification-notificationTemplate.md) | No | No | Notification template. |
| isRemoveAllowed<sup>8+<sup> | boolean | Yes | 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 | Yes | 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) | Yes | Yes | Distributed notification options. |
| distributedOption<sup>8+<sup> | [DistributedOptions](#distributedoptions) | No | No | Distributed notification options. |
| deviceId<sup>8+<sup> | string | Yes | 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#notificationFlags) | Yes | No | Notification flags. |
| removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected when it is removed. |
| badgeNumber<sup>9+<sup> | number | Yes | Yes | Number of notifications displayed on the application icon. |
| notificationFlags<sup>8+<sup> | [NotificationFlags](js-apis-inner-notification-notificationFlags.md#notificationflags) | Yes | No | Notification flags. |
| removalWantAgent<sup>9+<sup> | [WantAgent](js-apis-app-ability-wantAgent.md) | No | No | **WantAgent** instance to which the notification will be redirected when it is removed. |
| badgeNumber<sup>9+<sup> | number | No | No | Number of notifications displayed on the application icon. |
## DistributedOptions
......@@ -55,9 +55,9 @@ Describes distributed notification options.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| Name | Type | Read-only| Mandatory| Description |
| ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed<sup>8+<sup> | boolean | Yes | Yes | Whether the notification is a distributed notification. |
| supportDisplayDevices<sup>8+<sup> | Array\<string> | Yes | Yes | List of the devices to which the notification can be synchronized. |
| supportOperateDevices<sup>8+<sup> | Array\<string> | Yes | Yes | List of the devices on which the notification can be opened. |
| isDistributed<sup>8+<sup> | boolean | No | No | Whether the notification is a distributed notification. |
| supportDisplayDevices<sup>8+<sup> | Array\<string> | No | No | List of the devices to which the notification can be synchronized. |
| supportOperateDevices<sup>8+<sup> | Array\<string> | No | No | List of the devices on which the notification can be opened. |
| remindType<sup>8+<sup> | number | Yes | No | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications. |
......@@ -8,17 +8,17 @@ The **NotificationSlot** module describes the notification slot.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| type | [SlotType](js-apis-notificationManager.md#slottype) | Yes | Yes | Notification slot type. |
| level | number | Yes | Yes | Notification level. If this parameter is not set, the default value that corresponds to the notification slot type is used.|
| desc | string | Yes | Yes | Notification slot description. |
| badgeFlag | boolean | Yes | Yes | Whether to display the badge. |
| bypassDnd | boolean | Yes | Yes | Whether to bypass DND mode in the system. |
| lockscreenVisibility | number | Yes | Yes | Mode for displaying the notification on the lock screen. |
| vibrationEnabled | boolean | Yes | Yes | Whether to enable vibration for the notification. |
| sound | string | Yes | Yes | Notification alert tone. |
| lightEnabled | boolean | Yes | Yes | Whether the indicator blinks for the notification. |
| lightColor | number | Yes | Yes | Indicator color of the notification. |
| vibrationValues | Array\<number\> | Yes | Yes | Vibration mode of the notification. |
| type | [SlotType](js-apis-notificationManager.md#slottype) | No | Yes | Notification slot type. |
| level | number | No | No | Notification level. If this parameter is not set, the default value that corresponds to the notification slot type is used.|
| desc | string | No | No | Notification slot description. |
| badgeFlag | boolean | No | No | Whether to display the badge. |
| bypassDnd | boolean | No | No | Whether to bypass DND mode in the system. |
| lockscreenVisibility | number | No | No | Mode for displaying the notification on the lock screen. |
| vibrationEnabled | boolean | No | No | Whether to enable vibration for the notification. |
| sound | string | No | No | Notification alert tone. |
| lightEnabled | boolean | No | No | Whether the indicator blinks for the notification. |
| lightColor | number | No | No | Indicator color of the notification. |
| vibrationValues | Array\<number\> | No | No | Vibration mode of the notification. |
| enabled<sup>9+</sup> | boolean | Yes | No | Whether the notification slot is enabled. |
# NotificationSorting
Provides sorting information of active notifications.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| slot | [NotificationSlot](js-apis-inner-notification-notificationSlot.md) | Yes | Yes | Notification slot type. |
| level | number | Yes | Yes | Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
| desc | string | Yes | Yes | Description of the notification slot. |
# NotificationSortingMap
Provides sorting information of active notifications in all subscribed notifications.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| sortings | { [key: string]: [NotificationSorting](js-apis-inner-notification-notificationSorting.md) } | Yes | Yes | Array of notification sorting information.|
| sortedHashCode | Array\<string> | Yes | Yes | Hash codes for notification sorting.|
# NotificationSubscribeInfo
Provides the information about the publisher for notification subscription.
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| bundleNames | Array\<string> | No | No | Bundle names of the applications whose notifications are to be subscribed to. |
| userId | number | No | No | User ID. |
# NotificationSubscriber
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](js-apis-notificationSubscribe.md).
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import notificationSubscribe from '@ohos.notificationSubscribe';
```
**System API**: This is a system API and cannot be called by third-party applications.
### onConsume
onConsume?: (data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
Called when a new notification is received.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | Yes| Information about the notification received.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onConsumeCallback(data) {
console.info('===> onConsume in test');
let req = data.request;
console.info('===> onConsume callback req.id:' + req.id);
};
let subscriber = {
onConsume: onConsumeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onCancel
onCancel?:(data: [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata)) => void
Called when a notification is canceled.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [SubscribeCallbackData](js-apis-notification.md#subscribecallbackdata) | Yes| Information about the notification to cancel.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onCancelCallback(data) {
console.info('===> onCancel in test');
let req = data.request;
console.info('===> onCancel callback req.id:' + req.id);
}
let subscriber = {
onCancel: onCancelCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onUpdate
onUpdate?:(data: [NotificationSortingMap](js-apis-notification.md#notificationsortingmap)) => void
Called when notification sorting is updated.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| data | [NotificationSortingMap](js-apis-notification.md#notificationsortingmap) | Yes| Latest notification sorting list.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onUpdateCallback(map) {
console.info('===> onUpdateCallback map:' + JSON.stringify(map));
}
let subscriber = {
onUpdate: onUpdateCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onConnect
onConnect?:() => void
Called when the subscription is complete.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
let subscriber = {
onConnect: onConnectCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onDisconnect
onDisconnect?:() => void
Called when unsubscription is complete.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function unsubscribeCallback(err) {
if (err.code) {
console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("unsubscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
}
function onDisconnectCallback() {
console.info('===> onDisconnect in test');
}
let subscriber = {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback
};
// The onConnect callback is invoked when subscription to the notification is complete.
notificationSubscribe.subscribe(subscriber, subscribeCallback);
// The onDisconnect callback is invoked when unsubscription to the notification is complete.
notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
```
### onDestroy
onDestroy?:() => void
Called when the service is disconnected.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onDestroyCallback() {
console.info('===> onDestroy in test');
}
let subscriber = {
onDestroy: onDestroyCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onDoNotDisturbDateChange<sup>8+</sup>
onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notificationManager.md#donotdisturbdate)) => void
Called when the DND time settings are changed.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| mode | notification.[DoNotDisturbDate](js-apis-notificationManager.md#DoNotDisturbDate) | Yes| DND time setting updates.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange:' + mode);
}
let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onEnabledNotificationChanged<sup>8+</sup>
onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata8)) => void
Listens for the notification enabled status changes.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[EnabledNotificationCallbackData](js-apis-notification.md#enablednotificationcallbackdata8)\> | Yes| Callback used to return the result.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onEnabledNotificationChangedCallback(callbackData) {
console.info("bundle: ", callbackData.bundle);
console.info("uid: ", callbackData.uid);
console.info("enable: ", callbackData.enable);
};
let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
### onBadgeChanged<sup>10+</sup>
onBadgeChanged?:(data: [BadgeNumberCallbackData](#badgenumbercallbackdata10)) => void
Listens for the change of the notification badge number.
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------- |
| callback | AsyncCallback\<[BadgeNumberCallbackData](#badgenumbercallbackdata10)\> | Yes | Callback used to return the result.|
**Example**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onBadgeChangedCallback(data) {
console.info("bundle: ", data.bundle);
console.info("uid: ", data.uid);
console.info("badgeNumber: ", data.badgeNumber);
};
let subscriber = {
onBadgeChanged: onBadgeChangedCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
## SubscribeCallbackData
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| --------------- | ------------------------------------------------- | ---- | --- | -------- |
| request | [NotificationRequest](js-apis-inner-notification-notificationRequest#notificationrequest) | Yes | Yes | Notification content.|
| sortingMap | [NotificationSortingMap](js-apis-inner-notification-notificationSortingMap.md) | Yes | No | Notification sorting information.|
| reason | number | Yes | No | Reason for deletion.|
| sound | string | Yes | No | Sound used for notification.|
| vibrationValues | Array\<number\> | Yes | No | Vibration used for notification.|
## EnabledNotificationCallbackData<sup>8+</sup>
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| ------ | ------- | ---- | --- | ---------------- |
| bundle | string | Yes | Yes | Bundle name of the application. |
| uid | number | Yes | Yes | UID of the application. |
| enable | boolean | Yes | Yes | Notification enabled status of the application.|
## BadgeNumberCallbackData<sup>10+</sup>
**System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Read-only| Mandatory| Description |
| ----------- | ------ | ---- | ---- | ------------ |
| bundle | string | Yes | Yes | Bundle name of the application.|
| uid | number | Yes | Yes | UID of the application. |
| badgeNumber | number | Yes | Yes | Number of notifications displayed on the application icon. |
......@@ -8,7 +8,7 @@ The **NotificationTemplate** module describes the notification template.
**System capability**: SystemCapability.Notification.Notification
| Name| Type | Readable| Writable| Description |
| Name| Type | Read-only| Mandatory| Description |
| ---- | ---------------------- | ---- | ---- | ---------- |
| name | string | Yes | Yes | Template name.|
| data | {[key:string]: Object} | Yes | Yes | Template data.|
| name | string | No | Yes | Template name.|
| data | {[key:string]: Object} | No | Yes | Template data.|
......@@ -8,6 +8,6 @@ The **NotificationUserInput** module provides the notification user input.
**System capability**: SystemCapability.Notification.Notification
| Name | Type | Readable| Writable| Description |
| Name | Type | Read-only| Mandatory| Description |
| -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | string | Yes | Yes | Key to identify the user input.|
| inputKey | string | No | Yes | Key to identify the user input.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册