提交 fedc0385 编写于 作者: E esterzhou

update docs

Signed-off-by: Nesterzhou <ester.zhou@huawei.com>
上级 e0f9450f
# CommonEvent # @ohos.commonEvent
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. 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** > **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. > - 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 ## Modules to Import
...@@ -14,7 +14,7 @@ import CommonEvent from '@ohos.commonEvent'; ...@@ -14,7 +14,7 @@ import CommonEvent from '@ohos.commonEvent';
## Support ## Support
Provides the event types supported by the **CommonEvent** module. The name and value indicate the macro and name of a common event, respectively. The table below lists the event types supported by the **CommonEvent** module. The name and value indicate the macro and name of a common event, respectively.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
...@@ -167,8 +167,8 @@ Provides the event types supported by the **CommonEvent** module. The name and v ...@@ -167,8 +167,8 @@ Provides the event types supported by the **CommonEvent** module. The name and v
| COMMON_EVENT_ACCOUNT_DELETED | usual.event.data.ACCOUNT_DELETED | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the account was deleted. | | COMMON_EVENT_ACCOUNT_DELETED | usual.event.data.ACCOUNT_DELETED | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the account was deleted. |
| COMMON_EVENT_FOUNDATION_READY | usual.event.data.FOUNDATION_READY | ohos.permission.RECEIVER_STARTUP_COMPLETED | Indicates the common event that the foundation is ready. | | COMMON_EVENT_FOUNDATION_READY | usual.event.data.FOUNDATION_READY | ohos.permission.RECEIVER_STARTUP_COMPLETED | Indicates the common event that the foundation is ready. |
| COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | - | Indicates the common event that the airplane mode of the device has changed. | | COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | - | Indicates the common event that the airplane mode of the device has changed. |
| COMMON_EVENT_SPLIT_SCREEN<sup>8+<sup> | usual.event.SPLIT_SCREEN | - | Indicates the common event of screen splitting. | | COMMON_EVENT_SPLIT_SCREEN<sup>8+<sup> | usual.event.SPLIT_SCREEN | - | Indicates the common event of screen splitting. |
| COMMON_EVENT_SLOT_CHANGE<sup>9+<sup> | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | Indicates the common event that the notification slot has changed. | | COMMON_EVENT_SLOT_CHANGE<sup>9+<sup> | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | Indicates the common event that the notification slot has been updated. |
| COMMON_EVENT_SPN_INFO_CHANGED <sup>9+<sup> | usual.event.SPN_INFO_CHANGED | - | Indicates the common event that the SPN displayed has been updated. | | COMMON_EVENT_SPN_INFO_CHANGED <sup>9+<sup> | usual.event.SPN_INFO_CHANGED | - | Indicates the common event that the SPN displayed has been updated. |
| COMMON_EVENT_QUICK_FIX_APPLY_RESULT <sup>9+<sup> | usual.event.QUICK_FIX_APPLY_RESULT | - | Indicates the common event that a quick fix is applied to the application. | | COMMON_EVENT_QUICK_FIX_APPLY_RESULT <sup>9+<sup> | usual.event.QUICK_FIX_APPLY_RESULT | - | Indicates the common event that a quick fix is applied to the application. |
...@@ -192,7 +192,7 @@ Publishes a common event. This API uses an asynchronous callback to return the r ...@@ -192,7 +192,7 @@ Publishes a common event. This API uses an asynchronous callback to return the r
```js ```js
// Callback for common event publication // Callback for common event publication
function PublishCallBack(err) { function publishCallBack(err) {
if (err.code) { if (err.code) {
console.error("publish failed " + JSON.stringify(err)); console.error("publish failed " + JSON.stringify(err));
} else { } else {
...@@ -201,7 +201,7 @@ function PublishCallBack(err) { ...@@ -201,7 +201,7 @@ function PublishCallBack(err) {
} }
// Publish a common event. // Publish a common event.
CommonEvent.publish("event", PublishCallBack); CommonEvent.publish("event", publishCallBack);
``` ```
...@@ -234,7 +234,7 @@ let options = { ...@@ -234,7 +234,7 @@ let options = {
} }
// Callback for common event publication // Callback for common event publication
function PublishCallBack(err) { function publishCallBack(err) {
if (err.code) { if (err.code) {
console.error("publish failed " + JSON.stringify(err)); console.error("publish failed " + JSON.stringify(err));
} else { } else {
...@@ -243,7 +243,7 @@ function PublishCallBack(err) { ...@@ -243,7 +243,7 @@ function PublishCallBack(err) {
} }
// Publish a common event. // Publish a common event.
CommonEvent.publish("event", options, PublishCallBack); CommonEvent.publish("event", options, publishCallBack);
``` ```
...@@ -270,7 +270,7 @@ Publishes a common event to a specific user. This API uses an asynchronous callb ...@@ -270,7 +270,7 @@ Publishes a common event to a specific user. This API uses an asynchronous callb
```js ```js
// Callback for common event publication // Callback for common event publication
function PublishAsUserCallBack(err) { function publishAsUserCallBack(err) {
if (err.code) { if (err.code) {
console.error("publishAsUser failed " + JSON.stringify(err)); console.error("publishAsUser failed " + JSON.stringify(err));
} else { } else {
...@@ -282,7 +282,7 @@ function PublishAsUserCallBack(err) { ...@@ -282,7 +282,7 @@ function PublishAsUserCallBack(err) {
let userId = 100; let userId = 100;
// Publish a common event. // Publish a common event.
CommonEvent.publishAsUser("event", userId, PublishAsUserCallBack); CommonEvent.publishAsUser("event", userId, publishAsUserCallBack);
``` ```
...@@ -317,7 +317,7 @@ let options = { ...@@ -317,7 +317,7 @@ let options = {
} }
// Callback for common event publication // Callback for common event publication
function PublishAsUserCallBack(err) { function publishAsUserCallBack(err) {
if (err.code) { if (err.code) {
console.error("publishAsUser failed " + JSON.stringify(err)); console.error("publishAsUser failed " + JSON.stringify(err));
} else { } else {
...@@ -329,7 +329,7 @@ function PublishAsUserCallBack(err) { ...@@ -329,7 +329,7 @@ function PublishAsUserCallBack(err) {
let userId = 100; let userId = 100;
// Publish a common event. // Publish a common event.
CommonEvent.publishAsUser("event", userId, options, PublishAsUserCallBack); CommonEvent.publishAsUser("event", userId, options, publishAsUserCallBack);
``` ```
...@@ -361,7 +361,7 @@ let subscribeInfo = { ...@@ -361,7 +361,7 @@ let subscribeInfo = {
}; };
// Callback for subscriber creation. // Callback for subscriber creation.
function CreateSubscriberCallBack(err, commonEventSubscriber) { function createSubscriberCallBack(err, commonEventSubscriber) {
if (err.code) { if (err.code) {
console.error("createSubscriber failed " + JSON.stringify(err)); console.error("createSubscriber failed " + JSON.stringify(err));
} else { } else {
...@@ -371,7 +371,7 @@ function CreateSubscriberCallBack(err, commonEventSubscriber) { ...@@ -371,7 +371,7 @@ function CreateSubscriberCallBack(err, commonEventSubscriber) {
} }
// Create a subscriber. // Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
``` ```
...@@ -442,7 +442,7 @@ let subscribeInfo = { ...@@ -442,7 +442,7 @@ let subscribeInfo = {
}; };
// Callback for common event subscription. // Callback for common event subscription.
function SubscribeCallBack(err, data) { function subscribeCallBack(err, data) {
if (err.code) { if (err.code) {
console.error("subscribe failed " + JSON.stringify(err)); console.error("subscribe failed " + JSON.stringify(err));
} else { } else {
...@@ -451,19 +451,19 @@ function SubscribeCallBack(err, data) { ...@@ -451,19 +451,19 @@ function SubscribeCallBack(err, data) {
} }
// Callback for subscriber creation. // Callback for subscriber creation.
function CreateSubscriberCallBack(err, commonEventSubscriber) { function createSubscriberCallBack(err, commonEventSubscriber) {
if (err.code) { if (err.code) {
console.error("createSubscriber failed " + JSON.stringify(err)); console.error("createSubscriber failed " + JSON.stringify(err));
} else { } else {
console.info("createSubscriber"); console.info("createSubscriber");
subscriber = commonEventSubscriber; subscriber = commonEventSubscriber;
// Subscribe to a common event. // Subscribe to a common event.
CommonEvent.subscribe(subscriber, SubscribeCallBack); CommonEvent.subscribe(subscriber, subscribeCallBack);
} }
} }
// Create a subscriber. // Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
``` ```
...@@ -494,7 +494,7 @@ let subscribeInfo = { ...@@ -494,7 +494,7 @@ let subscribeInfo = {
}; };
// Callback for common event subscription. // Callback for common event subscription.
function SubscribeCallBack(err, data) { function subscribeCallBack(err, data) {
if (err.code) { if (err.code) {
console.info("subscribe failed " + JSON.stringify(err)); console.info("subscribe failed " + JSON.stringify(err));
} else { } else {
...@@ -503,19 +503,19 @@ function SubscribeCallBack(err, data) { ...@@ -503,19 +503,19 @@ function SubscribeCallBack(err, data) {
} }
// Callback for subscriber creation. // Callback for subscriber creation.
function CreateSubscriberCallBack(err, commonEventSubscriber) { function createSubscriberCallBack(err, commonEventSubscriber) {
if (err.code) { if (err.code) {
console.info("createSubscriber failed " + JSON.stringify(err)); console.info("createSubscriber failed " + JSON.stringify(err));
} else { } else {
console.info("createSubscriber"); console.info("createSubscriber");
subscriber = commonEventSubscriber; subscriber = commonEventSubscriber;
// Subscribe to a common event. // Subscribe to a common event.
CommonEvent.subscribe(subscriber, SubscribeCallBack); CommonEvent.subscribe(subscriber, subscribeCallBack);
} }
} }
// Callback for common event unsubscription. // Callback for common event unsubscription.
function UnsubscribeCallBack(err) { function unsubscribeCallBack(err) {
if (err.code) { if (err.code) {
console.info("unsubscribe failed " + JSON.stringify(err)); console.info("unsubscribe failed " + JSON.stringify(err));
} else { } else {
...@@ -524,10 +524,10 @@ function UnsubscribeCallBack(err) { ...@@ -524,10 +524,10 @@ function UnsubscribeCallBack(err) {
} }
// Create a subscriber. // Create a subscriber.
CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, createSubscriberCallBack);
// Unsubscribe from the common event. // Unsubscribe from the common event.
CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); CommonEvent.unsubscribe(subscriber, unsubscribeCallBack);
``` ```
## CommonEventSubscriber ## CommonEventSubscriber
...@@ -1233,39 +1233,45 @@ subscriber.finishCommonEvent().then(() => { ...@@ -1233,39 +1233,45 @@ subscriber.finishCommonEvent().then(() => {
## CommonEventData ## CommonEventData
Describes the common event data body.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| ---------- | ---- | ---- | -------------------- | ------------------------------------------------------- | | ---------- |-------------------- | ---- | ---- | ------------------------------------------------------- |
| event | Yes | No | string | Name of the common event that is being received. | | event | string | Yes | No | Name of the common event that is being received. |
| bundleName | Yes | No | string | Bundle name. | | bundleName | string | Yes | No | Bundle name. |
| code | Yes | No | number | Result code of the common event, which is used to transfer data of the int type. | | code | number | Yes | No | Result code of the common event, which is used to transfer data of the int type. |
| data | Yes | No | string | Custom result data of the common event, which is used to transfer data of the string type.| | data | string | Yes | No | Custom result data of the common event, which is used to transfer data of the string type.|
| parameters | Yes | No | {[key: string]: any} | Additional information about the common event. | | parameters | {[key: string]: any} | Yes | No | Additional information about the common event. |
## CommonEventPublishData ## CommonEventPublishData
Describes the data body published by a common event, including the common event content and attributes.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| --------------------- | ---- | ---- | -------------------- | ---------------------------- | | --------------------- | -------------------- | ---- | ---- | ---------------------------- |
| bundleName | Yes | No | string | Bundle name. | | bundleName | string | Yes | No | Bundle name. |
| code | Yes | No | number | Result code of the common event. | | code | number | Yes | No | Result code of the common event. |
| data | Yes | No | string | Custom result data of the common event.| | data | string | Yes | No | Custom result data of the common event.|
| subscriberPermissions | Yes | No | Array\<string> | Permissions required for subscribers to receive the common event. | | subscriberPermissions | Array\<string> | Yes | No | Permissions required for subscribers to receive the common event. |
| isOrdered | Yes | No | boolean | Whether the common event is an ordered one. | | isOrdered | boolean | Yes | No | Whether the common event is an ordered one. |
| isSticky | Yes | No | boolean | Whether the common event is a sticky one. | | isSticky | boolean | Yes | No | Whether the common event is a sticky one. Only system applications and system services are allowed to send sticky events.|
| parameters | Yes | No | {[key: string]: any} | Additional information about the common event. | | parameters | {[key: string]: any} | Yes | No | Additional information about the common event. |
## CommonEventSubscribeInfo ## CommonEventSubscribeInfo
Provides the subscriber information.
**System capability**: SystemCapability.Notification.CommonEvent **System capability**: SystemCapability.Notification.CommonEvent
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| ------------------- | ---- | ---- | -------------- | ------------------------------------------------------------ | | ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
| events | Yes | No | Array\<string> | Name of the common event to publish. | | events | Array\<string> | Yes | No | Name of the common event to publish. |
| publisherPermission | Yes | No | string | Permissions required for publishers to publish the common event. | | publisherPermission | string | Yes | No | Permissions required for publishers to publish the common event. |
| publisherDeviceId | Yes | No | string | Device ID. The value must be the ID of an existing device on the same network. | | publisherDeviceId | string | Yes | No | Device ID. The value must be the ID of an existing device on the same network. |
| userId | Yes | No | number | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.| | userId | number | Yes | No | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | Yes | No | number | Subscriber priority. The value ranges from -100 to 1000. | | priority | number | Yes | No | Subscriber priority. The value ranges from -100 to +1000. |
# @ohos.commonEventManager
The **CommonEventManager** 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 initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```ts
import CommonEventManager from '@ohos.commonEventManager';
```
## Support
The table below lists the event types supported by the **CommonEventManager** module. The name and value indicate the macro and name of a common event, respectively.
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Value | Subscriber Permission | Description |
| ------------ | ------------------ | ---------------------- | -------------------- |
| COMMON_EVENT_BOOT_COMPLETED | usual.event.BOOT_COMPLETED | ohos.permission.RECEIVER_STARTUP_COMPLETED | Indicates the common event that the user has finished booting and the system has been loaded. |
| COMMON_EVENT_LOCKED_BOOT_COMPLETED | usual.event.LOCKED_BOOT_COMPLETED | ohos.permission.RECEIVER_STARTUP_COMPLETED | Indicates the common event that the user has finished booting and the system has been loaded but the screen is still locked. |
| COMMON_EVENT_SHUTDOWN | usual.event.SHUTDOWN | - | Indicates the common event that the device is being shut down and the final shutdown will proceed. |
| COMMON_EVENT_BATTERY_CHANGED | usual.event.BATTERY_CHANGED | - | Indicates the common event that the charging state, level, and other information about the battery have changed. |
| COMMON_EVENT_BATTERY_LOW | usual.event.BATTERY_LOW | - | Indicates the common event that the battery level is low. |
| COMMON_EVENT_BATTERY_OKAY | usual.event.BATTERY_OKAY | - | Indicates the common event that the battery exits the low state. |
| COMMON_EVENT_POWER_CONNECTED | usual.event.POWER_CONNECTED | - | Indicates the common event that the device is connected to an external power supply. |
| COMMON_EVENT_POWER_DISCONNECTED | usual.event.POWER_DISCONNECTED | - | Indicates the common event that the device is disconnected from the external power supply. |
| COMMON_EVENT_SCREEN_OFF | usual.event.SCREEN_OFF | - | Indicates the common event that the device screen is off and the device is sleeping. |
| COMMON_EVENT_SCREEN_ON | usual.event.SCREEN_ON | - | Indicates the common event that the device screen is on and the device is in interactive state. |
| COMMON_EVENT_THERMAL_LEVEL_CHANGED | usual.event.THERMAL_LEVEL_CHANGED | - | Indicates the common event that the device's thermal level has changed. |
| COMMON_EVENT_USER_PRESENT | usual.event.USER_PRESENT | - | Indicates the common event that the user unlocks the device. |
| COMMON_EVENT_TIME_TICK | usual.event.TIME_TICK | - | Indicates the common event that the system time has changed. |
| COMMON_EVENT_TIME_CHANGED | usual.event.TIME_CHANGED | - | Indicates the common event that the system time is set. |
| COMMON_EVENT_DATE_CHANGED | usual.event.DATE_CHANGED | - | Indicates the common event that the system time has changed. |
| COMMON_EVENT_TIMEZONE_CHANGED | usual.event.TIMEZONE_CHANGED | - | Indicates the common event that the system time zone has changed. |
| COMMON_EVENT_CLOSE_SYSTEM_DIALOGS | usual.event.CLOSE_SYSTEM_DIALOGS | - | Indicates the common event that a user closes a temporary system dialog box. |
| COMMON_EVENT_PACKAGE_ADDED | usual.event.PACKAGE_ADDED | - | Indicates the common event that a new application package has been installed on the device. |
| COMMON_EVENT_PACKAGE_REPLACED | usual.event.PACKAGE_REPLACED | - | Indicates the common event that a later version of an installed application package has replaced the previous one on the device. |
| COMMON_EVENT_MY_PACKAGE_REPLACED | usual.event.MY_PACKAGE_REPLACED | - | Indicates the common event that a later version of your application package has replaced the previous one.
| COMMON_EVENT_PACKAGE_REMOVED | usual.event.PACKAGE_REMOVED | - | Indicates the common event that an installed application has been uninstalled from the device with the application data retained. |
| COMMON_EVENT_BUNDLE_REMOVED | usual.event.BUNDLE_REMOVED | - | Indicates the common event that an installed bundle has been uninstalled from the device with the application data retained. |
| COMMON_EVENT_PACKAGE_FULLY_REMOVED | usual.event.PACKAGE_FULLY_REMOVED | - | Indicates the common event that an installed application, including both the application data and code, has been completely uninstalled from the device. |
| COMMON_EVENT_PACKAGE_CHANGED | usual.event.PACKAGE_CHANGED | - | Indicates the common event that an application package has been changed (for example, a component in the package has been enabled or disabled). |
| COMMON_EVENT_PACKAGE_RESTARTED | usual.event.PACKAGE_RESTARTED | - | Indicates the common event that the user has restarted the application package and killed all its processes. |
| COMMON_EVENT_PACKAGE_DATA_CLEARED | usual.event.PACKAGE_DATA_CLEARED | - | Indicates the common event that the user has cleared the application package data. |
| COMMON_EVENT_PACKAGE_CACHE_CLEARED<sup>9+</sup> | usual.event.PACKAGE_CACHE_CLEARED | - | Indicates the common event that the user has cleared the application package data. |
| COMMON_EVENT_PACKAGES_SUSPENDED | usual.event.PACKAGES_SUSPENDED | - | Indicates the common event that application packages have been suspended. |
| COMMON_EVENT_PACKAGES_UNSUSPENDED | usual.event.PACKAGES_UNSUSPENDED | - | Indicates the common event that application package has not been suspended. |
| COMMON_EVENT_MY_PACKAGE_SUSPENDED | usual.event.MY_PACKAGE_SUSPENDED | - | Indicates the common event that an application package has been suspended. |
| COMMON_EVENT_MY_PACKAGE_UNSUSPENDED | usual.event.MY_PACKAGE_UNSUSPENDED | - | Indicates the common event that application package has not been suspended. |
| COMMON_EVENT_UID_REMOVED | usual.event.UID_REMOVED | - | Indicates the common event that a user ID has been removed from the system. |
| COMMON_EVENT_PACKAGE_FIRST_LAUNCH | usual.event.PACKAGE_FIRST_LAUNCH | - | Indicates the common event that an installed application is started for the first time. |
| COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION | usual.event.PACKAGE_NEEDS_VERIFICATION | - | Indicates the common event that an application requires system verification. |
| COMMON_EVENT_PACKAGE_VERIFIED | usual.event.PACKAGE_VERIFIED | - | Indicates the common event that an application has been verified by the system. |
| COMMON_EVENT_EXTERNAL_APPLICATIONS_AVAILABLE | usual.event.EXTERNAL_APPLICATIONS_AVAILABLE | - | Indicates the common event that applications installed on the external storage become available for the system. |
| COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE | usual.event.EXTERNAL_APPLICATIONS_UNAVAILABLE | - | Indicates the common event that applications installed on the external storage become unavailable for the system. |
| COMMON_EVENT_CONFIGURATION_CHANGED | usual.event.CONFIGURATION_CHANGED | - | Indicates the common event that the device state (for example, orientation and locale) has changed. |
| COMMON_EVENT_LOCALE_CHANGED | usual.event.LOCALE_CHANGED | - | Indicates the common event that the device locale has changed. |
| COMMON_EVENT_MANAGE_PACKAGE_STORAGE | usual.event.MANAGE_PACKAGE_STORAGE | - | Indicates the common event that the device storage is insufficient. |
| COMMON_EVENT_DRIVE_MODE | common.event.DRIVE_MODE | - | Indicates the common event that the system is in driving mode. |
| COMMON_EVENT_HOME_MODE | common.event.HOME_MODE | - | Indicates the common event that the system is in home mode. |
| COMMON_EVENT_OFFICE_MODE | common.event.OFFICE_MODE | - | Indicates the common event that the system is in office mode. |
| COMMON_EVENT_USER_STARTED | usual.event.USER_STARTED | - | Indicates the common event that the user has been started. |
| COMMON_EVENT_USER_BACKGROUND | usual.event.USER_BACKGROUND | - | Indicates the common event that the user has been brought to the background. |
| COMMON_EVENT_USER_FOREGROUND | usual.event.USER_FOREGROUND | - | Indicates the common event that the user has been brought to the foreground. |
| COMMON_EVENT_USER_SWITCHED | usual.event.USER_SWITCHED | ohos.permission.MANAGE_LOCAL_ACCOUNTS | Indicates the common event that user switching is happening. |
| COMMON_EVENT_USER_STARTING | usual.event.USER_STARTING | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the user is going to be started. |
| COMMON_EVENT_USER_UNLOCKED | usual.event.USER_UNLOCKED | - | Indicates the common event that the credential-encrypted storage has been unlocked for the current user when the device is unlocked after being restarted. |
| COMMON_EVENT_USER_STOPPING | usual.event.USER_STOPPING | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the user is going to be stopped. |
| COMMON_EVENT_USER_STOPPED | usual.event.USER_STOPPED | - | Indicates the common event that the user has been stopped. |
| COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGIN | usual.event.DISTRIBUTED_ACCOUNT_LOGIN | - | Indicates the action of successful login using a distributed account. |
| COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOUT | usual.event.DISTRIBUTED_ACCOUNT_LOGOUT | - | Indicates the action of successful logout of a distributed account. |
| COMMON_EVENT_DISTRIBUTED_ACCOUNT_TOKEN_INVALID | usual.event.DISTRIBUTED_ACCOUNT_TOKEN_INVALID | - | Indicates the action when the token of a distributed account is invalid. |
| COMMON_EVENT_DISTRIBUTED_ACCOUNT_LOGOFF | usual.event.DISTRIBUTED_ACCOUNT_LOGOFF | - | Indicates the action of deregistering a distributed account. |
| COMMON_EVENT_WIFI_POWER_STATE | usual.event.wifi.POWER_STATE | - | Indicates the common event about the Wi-Fi network state, such as enabled and disabled. |
| COMMON_EVENT_WIFI_SCAN_FINISHED | usual.event.wifi.SCAN_FINISHED | ohos.permission.LOCATION | Indicates the common event that the Wi-Fi access point has been scanned and proven to be available. |
| COMMON_EVENT_WIFI_RSSI_VALUE | usual.event.wifi.RSSI_VALUE | ohos.permission.GET_WIFI_INFO | Indicates the common event that the Wi-Fi signal strength (RSSI) has changed. |
| COMMON_EVENT_WIFI_CONN_STATE | usual.event.wifi.CONN_STATE | - | Indicates the common event that the Wi-Fi connection state has changed. |
| COMMON_EVENT_WIFI_HOTSPOT_STATE | usual.event.wifi.HOTSPOT_STATE | - | Indicates the common event about the Wi-Fi hotspot state, such as enabled or disabled. |
| COMMON_EVENT_WIFI_AP_STA_JOIN | usual.event.wifi.WIFI_HS_STA_JOIN | ohos.permission.GET_WIFI_INFO | Indicates the common event that a client has joined the Wi-Fi hotspot of the current device. |
| COMMON_EVENT_WIFI_AP_STA_LEAVE | usual.event.wifi.WIFI_HS_STA_LEAVE | ohos.permission.GET_WIFI_INFO |Indicates the common event that a client has disconnected from the Wi-Fi hotspot of the current device. |
| COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE | usual.event.wifi.mplink.STATE_CHANGE | ohos.permission.MPLINK_CHANGE_STATE | Indicates the common event that the state of MPLINK (an enhanced Wi-Fi feature) has changed. |
| COMMON_EVENT_WIFI_P2P_CONN_STATE | usual.event.wifi.p2p.CONN_STATE_CHANGE | ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION | Indicates the common event that the Wi-Fi P2P connection state has changed. |
| COMMON_EVENT_WIFI_P2P_STATE_CHANGED | usual.event.wifi.p2p.STATE_CHANGE | ohos.permission.GET_WIFI_INFO | Indicates the common event about the Wi-Fi P2P state, such as enabled and disabled. |
| COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED | usual.event.wifi.p2p.DEVICES_CHANGE | ohos.permission.GET_WIFI_INFO | Indicates the common event about the status change of Wi-Fi P2P peer devices. |
| COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED | usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE | ohos.permission.GET_WIFI_INFO | Indicates the common event about the Wi-Fi P2P discovery status change. |
| COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED | usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE | ohos.permission.GET_WIFI_INFO | Indicates the common event about the status change of the Wi-Fi P2P local device. |
| COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED | usual.event.wifi.p2p.GROUP_STATE_CHANGED | ohos.permission.GET_WIFI_INFO | Indicates the common event that the Wi-Fi P2P group information has changed. |
| COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CONNECT_STATE_UPDATE | usual.event.bluetooth.handsfree.ag.CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event about the connection state of Bluetooth handsfree communication. |
| COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CURRENT_DEVICE_UPDATE | usual.event.bluetooth.handsfree.ag.CURRENT_DEVICE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the device connected to the Bluetooth handsfree is active. |
| COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_AUDIO_STATE_UPDATE | usual.event.bluetooth.handsfree.ag.AUDIO_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the connection state of Bluetooth A2DP has changed. |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsource.CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event about the connection state of Bluetooth A2DP. |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CURRENT_DEVICE_UPDATE | usual.event.bluetooth.a2dpsource.CURRENT_DEVICE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the device connected using Bluetooth A2DP is active. |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_PLAYING_STATE_UPDATE | usual.event.bluetooth.a2dpsource.PLAYING_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the playing state of Bluetooth A2DP has changed. |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_AVRCP_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsource.AVRCP_CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the AVRCP connection state of Bluetooth A2DP has changed. |
| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CODEC_VALUE_UPDATE | usual.event.bluetooth.a2dpsource.CODEC_VALUE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the audio codec state of Bluetooth A2DP has changed. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_DISCOVERED | usual.event.bluetooth.remotedevice.DISCOVERED | ohos.permission.LOCATION and ohos.permission.USE_BLUETOOTH | Indicates the common event that a remote Bluetooth device is discovered. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CLASS_VALUE_UPDATE | usual.event.bluetooth.remotedevice.CLASS_VALUE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the Bluetooth class of a remote Bluetooth device has changed. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_CONNECTED | usual.event.bluetooth.remotedevice.ACL_CONNECTED | ohos.permission.USE_BLUETOOTH | Indicates the common event that a low-ACL connection has been established with a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_DISCONNECTED | usual.event.bluetooth.remotedevice.ACL_DISCONNECTED | ohos.permission.USE_BLUETOOTH | Indicates the common event that a low-ACL connection has been disconnected from a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_NAME_UPDATE | usual.event.bluetooth.remotedevice.NAME_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the friendly name of a remote Bluetooth device is retrieved for the first time or is changed since the last retrieval. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIR_STATE | usual.event.bluetooth.remotedevice.PAIR_STATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the connection state of a remote Bluetooth device has changed. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_BATTERY_VALUE_UPDATE | usual.event.bluetooth.remotedevice.BATTERY_VALUE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the battery level of a remote Bluetooth device is retrieved for the first time or is changed since the last retrieval. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_SDP_RESULT | usual.event.bluetooth.remotedevice.SDP_RESULT | - | Indicates the common event about the SDP state of a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_UUID_VALUE | usual.event.bluetooth.remotedevice.UUID_VALUE | ohos.permission.DISCOVER_BLUETOOTH | Indicates the common event about the UUID connection state of a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_REQ | usual.event.bluetooth.remotedevice.PAIRING_REQ | ohos.permission.DISCOVER_BLUETOOTH | Indicates the common event about the pairing request from a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_CANCEL | usual.event.bluetooth.remotedevice.PAIRING_CANCEL | - | Indicates the common event that Bluetooth pairing is canceled. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REQ | usual.event.bluetooth.remotedevice.CONNECT_REQ | - | Indicates the common event about the connection request from a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REPLY | usual.event.bluetooth.remotedevice.CONNECT_REPLY | - | Indicates the common event about the response to the connection request from a remote Bluetooth device. |
| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_CANCEL | usual.event.bluetooth.remotedevice.CONNECT_CANCEL | - | Indicates the common event that the connection to a remote Bluetooth device has been canceled. |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_CONNECT_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.CONNECT_STATE_UPDATE | - | Indicates the common event that the connection state of a Bluetooth handsfree has changed. |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AUDIO_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.AUDIO_STATE_UPDATE | - | Indicates the common event that the audio state of a Bluetooth handsfree has changed. |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_COMMON_EVENT | usual.event.bluetooth.handsfreeunit.AG_COMMON_EVENT | - | Indicates the common event that the audio gateway state of a Bluetooth handsfree has changed. |
| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_CALL_STATE_UPDATE | usual.event.bluetooth.handsfreeunit.AG_CALL_STATE_UPDATE | - | Indicates the common event that the calling state of a Bluetooth handsfree has changed. |
| COMMON_EVENT_BLUETOOTH_HOST_STATE_UPDATE | usual.event.bluetooth.host.STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the state of a Bluetooth adapter has been changed, for example, Bluetooth has been enabled or disabled. |
| COMMON_EVENT_BLUETOOTH_HOST_REQ_DISCOVERABLE | usual.event.bluetooth.host.REQ_DISCOVERABLE | - | Indicates the common event about the request for the user to allow Bluetooth device scanning. |
| COMMON_EVENT_BLUETOOTH_HOST_REQ_ENABLE | usual.event.bluetooth.host.REQ_ENABLE | ohos.permission.USE_BLUETOOTH | Indicates the common event about the request for the user to enable Bluetooth. |
| COMMON_EVENT_BLUETOOTH_HOST_REQ_DISABLE | usual.event.bluetooth.host.REQ_DISABLE | ohos.permission.USE_BLUETOOTH | Indicates the common event about the request for the user to disable Bluetooth. |
| COMMON_EVENT_BLUETOOTH_HOST_SCAN_MODE_UPDATE | usual.event.bluetooth.host.SCAN_MODE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the Bluetooth scanning mode of a device has changed. |
| COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_STARTED | usual.event.bluetooth.host.DISCOVERY_STARTED | ohos.permission.USE_BLUETOOTH | Indicates the common event that the Bluetooth scanning has been started on the device. |
| COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_FINISHED | usual.event.bluetooth.host.DISCOVERY_FINISHED | ohos.permission.USE_BLUETOOTH | Indicates the common event that the Bluetooth scanning is finished on the device. |
| COMMON_EVENT_BLUETOOTH_HOST_NAME_UPDATE | usual.event.bluetooth.host.NAME_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the Bluetooth adapter name of the device has changed. |
| COMMON_EVENT_BLUETOOTH_A2DPSINK_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsink.CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the connection state of Bluetooth A2DP Sink has changed. |
| COMMON_EVENT_BLUETOOTH_A2DPSINK_PLAYING_STATE_UPDATE | usual.event.bluetooth.a2dpsink.PLAYING_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the playing state of Bluetooth A2DP Sink has changed. |
| COMMON_EVENT_BLUETOOTH_A2DPSINK_AUDIO_STATE_UPDATE | usual.event.bluetooth.a2dpsink.AUDIO_STATE_UPDATE | ohos.permission.USE_BLUETOOTH | Indicates the common event that the audio state of Bluetooth A2DP Sink has changed. |
| COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED | usual.event.nfc.action.ADAPTER_STATE_CHANGED | - | Indicates the common event that the state of the device's NFC adapter has changed. |
| COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED | usual.event.nfc.action.RF_FIELD_ON_DETECTED | ohos.permission.MANAGE_SECURE_SETTINGS | Indicates the action of a common event that the NFC RF field is detected to be in the enabled state. |
| COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED | usual.event.nfc.action.RF_FIELD_OFF_DETECTED | ohos.permission.MANAGE_SECURE_SETTINGS | Indicates the common event that the NFC RF field is detected to be in the disabled state. |
| COMMON_EVENT_DISCHARGING | usual.event.DISCHARGING | - | Indicates the common event that the system stops charging the battery. |
| COMMON_EVENT_CHARGING | usual.event.CHARGING | - | Indicates the common event that the system starts charging the battery. |
| COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED | usual.event.DEVICE_IDLE_MODE_CHANGED | - | Indicates the common event that the system idle mode has changed. |
| COMMON_EVENT_POWER_SAVE_MODE_CHANGED | usual.event.POWER_SAVE_MODE_CHANGED | - | Indicates the common event that the power saving mode of the system has changed. |
| COMMON_EVENT_USER_ADDED | usual.event.USER_ADDED | ohos.permission.MANAGE_LOCAL_ACCOUNTS | Indicates the common event that a user has been added to the system. |
| COMMON_EVENT_USER_REMOVED | usual.event.USER_REMOVED | ohos.permission.MANAGE_LOCAL_ACCOUNTS | Indicates the common event that a user has been removed from the system. |
| COMMON_EVENT_ABILITY_ADDED | usual.event.ABILITY_ADDED | ohos.permission.LISTEN_BUNDLE_CHANGE | Indicates the common event that an ability has been added. |
| COMMON_EVENT_ABILITY_REMOVED | usual.event.ABILITY_REMOVED | ohos.permission.LISTEN_BUNDLE_CHANGE | Indicates the common event that an ability has been removed. |
| COMMON_EVENT_ABILITY_UPDATED | usual.event.ABILITY_UPDATED | ohos.permission.LISTEN_BUNDLE_CHANGE | Indicates the common event that an ability has been updated. |
| COMMON_EVENT_LOCATION_MODE_STATE_CHANGED | usual.event.location.MODE_STATE_CHANGED | - | Indicates the common event that the location mode of the system has changed. |
| COMMON_EVENT_IVI_SLEEP | common.event.IVI_SLEEP | - | Indicates the common event that the in-vehicle infotainment (IVI) system of a vehicle is sleeping. |
| COMMON_EVENT_IVI_PAUSE | common.event.IVI_PAUSE | - | Indicates the common event that the IVI system of a vehicle has entered sleep mode and the playing application is instructed to stop playback. |
| COMMON_EVENT_IVI_STANDBY | common.event.IVI_STANDBY | - | Indicates the common event that a third-party application is instructed to pause the current work. |
| COMMON_EVENT_IVI_LASTMODE_SAVE | common.event.IVI_LASTMODE_SAVE | - | Indicates the common event that a third-party application is instructed to save its last mode. |
| COMMON_EVENT_IVI_VOLTAGE_ABNORMAL | common.event.IVI_VOLTAGE_ABNORMAL | - | Indicates the common event that the voltage of the vehicle's power system is abnormal. |
| COMMON_EVENT_IVI_HIGH_TEMPERATURE | common.event.IVI_HIGH_TEMPERATURE | - | Indicates the common event that the temperature of the IVI system is high. |
| COMMON_EVENT_IVI_EXTREME_TEMPERATURE | common.event.IVI_EXTREME_TEMPERATURE | - | Indicates the common event that the temperature of the IVI system is extremely high. |
| COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL | common.event.IVI_TEMPERATURE_ABNORMAL | - | Indicates the common event that the IVI system has an extreme temperature. |
| COMMON_EVENT_IVI_VOLTAGE_RECOVERY | common.event.IVI_VOLTAGE_RECOVERY | - | Indicates the common event that the voltage of the vehicle's power system is restored to normal. |
| COMMON_EVENT_IVI_TEMPERATURE_RECOVERY | common.event.IVI_TEMPERATURE_RECOVERY | - | Indicates the common event that the temperature of the IVI system is restored to normal. |
| COMMON_EVENT_IVI_ACTIVE | common.event.IVI_ACTIVE | - | Indicates the common event that the battery service is active. |
|COMMON_EVENT_USB_STATE<sup>9+</sup> | usual.event.hardware.usb.action.USB_STATE | - | Indicates a common event indicating that the USB device status changes. |
|COMMON_EVENT_USB_PORT_CHANGED<sup>9+</sup> | usual.event.hardware.usb.action.USB_PORT_CHANGED | - | Indicates the public event that the USB port status of the user device changes. |
| COMMON_EVENT_USB_DEVICE_ATTACHED | usual.event.hardware.usb.action.USB_DEVICE_ATTACHED | - | Indicates the common event that a USB device has been attached when the user device functions as a USB host. |
| COMMON_EVENT_USB_DEVICE_DETACHED | usual.event.hardware.usb.action.USB_DEVICE_DETACHED | - | Indicates the common event that a USB device has been detached when the user device functions as a USB host. |
| COMMON_EVENT_USB_ACCESSORY_ATTACHED | usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED | - | Indicates the common event that a USB accessory was attached. |
| COMMON_EVENT_USB_ACCESSORY_DETACHED | usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED | - | Indicates the common event that a USB accessory was detached. |
| COMMON_EVENT_DISK_REMOVED | usual.event.data.DISK_REMOVED | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was removed. |
| COMMON_EVENT_DISK_UNMOUNTED | usual.event.data.DISK_UNMOUNTED | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was unmounted. |
| COMMON_EVENT_DISK_MOUNTED | usual.event.data.DISK_MOUNTED | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was mounted. |
| COMMON_EVENT_DISK_BAD_REMOVAL | usual.event.data.DISK_BAD_REMOVAL | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was removed without being unmounted. |
| COMMON_EVENT_DISK_UNMOUNTABLE | usual.event.data.DISK_UNMOUNTABLE | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device becomes unmountable. |
| COMMON_EVENT_DISK_EJECT | usual.event.data.DISK_EJECT | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was ejected. |
| COMMON_EVENT_VOLUME_REMOVED<sup>9+<sup> | usual.event.data.VOLUME_REMOVED | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was removed. |
| COMMON_EVENT_VOLUME_UNMOUNTED<sup>9+<sup> | usual.event.data.VOLUME_UNMOUNTED | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was unmounted. |
| COMMON_EVENT_VOLUME_MOUNTED<sup>9+<sup> | usual.event.data.VOLUME_MOUNTED | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was mounted. |
| COMMON_EVENT_VOLUME_BAD_REMOVAL<sup>9+<sup> | usual.event.data.VOLUME_BAD_REMOVAL | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was removed without being unmounted. |
| COMMON_EVENT_VOLUME_EJECT<sup>9+<sup> | usual.event.data.VOLUME_EJECT | ohos.permission.STORAGE_MANAGER | Indicates the common event that an external storage device was ejected. |
| COMMON_EVENT_VISIBLE_ACCOUNTS_UPDATED | usual.event.data.VISIBLE_ACCOUNTS_UPDATED | ohos.permission.GET_APP_ACCOUNTS | Indicates the common event that the account visibility changed. |
| COMMON_EVENT_ACCOUNT_DELETED | usual.event.data.ACCOUNT_DELETED | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS | Indicates the common event that the account was deleted. |
| COMMON_EVENT_FOUNDATION_READY | usual.event.data.FOUNDATION_READY | ohos.permission.RECEIVER_STARTUP_COMPLETED | Indicates the common event that the foundation is ready. |
| COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | - | Indicates the common event that the airplane mode of the device has changed. |
| COMMON_EVENT_SPLIT_SCREEN | usual.event.SPLIT_SCREEN | ohos.permission.RECEIVER_SPLIT_SCREEN | Indicates the common event of screen splitting. |
| COMMON_EVENT_SLOT_CHANGE<sup>9+<sup> | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | Indicates the common event that the notification slot has been updated. |
| COMMON_EVENT_SPN_INFO_CHANGED <sup>9+<sup> | usual.event.SPN_INFO_CHANGED | - | Indicates the common event that the SPN displayed has been updated. |
| COMMON_EVENT_QUICK_FIX_APPLY_RESULT <sup>9+<sup> | usual.event.QUICK_FIX_APPLY_RESULT | - | Indicates the common event that a quick fix is applied to the application. |
## CommonEventManager.publish
publish(event: string, callback: AsyncCallback\<void>): void
Publishes a common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------- |
| event | string | Yes | Name of the common event to publish.|
| 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 |
|-----------|--------------------|
|1500004 |not System services or System app|
|1500007 |message send error|
|1500008 |CEMS error|
|1500009 |system error|
**Example**
```ts
// Callback for common event publication
function publishCallBack(err) {
if (err) {
console.error("publish failed " + JSON.stringify(err));
} else {
console.info("publish");
}
}
// Publish a common event.
try {
CommonEventManager.publish("event", publishCallBack);
} catch(err) {
console.error('publish failed, catch error' + JSON.stringify(err));
}
```
## CommonEventManager.publish
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.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ---------------------- |
| event | string | Yes | Name of the common event to publish. |
| options | [CommonEventPublishData](#commoneventpublishdata) | Yes | Attributes of the common event to publish.|
| callback | syncCallback\<void> | Yes | Callback used to return the result. |
**Error codes**
|ID |Error Message |
|-----------|--------------------|
|1500004 |not System services or System app|
|1500007 |message send error|
|1500008 |CEMS error|
|1500009 |system error|
**Example**
```ts
// Attributes of a common event.
var options = {
code: 0, // Result code of the common event.
data: "initial data";// Result data of the common event.
isOrdered: true // The common event is an ordered one.
}
// Callback for common event publication
function publishCallBack(err) {
if (err) {
console.error("publish failed " + JSON.stringify(err));
} else {
console.info("publish");
}
}
// Publish a common event.
try {
CommonEventManager.publish("event", options, publishCallBack);
} catch (err) {
console.error('publish failed, catch error' + JSON.stringify(err));
}
```
## CommonEventManager.publishAsUser<sup>
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.
**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 |
| -------- | -------------------- | ---- | ---------------------------------- |
| event | string | Yes | Name of the common event to publish. |
| userId | number | Yes | User ID.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Error codes**
|ID |Error Message |
|-----------|--------------------|
|1500004 |not System services or System app|
|1500007 |message send error|
|1500008 |CEMS error|
|1500009 |system error|
**Example**
```ts
// Callback for common event publication
function publishAsUserCallBack(err) {
if (err) {
console.error("publishAsUser failed " + JSON.stringify(err));
} else {
console.info("publishAsUser");
}
}
// Specify the user to whom the common event will be published.
var userId = 100;
// Publish a common event.
try {
CommonEventManager.publishAsUser("event", userId, publishAsUserCallBack);
} catch (err) {
console.error('publishAsUser failed, catch error' + JSON.stringify(err));
}
```
## CommonEventManager.publishAsUser
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.
**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 |
| -------- | ---------------------- | ---- | ---------------------- |
| event | string | Yes | Name of the common event to publish. |
| userId | number | Yes| User ID.|
| options | [CommonEventPublishData](#commoneventpublishdata) | Yes | Attributes of the common event to publish.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Error codes**
|ID |Error Message |
|-----------|--------------------|
|1500004 |not System services or System app|
|1500007 |message send error|
|1500008 |CEMS error|
|1500009 |system error|
**Example**
```ts
// Attributes of a common event.
var options = {
code: 0, // Result code of the common event.
data: "initial data";// Result data of the common event.
}
// Callback for common event publication
function publishAsUserCallBack(err) {
if (err) {
console.error("publishAsUser failed " + JSON.stringify(err));
} else {
console.info("publishAsUser");
}
}
// Specify the user to whom the common event will be published.
var userId = 100;
// Publish a common event.
try {
CommonEventManager.publishAsUser("event", userId, options, publishAsUserCallBack);
} catch (err) {
console.error('publishAsUser failed, catch error' + JSON.stringify(err));
}
```
## CommonEventManager.createSubscriber
createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void
Creates a subscriber. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| ------------- | ------------------------------------------------------------ | ---- | -------------------------- |
| subscribeInfo | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes | Subscriber information. |
| callback | AsyncCallback\<[CommonEventSubscriber](#commoneventsubscriber)> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information.
var subscribeInfo = {
events: ["event"]
};
// Callback for subscriber creation.
function createSubscriberCallBack(err, commonEventSubscriber) {
if(!err) {
console.info("createSubscriber");
subscriber = commonEventSubscriber;
} else {
console.error("createSubscriber failed " + JSON.stringify(err));
}
}
// Create a subscriber.
try {
CommonEventManager.createSubscriber(subscribeInfo, createSubscriberCallBack);
} catch (err) {
console.error('createSubscriber failed, catch error' + JSON.stringify(err));
}
```
## CommonEventManager.createSubscriber
createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber>
Creates a subscriber. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| ------------- | ----------------------------------------------------- | ---- | -------------- |
| subscribeInfo | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes | Subscriber information.|
**Return value**
| Type | Description |
| --------------------------------------------------------- | ---------------- |
| Promise\<[CommonEventSubscriber](#commoneventsubscriber)> | Promise used to return the subscriber object.|
**Example**
```ts
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information.
var subscribeInfo = {
events: ["event"]
};
// Create a subscriber.
try {
CommonEventManager.createSubscriber(subscribeInfo).then((commonEventSubscriber) => {
console.info("createSubscriber");
subscriber = commonEventSubscriber;
}).catch((err) => {
console.error("createSubscriber failed " + JSON.stringify(err));
});
} catch(err) {
console.error('createSubscriber failed, catch error' + JSON.stringify(err));
}
```
## CommonEventManager.subscribe
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void
Subscribes to common events. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ---------------------------------------------------- | ---- | -------------------------------- |
| subscriber | [CommonEventSubscriber](#commoneventsubscriber) | Yes | Subscriber object. |
| callback | AsyncCallback\<[CommonEventData](#commoneventdata)> | Yes | Callback used to return the result.|
**Example**
```ts
// Subscriber information.
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information.
var subscribeInfo = {
events: ["event"]
};
// Callback for common event subscription.
function SubscribeCallBack(err, data) {
if (err.code) {
console.error("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribe ");
}
}
// Callback for subscriber creation.
function createSubscriberCallBack(err, commonEventSubscriber) {
if(!err) {
console.info("createSubscriber");
subscriber = commonEventSubscriber;
// Subscribe to a common event.
try {
CommonEventManager.subscribe(subscriber, SubscribeCallBack);
} catch (err) {
console.error("createSubscriber failed " + JSON.stringify(err));
}
} else {
console.error("createSubscriber failed " + JSON.stringify(err));
}
}
// Create a subscriber.
try {
CommonEventManager.createSubscriber(subscribeInfo, createSubscriberCallBack);
} catch (err) {
console.error('createSubscriber failed, catch error' + JSON.stringify(err));
}
```
## CommonEventManager.unsubscribe
unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void
Unsubscribes from common events. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | ----------------------------------------------- | ---- | ------------------------ |
| subscriber | [CommonEventSubscriber](#commoneventsubscriber) | Yes | Subscriber object. |
| callback | AsyncCallback\<void> | No | Callback used to return the result.|
**Example**
```ts
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information.
var subscribeInfo = {
events: ["event"]
};
// Callback for common event subscription.
function subscribeCallBack(err, data) {
if (err) {
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribe");
}
}
// Callback for subscriber creation.
function createSubscriberCallBack(err, commonEventSubscriber) {
if (err) {
console.info("createSubscriber failed " + JSON.stringify(err));
} else {
console.info("createSubscriber");
subscriber = commonEventSubscriber;
// Subscribe to a common event.
try {
CommonEventManager.subscribe(subscriber, subscribeCallBack);
} catch(err) {
console.info("subscribe failed " + JSON.stringify(err));
}
}
}
// Callback for common event unsubscription.
function unsubscribeCallBack(err) {
if (err) {
console.info("unsubscribe failed " + JSON.stringify(err));
} else {
console.info("unsubscribe");
}
}
// Create a subscriber.
try {
CommonEventManager.createSubscriber(subscribeInfo, createSubscriberCallBack);
} catch (err) {
console.info("createSubscriber failed " + JSON.stringify(err));
}
// Unsubscribe from the common event.
try {
CommonEventManager.unsubscribe(subscriber, unsubscribeCallBack);
} catch (err) {
console.info("unsubscribe failed " + JSON.stringify(err));
}
```
## CommonEventSubscriber
### getCode
getCode(callback: AsyncCallback\<number>): void
Obtains the result code of this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------ |
| callback | AsyncCallback\<number> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result code obtaining of an ordered common event.
function getCodeCallback(err, Code) {
if (err.code) {
console.error("getCode failed " + JSON.stringify(err));
} else {
console.info("getCode " + JSON.stringify(Code));
}
}
subscriber.getCode(getCodeCallback);
```
### getCode
getCode(): Promise\<number>
Obtains the result code of this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<number> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.getCode().then((Code) => {
console.info("getCode " + JSON.stringify(Code));
}).catch((err) => {
console.error("getCode failed " + JSON.stringify(err));
});
```
### setCode
setCode(code: number, callback: AsyncCallback\<void>): void
Sets the result code for this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------- |
| code | number | Yes | Result code of the common event. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result code setting of an ordered common event.
function setCodeCallback(err) {
if (err.code) {
console.error("setCode failed " + JSON.stringify(err));
} else {
console.info("setCode");
}
}
subscriber.setCode(1, setCodeCallback);
```
### setCode
setCode(code: number): Promise\<void>
Sets the result code for this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| code | number | Yes | Result code of the common event.|
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.setCode(1).then(() => {
console.info("setCode");
}).catch((err) => {
console.error("setCode failed " + JSON.stringify(err));
});
```
### getData
getData(callback: AsyncCallback\<string>): void
Obtains the result data of this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------- |
| callback | AsyncCallback\<string> | Yes | Callback used to return the result data.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result data obtaining of an ordered common event.
function getDataCallback(err, Data) {
if (err.code) {
console.error("getData failed " + JSON.stringify(err));
} else {
console.info("getData " + JSON.stringify(Data));
}
}
subscriber.getData(getDataCallback);
```
### getData
getData(): Promise\<string>
Obtains the result data of this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | ------------------ |
| Promise\<string> | Promise used to return the result data.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.getData().then((Data) => {
console.info("getData " + JSON.stringify(Data));
}).catch((err) => {
console.error("getData failed " + JSON.stringify(err));
});
```
### setData
setData(data: string, callback: AsyncCallback\<void>): void
Sets the result data for this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
| data | string | Yes | Result data of the common event. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result data setting of an ordered common event
function setDataCallback(err) {
if (err.code) {
console.error("setData failed " + JSON.stringify(err));
} else {
console.info("setData");
}
}
subscriber.setData("publish_data_changed", setDataCallback);
```
### setData
setData(data: string): Promise\<void>
Sets the result data for this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------- |
| data | string | Yes | Result data of the common event.|
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.setData("publish_data_changed").then(() => {
console.info("setData");
}).catch((err) => {
console.error("setData failed " + JSON.stringify(err));
});
```
### setCodeAndData
setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
Sets the result code and result data for this common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ---------------------- |
| code | number | Yes | Result code of the common event. |
| data | string | Yes | Result data of the common event. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for result code and result data setting of an ordered common event.
function setCodeDataCallback(err) {
if (err.code) {
console.error("setCodeAndData failed " + JSON.stringify(err));
} else {
console.info("setCodeDataCallback");
}
}
subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCallback);
```
### setCodeAndData
setCodeAndData(code: number, data: string): Promise\<void>
Sets the result code and result data for this common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------- |
| code | number | Yes | Result code of the common event.|
| data | string | Yes | Result data of the common event.|
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
console.info("setCodeAndData");
}).catch((err) => {
console.info("setCodeAndData failed " + JSON.stringify(err));
});
```
### isOrderedCommonEvent
isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the common event is an ordered one; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is an ordered one.
function isOrderedCallback(err, isOrdered) {
if (err.code) {
console.error("isOrderedCommonEvent failed " + JSON.stringify(err));
} else {
console.info("isOrdered " + JSON.stringify(isOrdered));
}
}
subscriber.isOrderedCommonEvent(isOrderedCallback);
```
### isOrderedCommonEvent
isOrderedCommonEvent(): Promise\<boolean>
Checks whether this common event is an ordered one. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ----------------- | -------------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the common event is an ordered one; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.isOrderedCommonEvent().then((isOrdered) => {
console.info("isOrdered " + JSON.stringify(isOrdered));
}).catch((err) => {
console.error("isOrdered failed " + JSON.stringify(err));
});
```
### isStickyCommonEvent
isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the common event is a sticky one; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is a sticky one.
function isStickyCallback(err, isSticky) {
if (err.code) {
console.error("isStickyCommonEvent failed " + JSON.stringify(err));
} else {
console.info("isSticky " + JSON.stringify(isSticky));
}
}
subscriber.isStickyCommonEvent(isStickyCallback);
```
### isStickyCommonEvent
isStickyCommonEvent(): Promise\<boolean>
Checks whether this common event is a sticky one. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ----------------- | -------------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the common event is a sticky one; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.isStickyCommonEvent().then((isSticky) => {
console.info("isSticky " + JSON.stringify(isSticky));
}).catch((err) => {
console.error("isSticky failed " + JSON.stringify(err));
});
```
### abortCommonEvent
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.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for common event aborting.
function abortCallback(err) {
if (err.code) {
console.error("abortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("abortCommonEvent");
}
}
subscriber.abortCommonEvent(abortCallback);
```
### abortCommonEvent
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.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.abortCommonEvent().then(() => {
console.info("abortCommonEvent");
}).catch((err) => {
console.error("abortCommonEvent failed " + JSON.stringify(err));
});
```
### clearAbortCommonEvent
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.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for clearing the aborted state of the current common event.
function clearAbortCallback(err) {
if (err.code) {
console.error("clearAbortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("clearAbortCommonEvent");
}
}
subscriber.clearAbortCommonEvent(clearAbortCallback);
```
### clearAbortCommonEvent
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.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.clearAbortCommonEvent().then(() => {
console.info("clearAbortCommonEvent");
}).catch((err) => {
console.error("clearAbortCommonEvent failed " + JSON.stringify(err));
});
```
### getAbortCommonEvent
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.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the ordered common event is in the aborted state; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for checking whether the current common event is in the aborted state.
function getAbortCallback(err, AbortCommonEvent) {
if (err.code) {
console.error("getAbortCommonEvent failed " + JSON.stringify(err));
} else {
console.info("AbortCommonEvent " + AbortCommonEvent)
}
}
subscriber.getAbortCommonEvent(getAbortCallback);
```
### getAbortCommonEvent
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.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ----------------- | ---------------------------------- |
| Promise\<boolean> | Promise used to return the result. The value **true** means that the ordered common event is in the aborted state; and **false** means the opposite.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.getAbortCommonEvent().then((AbortCommonEvent) => {
console.info("AbortCommonEvent " + JSON.stringify(AbortCommonEvent));
}).catch((err) => {
console.error("getAbortCommonEvent failed " + JSON.stringify(err));
});
```
### getSubscribeInfo
getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
Obtains the subscriber information. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ---------------------- |
| callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Yes | Callback used to return the subscriber information.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for subscriber information obtaining.
function getSubscribeInfoCallback(err, SubscribeInfo) {
if (err.code) {
console.error("getSubscribeInfo failed " + JSON.stringify(err));
} else {
console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
}
}
subscriber.getSubscribeInfo(getSubscribeInfoCallback);
```
### getSubscribeInfo
getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
Obtains the subscriber information. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ------------------------------------------------------------ | ---------------------- |
| Promise\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Promise used to return the subscriber information.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.getSubscribeInfo().then((SubscribeInfo) => {
console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
}).catch((err) => {
console.error("getSubscribeInfo failed " + JSON.stringify(err));
});
```
### finishCommonEvent<sup>9+</sup>
finishCommonEvent(callback: AsyncCallback\<void\>): void
Finishes this ordered common event. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback returned after the ordered common event is finished.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
// Callback for ordered common event finishing.
function finishCommonEventCallback(err) {
if (err.code) {
console.error("finishCommonEvent failed " + JSON.stringify(err));
} else {
console.info("FinishCommonEvent");
}
}
subscriber.finishCommonEvent(finishCommonEventCallback);
```
### finishCommonEvent<sup>9+</sup>
finishCommonEvent(): Promise\<void\>
Finishes this ordered common event. This API uses a promise to return the result.
**System capability**: SystemCapability.Notification.CommonEvent
**Return value**
| Type | Description |
| ---------------- | -------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```ts
var subscriber; // Subscriber object successfully created.
subscriber.finishCommonEvent().then(() => {
console.info("FinishCommonEvent");
}).catch((err) => {
console.error("finishCommonEvent failed " + JSON.stringify(err));
});
```
## CommonEventData
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description |
| ---------- |-------------------- | ---- | ---- | ------------------------------------------------------- |
| event | string | Yes | No | Name of the common event that is being received. |
| bundleName | string | Yes | No | Bundle name. |
| code | number | Yes | No | Result code of the common event, which is used to transfer data of the int type. |
| data | string | Yes | No | Custom result data of the common event, which is used to transfer data of the string type.|
| parameters | {[key: string]: any} | Yes | No | Additional information about the common event. |
## CommonEventPublishData
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description |
| --------------------- | -------------------- | ---- | ---- | ---------------------------- |
| bundleName | string | Yes | No | Bundle name. |
| code | number | Yes | No | Result code of the common event. |
| data | string | Yes | No | Custom result data of the common event.|
| subscriberPermissions | Array\<string> | Yes | No | Permissions required for subscribers to receive the common event. |
| isOrdered | boolean | Yes | No | Whether the common event is an ordered one. |
| isSticky | boolean | Yes | No | Whether the common event is a sticky one. Only system applications and system services are allowed to send sticky events.|
| parameters | {[key: string]: any} | Yes | No | Additional information about the common event. |
## CommonEventSubscribeInfo
**System capability**: SystemCapability.Notification.CommonEvent
| Name | Type | Readable| Writable| Description |
| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
| events | Array\<string> | Yes | No | Name of the common event to publish. |
| publisherPermission | string | Yes | No | Permissions required for publishers to publish the common event. |
| publisherDeviceId | string | Yes | No | Device ID. The value must be the ID of an existing device on the same network. |
| userId | number | Yes | No | User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | number | Yes | No | Subscriber priority. The value ranges from -100 to +1000. |
# Emitter # @ohos.events.emitter
The **Emitter** module provides APIs for sending and processing in-process events, including the APIs for processing events that are subscribed to in persistent or one-shot manner, unsubscribing from events, and emitting events to the event queue. The **Emitter** module provides APIs for sending and processing in-process events, including the APIs for processing events that are subscribed to in persistent or one-shot manner, unsubscribing from events, and emitting events to the event queue.
......
# Notification # @ohos.notification
The **Notification** module provides notification management capabilities, covering notifications, notification slots, notification subscription, notification enabled status, and notification badge status. The **Notification** module provides notification management capabilities, covering notifications, notification slots, notification subscription, notification enabled status, and notification badge status.
...@@ -852,11 +852,7 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -852,11 +852,7 @@ Subscribes to a notification with the subscription information specified. This A
```js ```js
function onConsumeCallback(data) { function onConsumeCallback(data) {
if (err.code) { console.info("Consume callback: " + JSON.stringify(data));
console.info("subscribe failed " + JSON.stringify(err));
} else {
console.info("subscribe success");
}
} }
var subscriber = { var subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
...@@ -1621,7 +1617,7 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal ...@@ -1621,7 +1617,7 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------- | | -------- | --------------------- | ---- | -------------------- |
| hashCode | string | Yes | Unique notification ID. | | hashCode | string | Yes | Unique notification ID. |
| reason | [RemoveReason](#removereason9) | Yes | Reason for removing the notification. | | reason | [RemoveReason](#removereason9) | Yes | Indicates the reason for deleting a notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -1659,7 +1655,7 @@ Removes a notification for a specified bundle. This API uses a promise to return ...@@ -1659,7 +1655,7 @@ Removes a notification for a specified bundle. This API uses a promise to return
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------- | ---- | ---------- | | -------- | ---------- | ---- | ---------- |
| hashCode | string | Yes | Unique notification ID.| | hashCode | string | Yes | Unique notification ID.|
| reason | [RemoveReason](#removereason9) | Yes | Reason for removing the notification. | | reason | [RemoveReason](#removereason9) | Yes | Reason for deleting the notification. |
**Example** **Example**
...@@ -2567,11 +2563,11 @@ Requests notification to be enabled for this application. This API uses an async ...@@ -2567,11 +2563,11 @@ Requests notification to be enabled for this application. This API uses an async
**Example** **Example**
```javascript ```javascript
function requestEnableNotificationCallback() { function requestEnableNotificationCallback(err) {
if (err.code) { if (err.code) {
console.info("requestEnableNotification failed " + JSON.stringify(err)); console.info("requestEnableNotification failed " + JSON.stringify(err));
} else { } else {
console.info("requestEnableNotification success");
} }
}; };
...@@ -2620,7 +2616,7 @@ Sets whether this device supports distributed notifications. This API uses an as ...@@ -2620,7 +2616,7 @@ Sets whether this device supports distributed notifications. This API uses an as
**Example** **Example**
```javascript ```javascript
function enabledNotificationCallback() { function enabledNotificationCallback(err) {
if (err.code) { if (err.code) {
console.info("enableDistributed failed " + JSON.stringify(err)); console.info("enableDistributed failed " + JSON.stringify(err));
} else { } else {
...@@ -2682,11 +2678,11 @@ Obtains whether this device supports distributed notifications. This API uses an ...@@ -2682,11 +2678,11 @@ Obtains whether this device supports distributed notifications. This API uses an
**Example** **Example**
```javascript ```javascript
function isDistributedEnabledCallback() { function isDistributedEnabledCallback(err, data) {
if (err.code) { if (err.code) {
console.info("isDistributedEnabled failed " + JSON.stringify(err)); console.info("isDistributedEnabled failed " + JSON.stringify(err));
} else { } else {
console.info("isDistributedEnabled success"); console.info("isDistributedEnabled success " + JSON.stringify(data));
} }
}; };
...@@ -2742,7 +2738,7 @@ Sets whether an application supports distributed notifications based on the bund ...@@ -2742,7 +2738,7 @@ Sets whether an application supports distributed notifications based on the bund
**Example** **Example**
```javascript ```javascript
function enableDistributedByBundleCallback() { function enableDistributedByBundleCallback(err) {
if (err.code) { if (err.code) {
console.info("enableDistributedByBundle failed " + JSON.stringify(err)); console.info("enableDistributedByBundle failed " + JSON.stringify(err));
} else { } else {
...@@ -2817,11 +2813,11 @@ Obtains whether an application supports distributed notifications based on the b ...@@ -2817,11 +2813,11 @@ Obtains whether an application supports distributed notifications based on the b
**Example** **Example**
```javascript ```javascript
function isDistributedEnabledByBundleCallback(data) { function isDistributedEnabledByBundleCallback(err, data) {
if (err.code) { if (err.code) {
console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err)); console.info("isDistributedEnabledByBundle failed " + JSON.stringify(err));
} else { } else {
console.info("isDistributedEnabledByBundle success"); console.info("isDistributedEnabledByBundle success" + JSON.stringify(data));
} }
}; };
...@@ -2893,7 +2889,7 @@ Obtains the notification reminder type. This API uses an asynchronous callback t ...@@ -2893,7 +2889,7 @@ Obtains the notification reminder type. This API uses an asynchronous callback t
**Example** **Example**
```javascript ```javascript
function getDeviceRemindTypeCallback(data) { function getDeviceRemindTypeCallback(err,data) {
if (err.code) { if (err.code) {
console.info("getDeviceRemindType failed " + JSON.stringify(err)); console.info("getDeviceRemindType failed " + JSON.stringify(err));
} else { } else {
...@@ -3414,6 +3410,8 @@ Notification.getSyncNotificationEnabledWithoutApp(userId) ...@@ -3414,6 +3410,8 @@ Notification.getSyncNotificationEnabledWithoutApp(userId)
## NotificationSubscriber ## NotificationSubscriber
Provides callbacks for receiving or removing notifications.
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
### onConsume ### onConsume
...@@ -3430,7 +3428,7 @@ Callback for receiving notifications. ...@@ -3430,7 +3428,7 @@ Callback for receiving notifications.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | Yes| Notification information returned.| | data | [SubscribeCallbackData](#subscribecallbackdata) | Yes| Notification information returned.|
**Example** **Example**
...@@ -3447,15 +3445,6 @@ function onConsumeCallback(data) { ...@@ -3447,15 +3445,6 @@ function onConsumeCallback(data) {
console.info('===> onConsume in test'); console.info('===> onConsume in test');
let req = data.request; let req = data.request;
console.info('===> onConsume callback req.id:' + req.id); console.info('===> onConsume callback req.id:' + req.id);
let wantAgent = data.wantAgent;
wantAgent .getWant(wantAgent)
.then((data1) => {
console.info('===> getWant success want:' + JSON.stringify(data1));
})
.catch((err) => {
console.error('===> getWant failed because' + JSON.stringify(err));
});
console.info('===> onConsume callback req.wantAgent:' + JSON.stringify(req.wantAgent));
}; };
var subscriber = { var subscriber = {
...@@ -3479,7 +3468,7 @@ Callback for removing notifications. ...@@ -3479,7 +3468,7 @@ Callback for removing notifications.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------------ | ------------------------ | ---- | -------------------------- | | ------------ | ------------------------ | ---- | -------------------------- |
| data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | Yes| Notification information returned.| | data | [SubscribeCallbackData](#subscribecallbackdata) | Yes| Notification information returned.|
**Example** **Example**
...@@ -3723,13 +3712,13 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3723,13 +3712,13 @@ Notification.subscribe(subscriber, subscribeCallback);
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| --------------- | ---- | --- | ------------------------------------------------- | -------- | | --------------- | ------------------------------------------------- | ---- | --- | -------- |
| request | Yes | No | [NotificationRequest](#notificationrequest) | Notification content.| | request | [NotificationRequest](#notificationrequest) | Yes | No | Notification content.|
| sortingMap | Yes | No | [NotificationSortingMap](#notificationsortingmap) | Notification sorting information.| | sortingMap | [NotificationSortingMap](#notificationsortingmap) | Yes | No | Notification sorting information.|
| reason | Yes | No | number | Reason for deletion.| | reason | number | Yes | No | Reason for deletion.|
| sound | Yes | No | string | Sound used for notification.| | sound | string | Yes | No | Sound used for notification.|
| vibrationValues | Yes | No | Array\<number\> | Vibration used for notification.| | vibrationValues | Array\<number\> | Yes | No | Vibration used for notification.|
## EnabledNotificationCallbackData<sup>8+</sup> ## EnabledNotificationCallbackData<sup>8+</sup>
...@@ -3738,11 +3727,11 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3738,11 +3727,11 @@ Notification.subscribe(subscriber, subscribeCallback);
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| ------ | ---- | --- | ------- | ---------------- | | ------ | ------- | ---- | --- | ---------------- |
| bundle | Yes | No | string | Bundle name of the application. | | bundle | string | Yes | No | Bundle name of the application. |
| uid | Yes | No | number | UID of the application. | | uid | number | Yes | No | UID of the application. |
| enable | Yes | No | boolean | Notification enabled status of the application.| | enable | boolean | Yes | No | Notification enabled status of the application.|
## DoNotDisturbDate<sup>8+</sup> ## DoNotDisturbDate<sup>8+</sup>
...@@ -3751,11 +3740,11 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3751,11 +3740,11 @@ Notification.subscribe(subscriber, subscribeCallback);
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| ----- | ---- | --- | ------------------------------------- | ------------------------ | | ----- ------------------------------------- || ---- | --- | ------------------------ |
| type | Yes | No | [DoNotDisturbType](#donotdisturbtype8) | DND time type.| | type | [DoNotDisturbType](#donotdisturbtype8) | Yes | No | DND time type.|
| begin | Yes | No | Date | DND start time.| | begin | Date | Yes | No | DND start time.|
| end | Yes | No | Date | DND end time.| | end | Date | Yes | No | DND end time.|
...@@ -3802,10 +3791,10 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3802,10 +3791,10 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| ------ | ---- | --- | ------ | ------ | | ------ | ------ |---- | --- | ------ |
| bundle | Yes | Yes | string | Bundle name. | | bundle | string | Yes | Yes | Bundle name. |
| uid | Yes | Yes | number | User ID.| | uid | number | Yes | Yes | User ID.|
...@@ -3813,10 +3802,10 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3813,10 +3802,10 @@ Notification.subscribe(subscriber, subscribeCallback);
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| ----- | ---- | --- | ------ | -------- | | ----- | ------ | ---- | --- | -------- |
| id | Yes | Yes | number | Notification ID. | | id | number | Yes | Yes | Notification ID. |
| label | Yes | Yes | string | Notification label.| | label | string | Yes | Yes | Notification label.|
## SlotType ## SlotType
...@@ -3834,84 +3823,98 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3834,84 +3823,98 @@ Notification.subscribe(subscriber, subscribeCallback);
## NotificationActionButton ## NotificationActionButton
Enumerates the buttons in the notification.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| --------- | --- | ---- | ----------------------------------------------- | ------------------------- | | --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
| title | Yes | Yes | string | Button title. | | title | string | Yes | Yes | Button title. |
| wantAgent | Yes | Yes | WantAgent | **WantAgent** of the button.| | wantAgent | WantAgent | Yes | Yes | **WantAgent** of the button.|
| extras | Yes | Yes | { [key: string]: any } | Extra information of the button. | | extras | { [key: string]: any } | Yes | Yes | Extra information of the button. |
| userInput<sup>8+</sup> | Yes | Yes | [NotificationUserInput](#notificationuserinput8) | User input object. | | userInput<sup>8+</sup> | [NotificationUserInput](#notificationuserinput8) | Yes | Yes | User input object. |
## NotificationBasicContent ## NotificationBasicContent
Describes the normal text notification.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| -------------- | ---- | ---- | ------ | ---------------------------------- | | -------------- | ------ | ---- | ---- | ---------------------------------- |
| title | Yes | Yes | string | Notification title. | | title | string | Yes | Yes | Notification title. |
| text | Yes | Yes | string | Notification content. | | text | string | Yes | Yes | Notification content. |
| additionalText | Yes | Yes | string | Additional information of the notification.| | additionalText | string | Yes | Yes | Additional information of the notification.|
## NotificationLongTextContent ## NotificationLongTextContent
Describes the long text notification.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| -------------- | ---- | --- | ------ | -------------------------------- | | -------------- | ------ | ---- | --- | -------------------------------- |
| title | Yes | Yes | string | Notification title. | | title | string | Yes | Yes | Notification title. |
| text | Yes | Yes | string | Notification content. | | text | string | Yes | Yes | Notification content. |
| additionalText | Yes | Yes | string | Additional information of the notification.| | additionalText | string | Yes | Yes | Additional information of the notification.|
| longText | Yes | Yes | string | Long text of the notification. | | longText | string | Yes | Yes | Long text of the notification. |
| briefText | Yes | Yes | string | Brief text of the notification.| | briefText | string | Yes | Yes | Brief text of the notification.|
| expandedTitle | Yes | Yes | string | Title of the notification in the expanded state. | | expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. |
## NotificationMultiLineContent ## NotificationMultiLineContent
Describes the multi-line text notification.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| -------------- | --- | --- | --------------- | -------------------------------- | | -------------- | --------------- | --- | --- | -------------------------------- |
| title | Yes | Yes | string | Notification title. | | title | string | Yes | Yes | Notification title. |
| text | Yes | Yes | string | Notification content. | | text | string | Yes | Yes | Notification content. |
| additionalText | Yes | Yes | string | Additional information of the notification.| | additionalText | string | Yes | Yes | Additional information of the notification.|
| briefText | Yes | Yes | string | Brief text of the notification.| | briefText | string | Yes | Yes | Brief text of the notification.|
| longTitle | Yes | Yes | string | Title of the notification in the expanded state. | | longTitle | string | Yes | Yes | Title of the notification in the expanded state. |
| lines | Yes | Yes | Array\<string\> | Multi-line text of the notification. | | lines | Array\<string\> | Yes | Yes | Multi-line text of the notification. |
## NotificationPictureContent ## NotificationPictureContent
Describes the picture-attached notification.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| -------------- | ---- | --- | -------------- | -------------------------------- | | -------------- | -------------- | ---- | --- | -------------------------------- |
| title | Yes | Yes | string | Notification title. | | title | string | Yes | Yes | Notification title. |
| text | Yes | Yes | string | Notification content. | | text | string | Yes | Yes | Notification content. |
| additionalText | Yes | Yes | string | Additional information of the notification.| | additionalText | string | Yes | Yes | Additional information of the notification.|
| briefText | Yes | Yes | string | Brief text of the notification.| | briefText | string | Yes | Yes | Brief text of the notification.|
| expandedTitle | Yes | Yes | string | Title of the notification in the expanded state. | | expandedTitle | string | Yes | Yes | Title of the notification in the expanded state. |
| picture | Yes | Yes | image.PixelMap | Picture attached to the notification. | | picture | image.PixelMap | Yes | Yes | Picture attached to the notification. |
## NotificationContent ## NotificationContent
Describes the notification content.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| ----------- | ---- | --- | ------------------------------------------------------------ | ------------------ | | ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
| contentType | Yes | Yes | [ContentType](#contenttype) | Notification content type. | | contentType | [ContentType](#contenttype) | Yes | Yes | Notification content type. |
| normal | Yes | Yes | [NotificationBasicContent](#notificationbasiccontent) | Normal text. | | normal | [NotificationBasicContent](#notificationbasiccontent) | Yes | Yes | Normal text. |
| longText | Yes | Yes | [NotificationLongTextContent](#notificationlongtextcontent) | Long text.| | longText | [NotificationLongTextContent](#notificationlongtextcontent) | Yes | Yes | Long text.|
| multiLine | Yes | Yes | [NotificationMultiLineContent](#notificationmultilinecontent) | Multi-line text. | | multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text. |
| picture | Yes | Yes | [NotificationPictureContent](#notificationpicturecontent) | Picture-attached. | | picture | [NotificationPictureContent](#notificationpicturecontent) | Yes | Yes | Picture-attached. |
## NotificationFlagStatus<sup>8+</sup> ## NotificationFlagStatus<sup>8+</sup>
Describes the notification flag status.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
...@@ -3925,133 +3928,149 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -3925,133 +3928,149 @@ Notification.subscribe(subscriber, subscribeCallback);
## NotificationFlags<sup>8+</sup> ## NotificationFlags<sup>8+</sup>
Enumerates notification flags.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| ---------------- | ---- | ---- | ---------------------- | --------------------------------- | | ---------------- | ---------------------- | ---- | ---- | --------------------------------- |
| soundEnabled | Yes | No | NotificationFlagStatus | Whether to enable the sound alert for the notification. | | soundEnabled | NotificationFlagStatus | Yes | No | Whether to enable the sound alert for the notification. |
| vibrationEnabled | Yes | No | NotificationFlagStatus | Whether to enable vibration for the notification. | | vibrationEnabled | NotificationFlagStatus | Yes | No | Whether to enable vibration for the notification. |
## NotificationRequest ## NotificationRequest
**System capability**: SystemCapability.Notification.Notification Describes the notification request.
| Name | Readable| Writable| Type | Description | **System capability**: SystemCapability.Notification.Notification
| --------------------- | ---- | --- | --------------------------------------------- | -------------------------- |
| content | Yes | Yes | [NotificationContent](#notificationcontent) | Notification content. | | Name | Type | Readable| Writable| Description |
| id | Yes | Yes | number | Notification ID. | | --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
| slotType | Yes | Yes | [SlotType](#slottype) | Slot type. | | content | [NotificationContent](#notificationcontent) | Yes | Yes | Notification content. |
| isOngoing | Yes | Yes | boolean | Whether the notification is an ongoing notification. | | id | number | Yes | Yes | Notification ID. |
| isUnremovable | Yes | Yes | boolean | Whether the notification can be removed. | | slotType | [SlotType](#slottype) | Yes | Yes | Slot type. |
| deliveryTime | Yes | Yes | number | Time when the notification is sent. | | isOngoing | boolean | Yes | Yes | Whether the notification is an ongoing notification. |
| tapDismissed | Yes | Yes | boolean | Whether the notification is automatically cleared. | | isUnremovable | boolean | Yes | Yes | Whether the notification can be removed. |
| autoDeletedTime | Yes | Yes | number | Time when the notification is automatically cleared. | | deliveryTime | number | Yes | Yes | Time when the notification is sent. |
| wantAgent | Yes | Yes | WantAgent | **WantAgent** instance to which the notification will be redirected after being clicked. | | tapDismissed | boolean | Yes | Yes | Whether the notification is automatically cleared. |
| extraInfo | Yes | Yes | {[key: string]: any} | Extended parameters. | | autoDeletedTime | number | Yes | Yes | Time when the notification is automatically cleared. |
| color | Yes | Yes | number | Background color of the notification. | | wantAgent | WantAgent | Yes | Yes | **WantAgent** instance to which the notification will be redirected after being clicked. |
| colorEnabled | Yes | Yes | boolean | Whether the notification background color is enabled. | | extraInfo | {[key: string]: any} | Yes | Yes | Extended parameters. |
| isAlertOnce | Yes | Yes | boolean | Whether the notification triggers an alert only once.| | color | number | Yes | Yes | Background color of the notification. Not supported currently. |
| isStopwatch | Yes | Yes | boolean | Whether to display the stopwatch. | | colorEnabled | boolean | Yes | Yes | Whether the notification background color is enabled. Not supported currently. |
| isCountDown | Yes | Yes | boolean | Whether to display the countdown time. | | isAlertOnce | boolean | Yes | Yes | Whether the notification triggers an alert only once.|
| isFloatingIcon | Yes | Yes | boolean | Whether the notification is displayed as a floating icon. | | isStopwatch | boolean | Yes | Yes | Whether to display the stopwatch. |
| label | Yes | Yes | string | Notification label. | | isCountDown | boolean | Yes | Yes | Whether to display the countdown time. |
| badgeIconStyle | Yes | Yes | number | Notification badge type. | | isFloatingIcon | boolean | Yes | Yes | Whether the notification is displayed as a floating icon. |
| showDeliveryTime | Yes | Yes | boolean | Whether to display the time when the notification is delivered. | | label | string | Yes | Yes | Notification label. |
| actionButtons | Yes | Yes | Array\<[NotificationActionButton](#notificationactionbutton)\> | Buttons in the notification. Up to two buttons are allowed. | | badgeIconStyle | number | Yes | Yes | Notification badge type. |
| smallIcon | Yes | Yes | PixelMap | Small notification icon. | | showDeliveryTime | boolean | Yes | Yes | Whether to display the time when the notification is delivered. |
| largeIcon | Yes | Yes | PixelMap | Large notification icon. | | actionButtons | Array\<[NotificationActionButton](#notificationactionbutton)\> | Yes | Yes | Buttons in the notification. Up to two buttons are allowed. |
| creatorBundleName | Yes | No | string | Name of the bundle that creates the notification. | | smallIcon | PixelMap | Yes | Yes | Small notification icon. |
| creatorUid | Yes | No | number | UID used for creating the notification. | | largeIcon | PixelMap | Yes | Yes | Large notification icon. |
| creatorPid | Yes | No | number | PID used for creating the notification. | | creatorBundleName | string | Yes | No | Name of the bundle that creates the notification. |
| creatorUserId<sup>8+</sup>| Yes | No | number | ID of the user who creates the notification. | | creatorUid | number | Yes | No | UID used for creating the notification. |
| hashCode | Yes | No | string | Unique ID of the notification. | | creatorPid | number | Yes | No | PID used for creating the notification. |
| classification | Yes | Yes | string | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications. | | creatorUserId<sup>8+</sup>| number | Yes | No | ID of the user who creates the notification. |
| groupName<sup>8+</sup>| Yes | Yes | string | Group notification name. | | hashCode | string | Yes | No | Unique ID of the notification. |
| template<sup>8+</sup> | Yes | Yes | [NotificationTemplate](#notificationtemplate8) | Notification template. | | classification | string | Yes | Yes | Notification category.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| isRemoveAllowed<sup>8+</sup> | Yes | No | boolean | Whether the notification can be removed.<br>**System API**: This is a system API and cannot be called by third-party applications. | | groupName<sup>8+</sup>| string | Yes | Yes | Group notification name. |
| source<sup>8+</sup> | Yes | No | number | Notification source.<br>**System API**: This is a system API and cannot be called by third-party applications. | | template<sup>8+</sup> | [NotificationTemplate](#notificationtemplate8) | Yes | Yes | Notification template. |
| distributedOption<sup>8+</sup> | Yes | Yes | [DistributedOptions](#distributedoptions8) | Option of distributed notification. | | 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. |
| deviceId<sup>8+</sup> | Yes | No | string | Device ID of the notification source.<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. |
| notificationFlags<sup>8+</sup> | Yes | No | [NotificationFlags](#notificationflags8) | Notification flags. | | distributedOption<sup>8+</sup> | [DistributedOptions](#distributedoptions8) | Yes | Yes | Option of distributed notification. |
| removalWantAgent<sup>9+</sup> | Yes | Yes | WantAgent | **WantAgent** instance to which the notification will be redirected when it is removed. | | 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. |
| badgeNumber<sup>9+</sup> | Yes | Yes | number | Number of notifications displayed on the application icon. | | notificationFlags<sup>8+</sup> | [NotificationFlags](#notificationflags8) | Yes | No | Notification flags. |
| removalWantAgent<sup>9+</sup> | WantAgent | 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. |
## DistributedOptions<sup>8+</sup> ## DistributedOptions<sup>8+</sup>
Describes distributed options.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| ---------------------- | ---- | ---- | -------------- | ---------------------------------- | | ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
| isDistributed | Yes | Yes | boolean | Whether the notification is a distributed notification. | | isDistributed | boolean | Yes | Yes | Whether the notification is a distributed notification. |
| supportDisplayDevices | Yes | Yes | Array\<string> | Types of the devices to which the notification can be synchronized. | | supportDisplayDevices | Array\<string> | Yes | Yes | Types of the devices to which the notification can be synchronized. |
| supportOperateDevices | Yes | Yes | Array\<string> | Devices on which notification can be enabled. | | supportOperateDevices | Array\<string> | Yes | Yes | Devices on which notification can be enabled. |
| remindType | Yes | No | number | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications. | | remindType | number | Yes | No | Notification reminder type.<br>**System API**: This is a system API and cannot be called by third-party applications. |
## NotificationSlot ## NotificationSlot
Describes the notification slot.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| -------------------- | ---- | --- | --------------------- | ------------------------------------------ | | -------------------- | --------------------- | ---- | --- | ------------------------------------------ |
| type | Yes | Yes | [SlotType](#slottype) | Slot type. | | type | [SlotType](#slottype) | Yes | Yes | Slot type. |
| level | Yes | Yes | number | Notification level. If this parameter is not set, the default value is used based on the 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 | Yes | Yes | string | Notification slot description. | | desc | string | Yes | Yes | Notification slot description. |
| badgeFlag | Yes | Yes | boolean | Whether to display the badge. | | badgeFlag | boolean | Yes | Yes | Whether to display the badge. |
| bypassDnd | Yes | Yes | boolean | Whether to bypass the DND mode in the system. | | bypassDnd | boolean | Yes | Yes | Whether to bypass the DND mode in the system. |
| lockscreenVisibility | Yes | Yes | number | Mode for displaying the notification on the lock screen. | | lockscreenVisibility | number | Yes | Yes | Mode for displaying the notification on the lock screen. |
| vibrationEnabled | Yes | Yes | boolean | Whether vibration is supported for the notification. | | vibrationEnabled | boolean | Yes | Yes | Whether vibration is supported for the notification. |
| sound | Yes | Yes | string | Notification alert tone. | | sound | string | Yes | Yes | Notification alert tone. |
| lightEnabled | Yes | Yes | boolean | Whether the indicator blinks for the notification. | | lightEnabled | boolean | Yes | Yes | Whether the indicator blinks for the notification. |
| lightColor | Yes | Yes | number | Indicator color of the notification. | | lightColor | number | Yes | Yes | Indicator color of the notification. |
| vibrationValues | Yes | Yes | Array\<number\> | Vibration mode of the notification. | | vibrationValues | Array\<number\> | Yes | Yes | Vibration mode of the notification. |
| enabled<sup>9+</sup> | Yes | No | boolean | Enabled status of the notification slot. | | enabled<sup>9+</sup> | boolean | Yes | No | Enabled status of the notification slot. |
## NotificationSorting ## NotificationSorting
Provides sorting information of active notifications.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| -------- | ---- | --- | ------------------------------------- | ------------ | | -------- | ------------------------------------- | ---- | --- | ------------ |
| slot | Yes | No | [NotificationSlot](#notificationslot) | Notification slot content.| | slot | [NotificationSlot](#notificationslot) | Yes | No | Notification slot content.|
| hashCode | Yes | No | string | Unique ID of the notification.| | hashCode | string | Yes | No | Unique ID of the notification.|
| ranking | Yes | No | number | Notification sequence number.| | ranking | number | Yes | No | Notification sequence number.|
## NotificationSortingMap ## NotificationSortingMap
Provides sorting information of active notifications in all subscribed notifications.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| -------------- | ---- | --- | ------------------------------------------------------------ | ---------------- | | -------------- | ------------------------------------------------------------ | ---- | --- | ---------------- |
| sortings | Yes | No | {[key: string]: [NotificationSorting](#notificationsorting)} | Array of notification sorting information.| | sortings | {[key: string]: [NotificationSorting](#notificationsorting)} | Yes | No | Array of notification sorting information.|
| sortedHashCode | Yes | No | Array\<string\> | Array of unique notification IDs.| | sortedHashCode | Array\<string\> | Yes | No | Array of unique notification IDs.|
## NotificationSubscribeInfo ## NotificationSubscribeInfo
Provides the information about the publisher for notification subscription.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| ----------- | --- | ---- | --------------- | ------------------------------- | | ----------- | --------------- | --- | ---- | ------------------------------- |
| bundleNames | Yes | Yes | Array\<string\> | Bundle names of the applications whose notifications are to be subscribed to.| | bundleNames | Array\<string\> | Yes | Yes | Bundle names of the applications whose notifications are to be subscribed to.|
| userId | Yes | Yes | number | User whose notifications are to be subscribed to. | | userId | number | Yes | Yes | User whose notifications are to be subscribed to. |
## NotificationTemplate<sup>8+</sup> ## NotificationTemplate<sup>8+</sup>
Notification template.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name| Type | Readable| Writable| Description | | Name| Type | Readable| Writable| Description |
| ---- | ---------------------- | ---- | ---- | ---------- | | ---- | ---------------------- | ---- | ---- | ---------- |
| name | string | Yes | Yes | Template name.| | name | string | Yes | Yes | Template name.|
| data | {[key:string]: Object} | Yes | Yes | Template data.| | data | {[key:string]: Object} | Yes | Yes | Template data.|
...@@ -4059,11 +4078,13 @@ Notification.subscribe(subscriber, subscribeCallback); ...@@ -4059,11 +4078,13 @@ Notification.subscribe(subscriber, subscribeCallback);
## NotificationUserInput<sup>8+</sup> ## NotificationUserInput<sup>8+</sup>
Provides the notification user input.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
| Name | Readable| Writable| Type | Description | | Name | Type | Readable| Writable| Description |
| -------- | --- | ---- | ------ | ----------------------------- | | -------- | ------ | --- | ---- | ----------------------------- |
| inputKey | Yes | Yes | string | Key to identify the user input.| | inputKey | string | Yes | Yes | Key to identify the user input.|
## DeviceRemindType<sup>8+</sup> ## DeviceRemindType<sup>8+</sup>
......
# SystemParameter # @ohos.systemParameter
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs of this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters. The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
For details about the system parameter design principles and definitions, see For details about the system parameter design principles and definitions, see
[Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md). [Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
> **NOTE** > **NOTE**
>
> - The APIs of this module are no longer maintained since API version 9. It is recommended that you use [@ohos.systemParameterV9](js-apis-system-parameterV9.md) instead. > - The APIs of this module are no longer maintained since API version 9. It is recommended that you use [@ohos.systemParameterV9](js-apis-system-parameterV9.md) instead.
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are system APIs. > - The APIs provided by this module are system APIs.
...@@ -54,7 +53,7 @@ try { ...@@ -54,7 +53,7 @@ try {
get(key: string, callback: AsyncCallback&lt;string&gt;): void get(key: string, callback: AsyncCallback&lt;string&gt;): void
Obtains the value of the system parameter with the specified key. This API uses an asynchronous callback to return the result. Obtains the value of the system parameter with the specified key. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Startup.SystemInfo **System capability**: SystemCapability.Startup.SystemInfo
...@@ -164,9 +163,9 @@ Sets a value for the system parameter with the specified key. ...@@ -164,9 +163,9 @@ Sets a value for the system parameter with the specified key.
| value | string | Yes| Value of the system parameter to set.| | value | string | Yes| Value of the system parameter to set.|
> **NOTE** > **NOTE**
>
> - This API can be used only for setting parameters of system applications. > - This API can be used only for setting parameters of system applications.
> - SELinux and DAC rules must be configured for authorized system applications. For details, see [Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md). > - SELinux and Discretionary Access Control (DAC) rules must be configured for authorized system applications. For details about how to configure SELinux and DAC rules, see [Parameter Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
**Example** **Example**
...@@ -195,9 +194,8 @@ Sets a value for the system parameter with the specified key. This API uses an a ...@@ -195,9 +194,8 @@ Sets a value for the system parameter with the specified key. This API uses an a
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
> **NOTE** > **NOTE**
>
> - This API can be used only for setting parameters of system applications. > - This API can be used only for setting parameters of system applications.
> - SELinux and discretionary access control (DAC) rules must be configured for authorized system applications. For details, see [Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md). > - SELinux and Discretionary Access Control (DAC) rules must be configured for authorized system applications. For details about how to configure SELinux and DAC rules, see [Parameter Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
**Example** **Example**
...@@ -236,9 +234,8 @@ Sets a value for the system parameter with the specified key. This API uses a pr ...@@ -236,9 +234,8 @@ Sets a value for the system parameter with the specified key. This API uses a pr
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise used to return the execution result.|
> **NOTE** > **NOTE**
>
> - This API can be used only for setting parameters of system applications. > - This API can be used only for setting parameters of system applications.
> - SELinux and discretionary access control (DAC) rules must be configured for authorized system applications. For details, see [Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md). > - SELinux and Discretionary Access Control (DAC) rules must be configured for authorized system applications. For details about how to configure SELinux and DAC rules, see [Parameter Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
**Example** **Example**
......
# Event Error Codes
## 1500001 Want Action Is Null
**Error Message**
Want action is null
**Description**
This error code is reported when the **Action** attribute in the **want** is null for the event to send.
**Possible Causes**
The **Action** attribute in the **want** is null for the event to send.
**Solution**
Make sure the **Action** attribute in the **want** is not null.
## 1500002 Failed to Send Common Events from a Sandbox Application
**Error Message**
sandbox application can not send common event
**Description**
This error code is reported when an attempt is made to send a common event from a sandbox application.
**Possible Causes**
Common events from a sandbox application are blocked.
**Solution**
Check whether the application used to send a common event is a sandbox application. If so, switch to another application.
## 1500003 Event Sending Frequency Is Too High
**Error Message**
common event send frequency too high
**Description**
This error code is reported when the application sends common events too frequently.
**Possible Causes**
The number of common events sent by the application in a given time frame has reached the maximum.
**Solution**
Do not send common events too frequently.
## 1500004 Failed to Send System Common Events
**Error Message**
not System services or System app
**Description**
This error code is reported when the application cannot send system common events.
**Possible Causes**
The application is not a system application or system service.
**Solution**
Make sure the application to send system common events is a system application or system service.
## 1500005 Subscriber Not Found
**Error Message**
subscriber can not found
**Description**
This error code is reported when the subscriber cannot be found.
**Possible Causes**
The subscriber is deleted.
**Solution**
Check whether the subscription has already been canceled. If the subscription has been canceled, the subscriber is deleted.
## 1500006 Invalid User ID
**Error Message**
usreId is invalid
**Description**
This error code is reported when the user ID is invalid.
**Possible Causes**
The user ID is different from the system user ID, or the application is not a system application or subsystem process.
**Solution**
Check whether the current user ID is the same as the system user ID. If they are different, check whether the application is a system application or subsystem process
## 1500007 Failed to Send a Request Through IPC
**Error Message**
message send error
**Description**
This error code is reported when the attempt to send a request through IPC fails.
**Possible Causes**
The connection object fails to be created.
**Solution**
Do not set up connections frequently. Try again later.
## 1500008 Failed to Read Data
**Error Message**
CEMS error
**Description**
This error code is reported when an error occurs on the server.
**Possible Causes**
A service exception occurs when the server processes data.
**Solution**
Try again later.
## 1500009 System Error
**Error Message**
system error
**Description**
This error code is reported when an exception occurs in the system during service processing, for example, when the current system time fails to be obtained.
**Possible Causes**
A system fault occurs.
**Solution**
Try again later.
# DistributedNotificationService Error Codes
## 1600001 Internal Error
**Error Message**
Internal Error.
**Description**
This error code is reported when an internal processing error occurs, such as a memory allocation or multi-thread processing error.
**Possible Causes**
1. Common kernel errors such as memory allocation and multi-thread processing errors occur.
**Solution**
1. Ensure sufficient system memory.
2. Restart the system.
## 1600002 Data Processing or Interaction Error Between the Application and Notification Subsystem
**Error Message**
IPC Error.
**Description**
This error code is reported when a serialization or deserialization error occurs and the interaction with the notification subsystem fails.
**Possible Causes**
1. A serialization and deserialization error occurs.
2. The interaction with the notification subsystem fails.
**Solution**
1. Make sure the input parameter value is within the valid range.
2. Make sure the notification subsystem is not being started.
## 1600003 Failed to Connect to the Service
**Error Message**
Failed to connect to service.
**Description**
This error code is reported when the notification subsystem is abnormal due to a service connection failure.
**Possible Causes**
The service is busy or the notification subsystem is not working correctly.
**Solution**
1. Try again later.
2. Make sure the notification subsystem is started.
## 1600004 Notification Is Disabled
**Error Message**
Notification is not enabled.
**Description**
This error code is reported when the notification function is disabled.
**Possible Causes**
The notification function is set to its default state (default) or manually disabled.
**Solution**
Enable the notification function.
## 1600005 Notification Slot Is Disabled
**Error Message**
Notification slot is not enabled.
**Description**
This error code is reported when the notification slot is disabled.
**Possible Causes**
The notification slot is disabled.
**Solution**
Make sure the application notification slot is enabled.
## 1600006 Unable to Remove the Notification
**Error Message**
Notification is not allowed to remove.
**Description**
This error code is reported when **isUnremoveable** is set to **true** and an attempt is made to remove all notifications or when **isRemoveAllowed** is set to **false** and an attempt is made to remove a specific notification.
**Possible Causes**
1. When **isUnremoveable** is set to **true**, notifications can only be removed on a one-by-one basis.
2. When **isRemoveAllowed** is set to **false**, no notification can be deleted.
**Solution**
1. Check whether **unremovable** is set to **true**.
2. Check whether **isRemoveAllowed** is set to **false**.
## 1600007 Notification Not Found
**Error Message**
The notification is not exist.
**Description**
This error code is reported when the target notification is not found.
**Possible Causes**
1. The notification has been deleted.
2. The notification has been canceled.
**Solution**
Make sure the notification exists.
## 1600008 User Not Found
**Error Message**
The user is not exist.
**Description**
This error code is reported when the target user is not found.
**Possible Causes**
1. The user ID is incorrect.
2. No user account has not been activated.
**Solution**
Make sure the user account with the specified ID has been activated.
## 1600009 Maximum Number of Notifications per Second Reached
**Error Message**
Over max number notifications per second.
**Description**
This error code is reported when the number of notifications sent per second has reached the maximum.
**Possible Causes**
More than 10 notifications are sent per second.
**Solution**
Reduce the number of notifications sent per second to 10 or less.
## 1600010 Distributed Processing Error
**Error Message**
Distributed operation failed.
**Description**
This error code is reported when a database processing error occurs or the database operations are too frequent.
**Possible Causes**
1. A database processing error occurs.
2. The database operations are too frequent.
**Solution**
1. Make sure the distributed data is running properly.
2. Reduce the database operation frequency.
## 1600011 Failed to read the Template Configuration File
**Error Message**
Read template config failed.
**Description**
This error code is reported when the template configuration file fails to be read.
**Possible Causes**
1. The template configuration file is lost.
2. The current template version is not supported.
**Solution**
1. Check for the **/system/etc/notification_template/external.json** file.
2. Update the version to 3.2 or later.
## 17700001 Bundle Name Not Found
**Error Message**
The specified bundle name was not found.
**Description**
This error code is reported when the specified bund name is not found.
**Possible Causes**
1. The bundle name is incorrect.
2. The application is not installed.
**Solution**
1. Verify the bundle name.
2. Make sure the application has been installed.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册