• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# CommonEvent
2
3The **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.
4
5> **NOTE**<br>
6> 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.
7
8## Common Event List
9
10| Common Event Macro | Common Event Name | Subscriber Permission |
11| ------------ | ------------------ | ---------------------- |
12| COMMON_EVENT_BOOT_COMPLETED                                  | usual.event.BOOT_COMPLETED                                  | ohos.permission.RECEIVER_STARTUP_COMPLETED                   |
13| COMMON_EVENT_LOCKED_BOOT_COMPLETED                           | usual.event.LOCKED_BOOT_COMPLETED                           | ohos.permission.RECEIVER_STARTUP_COMPLETED                   |
14| COMMON_EVENT_SHUTDOWN                                        | usual.event.SHUTDOWN                                        | -                                                          |
15| COMMON_EVENT_BATTERY_CHANGED                                 | usual.event.BATTERY_CHANGED                                 | -                                                          |
16| COMMON_EVENT_BATTERY_LOW                                     | usual.event.BATTERY_LOW                                     | -                                                          |
17| COMMON_EVENT_BATTERY_OKAY                                    | usual.event.BATTERY_OKAY                                    | -                                                          |
18| COMMON_EVENT_POWER_CONNECTED                                 | usual.event.POWER_CONNECTED                                 | -                                                          |
19| COMMON_EVENT_POWER_DISCONNECTED                              | usual.event.POWER_DISCONNECTED                              | -                                                          |
20| COMMON_EVENT_SCREEN_OFF                                      | usual.event.SCREEN_OFF                                      | -                                                          |
21| COMMON_EVENT_SCREEN_ON                                       | usual.event.SCREEN_ON                                       | -                                                          |
22| COMMON_EVENT_THERMAL_LEVEL_CHANGED                           | usual.event.THERMAL_LEVEL_CHANGED                           | -                                                          |
23| COMMON_EVENT_USER_PRESENT                                    | usual.event.USER_PRESENT                                    | -                                                          |
24| COMMON_EVENT_TIME_TICK                                       | usual.event.TIME_TICK                                       | -                                                          |
25| COMMON_EVENT_TIME_CHANGED                                    | usual.event.TIME_CHANGED                                    | -                                                          |
26| COMMON_EVENT_DATE_CHANGED                                    | usual.event.DATE_CHANGED                                    | -                                                          |
27| COMMON_EVENT_TIMEZONE_CHANGED                                | usual.event.TIMEZONE_CHANGED                                | -                                                          |
28| COMMON_EVENT_CLOSE_SYSTEM_DIALOGS                            | usual.event.CLOSE_SYSTEM_DIALOGS                            | -                                                          |
29| COMMON_EVENT_PACKAGE_ADDED                                   | usual.event.PACKAGE_ADDED                                   | -                                                          |
30| COMMON_EVENT_PACKAGE_REPLACED                                | usual.event.PACKAGE_REPLACED                                | -                                                          |
31| COMMON_EVENT_MY_PACKAGE_REPLACED                             | usual.event.MY_PACKAGE_REPLACED                             | -                                                          |
32| COMMON_EVENT_PACKAGE_REMOVED                                 | usual.event.PACKAGE_REMOVED                                 | -                                                          |
33| COMMON_EVENT_BUNDLE_REMOVED                                  | usual.event.BUNDLE_REMOVED                                  | -                                                          |
34| COMMON_EVENT_PACKAGE_FULLY_REMOVED                           | usual.event.PACKAGE_FULLY_REMOVED                           | -                                                          |
35| COMMON_EVENT_PACKAGE_CHANGED                                 | usual.event.PACKAGE_CHANGED                                 | -                                                          |
36| COMMON_EVENT_PACKAGE_RESTARTED                               | usual.event.PACKAGE_RESTARTED                               | -                                                          |
37| COMMON_EVENT_PACKAGE_DATA_CLEARED                            | usual.event.PACKAGE_DATA_CLEARED                            | -                                                          |
38| COMMON_EVENT_PACKAGES_SUSPENDED                              | usual.event.PACKAGES_SUSPENDED                              | -                                                          |
39| COMMON_EVENT_PACKAGES_UNSUSPENDED                            | usual.event.PACKAGES_UNSUSPENDED                            | -                                                          |
40| COMMON_EVENT_MY_PACKAGE_SUSPENDED                            | usual.event.MY_PACKAGE_SUSPENDED                            | -                                                          |
41| COMMON_EVENT_MY_PACKAGE_UNSUSPENDED                          | usual.event.MY_PACKAGE_UNSUSPENDED                          | -                                                          |
42| COMMON_EVENT_UID_REMOVED                                     | usual.event.UID_REMOVED                                     | -                                                          |
43| COMMON_EVENT_PACKAGE_FIRST_LAUNCH                            | usual.event.PACKAGE_FIRST_LAUNCH                            | -                                                          |
44| COMMON_EVENT_PACKAGE_NEEDS_VERIFICATION                      | usual.event.PACKAGE_NEEDS_VERIFICATION                      | -                                                          |
45| COMMON_EVENT_PACKAGE_VERIFIED                                | usual.event.PACKAGE_VERIFIED                                | -                                                          |
46| COMMON_EVENT_EXTERNAL_APPLICATIONS_AVAILABLE                 | usual.event.EXTERNAL_APPLICATIONS_AVAILABLE                 | -                                                          |
47| COMMON_EVENT_EXTERNAL_APPLICATIONS_UNAVAILABLE               | usual.event.EXTERNAL_APPLICATIONS_UNAVAILABLE               | -                                                          |
48| COMMON_EVENT_CONFIGURATION_CHANGED                           | usual.event.CONFIGURATION_CHANGED                           | -                                                          |
49| COMMON_EVENT_LOCALE_CHANGED                                  | usual.event.LOCALE_CHANGED                                  | -                                                          |
50| COMMON_EVENT_MANAGE_PACKAGE_STORAGE                          | usual.event.MANAGE_PACKAGE_STORAGE                          | -                                                          |
51| COMMON_EVENT_DRIVE_MODE                                      | common.event.DRIVE_MODE                                     | -                                                          |
52| COMMON_EVENT_HOME_MODE                                       | common.event.HOME_MODE                                      | -                                                          |
53| COMMON_EVENT_OFFICE_MODE                                     | common.event.OFFICE_MODE                                    | -                                                          |
54| COMMON_EVENT_USER_STARTED                                    | usual.event.USER_STARTED                                    | -                                                          |
55| COMMON_EVENT_USER_BACKGROUND                                 | usual.event.USER_BACKGROUND                                 | -                                                          |
56| COMMON_EVENT_USER_FOREGROUND                                 | usual.event.USER_FOREGROUND                                 | -                                                          |
57| COMMON_EVENT_USER_SWITCHED                                   | usual.event.USER_SWITCHED                                   | ohos.permission.MANAGE_USERS                                 |
58| COMMON_EVENT_USER_STARTING                                   | usual.event.USER_STARTING                                   | ohos.permission.INTERACT_ACROSS_USERS                        |
59| COMMON_EVENT_USER_UNLOCKED                                   | usual.event.USER_UNLOCKED                                   | -                                                          |
60| COMMON_EVENT_USER_STOPPING                                   | usual.event.USER_STOPPING                                   | ohos.permission.INTERACT_ACROSS_USERS                        |
61| COMMON_EVENT_USER_STOPPED                                    | usual.event.USER_STOPPED                                    | -                                                          |
62| COMMON_EVENT_HWID_LOGIN                                      | common.event.HWID_LOGIN                                     | -                                                          |
63| COMMON_EVENT_HWID_LOGOUT                                     | common.event.HWID_LOGOUT                                    | -                                                          |
64| COMMON_EVENT_HWID_TOKEN_INVALID                              | common.event.HWID_TOKEN_INVALID                             | -                                                          |
65| COMMON_EVENT_HWID_LOGOFF                                     | common.event.HWID_LOGOFF                                    | -                                                          |
66| COMMON_EVENT_WIFI_POWER_STATE                                | usual.event.wifi.POWER_STATE                                | -                                                          |
67| COMMON_EVENT_WIFI_SCAN_FINISHED                              | usual.event.wifi.SCAN_FINISHED                              | ohos.permission.LOCATION                                     |
68| COMMON_EVENT_WIFI_RSSI_VALUE                                 | usual.event.wifi.RSSI_VALUE                                 | ohos.permission.GET_WIFI_INFO                                |
69| COMMON_EVENT_WIFI_CONN_STATE                                 | usual.event.wifi.CONN_STATE                                 | -                                                          |
70| COMMON_EVENT_WIFI_HOTSPOT_STATE                              | usual.event.wifi.HOTSPOT_STATE                              | -                                                          |
71| COMMON_EVENT_WIFI_AP_STA_JOIN                                | usual.event.wifi.WIFI_HS_STA_JOIN                           | ohos.permission.GET_WIFI_INFO                                |
72| COMMON_EVENT_WIFI_AP_STA_LEAVE                               | usual.event.wifi.WIFI_HS_STA_LEAVE                          | ohos.permission.GET_WIFI_INFO                                |
73| COMMON_EVENT_WIFI_MPLINK_STATE_CHANGE                        | usual.event.wifi.mplink.STATE_CHANGE                        | ohos.permission.MPLINK_CHANGE_STATE                          |
74| COMMON_EVENT_WIFI_P2P_CONN_STATE                             | usual.event.wifi.p2p.CONN_STATE_CHANGE                      | ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION   |
75| COMMON_EVENT_WIFI_P2P_STATE_CHANGED                          | usual.event.wifi.p2p.STATE_CHANGE                           | ohos.permission.GET_WIFI_INFO                                |
76| COMMON_EVENT_WIFI_P2P_PEERS_STATE_CHANGED                    | usual.event.wifi.p2p.DEVICES_CHANGE                         | ohos.permission.GET_WIFI_INFO                                |
77| COMMON_EVENT_WIFI_P2P_PEERS_DISCOVERY_STATE_CHANGED          | usual.event.wifi.p2p.PEER_DISCOVERY_STATE_CHANGE            | ohos.permission.GET_WIFI_INFO                                |
78| COMMON_EVENT_WIFI_P2P_CURRENT_DEVICE_STATE_CHANGED           | usual.event.wifi.p2p.CURRENT_DEVICE_CHANGE                  | ohos.permission.GET_WIFI_INFO                                |
79| COMMON_EVENT_WIFI_P2P_GROUP_STATE_CHANGED                    | usual.event.wifi.p2p.GROUP_STATE_CHANGED                    | ohos.permission.GET_WIFI_INFO                                |
80| COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CONNECT_STATE_UPDATE     | usual.event.bluetooth.handsfree.ag.CONNECT_STATE_UPDATE     | ohos.permission.USE_BLUETOOTH                                |
81| COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_CURRENT_DEVICE_UPDATE    | usual.event.bluetooth.handsfree.ag.CURRENT_DEVICE_UPDATE    | ohos.permission.USE_BLUETOOTH                                |
82| COMMON_EVENT_BLUETOOTH_HANDSFREE_AG_AUDIO_STATE_UPDATE       | usual.event.bluetooth.handsfree.ag.AUDIO_STATE_UPDATE       | ohos.permission.USE_BLUETOOTH                                |
83| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CONNECT_STATE_UPDATE       | usual.event.bluetooth.a2dpsource.CONNECT_STATE_UPDATE       | ohos.permission.USE_BLUETOOTH                                |
84| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CURRENT_DEVICE_UPDATE      | usual.event.bluetooth.a2dpsource.CURRENT_DEVICE_UPDATE      | ohos.permission.USE_BLUETOOTH                                |
85| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_PLAYING_STATE_UPDATE       | usual.event.bluetooth.a2dpsource.PLAYING_STATE_UPDATE       | ohos.permission.USE_BLUETOOTH                                |
86| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_AVRCP_CONNECT_STATE_UPDATE | usual.event.bluetooth.a2dpsource.AVRCP_CONNECT_STATE_UPDATE | ohos.permission.USE_BLUETOOTH                                |
87| COMMON_EVENT_BLUETOOTH_A2DPSOURCE_CODEC_VALUE_UPDATE         | usual.event.bluetooth.a2dpsource.CODEC_VALUE_UPDATE         | ohos.permission.USE_BLUETOOTH                                |
88| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_DISCOVERED               | usual.event.bluetooth.remotedevice.DISCOVERED               | ohos.permission.LOCATION and ohos.permission.USE_BLUETOOTH   |
89| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CLASS_VALUE_UPDATE       | usual.event.bluetooth.remotedevice.CLASS_VALUE_UPDATE       | ohos.permission.USE_BLUETOOTH                                |
90| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_CONNECTED            | usual.event.bluetooth.remotedevice.ACL_CONNECTED            | ohos.permission.USE_BLUETOOTH                                |
91| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_ACL_DISCONNECTED         | usual.event.bluetooth.remotedevice.ACL_DISCONNECTED         | ohos.permission.USE_BLUETOOTH                                |
92| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_NAME_UPDATE              | usual.event.bluetooth.remotedevice.NAME_UPDATE              | ohos.permission.USE_BLUETOOTH                                |
93| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIR_STATE               | usual.event.bluetooth.remotedevice.PAIR_STATE               | ohos.permission.USE_BLUETOOTH                                |
94| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_BATTERY_VALUE_UPDATE     | usual.event.bluetooth.remotedevice.BATTERY_VALUE_UPDATE     | ohos.permission.USE_BLUETOOTH                                |
95| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_SDP_RESULT               | usual.event.bluetooth.remotedevice.SDP_RESULT               | -                                                          |
96| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_UUID_VALUE               | usual.event.bluetooth.remotedevice.UUID_VALUE               | ohos.permission.DISCOVER_BLUETOOTH                           |
97| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_REQ              | usual.event.bluetooth.remotedevice.PAIRING_REQ              | ohos.permission.DISCOVER_BLUETOOTH                           |
98| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_PAIRING_CANCEL           | usual.event.bluetooth.remotedevice.PAIRING_CANCEL           | -                                                          |
99| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REQ              | usual.event.bluetooth.remotedevice.CONNECT_REQ              | -                                                          |
100| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_REPLY            | usual.event.bluetooth.remotedevice.CONNECT_REPLY            | -                                                          |
101| COMMON_EVENT_BLUETOOTH_REMOTEDEVICE_CONNECT_CANCEL           | usual.event.bluetooth.remotedevice.CONNECT_CANCEL           | -                                                          |
102| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_CONNECT_STATE_UPDATE    | usual.event.bluetooth.handsfreeunit.CONNECT_STATE_UPDATE    | -                                                          |
103| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AUDIO_STATE_UPDATE      | usual.event.bluetooth.handsfreeunit.AUDIO_STATE_UPDATE      | -                                                          |
104| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_COMMON_EVENT         | usual.event.bluetooth.handsfreeunit.AG_COMMON_EVENT         | -                                                          |
105| COMMON_EVENT_BLUETOOTH_HANDSFREEUNIT_AG_CALL_STATE_UPDATE    | usual.event.bluetooth.handsfreeunit.AG_CALL_STATE_UPDATE    | -                                                          |
106| COMMON_EVENT_BLUETOOTH_HOST_STATE_UPDATE                     | usual.event.bluetooth.host.STATE_UPDATE                     | ohos.permission.USE_BLUETOOTH                                |
107| COMMON_EVENT_BLUETOOTH_HOST_REQ_DISCOVERABLE                 | usual.event.bluetooth.host.REQ_DISCOVERABLE                 | -                                                          |
108| COMMON_EVENT_BLUETOOTH_HOST_REQ_ENABLE                       | usual.event.bluetooth.host.REQ_ENABLE                       | ohos.permission.USE_BLUETOOTH                                |
109| COMMON_EVENT_BLUETOOTH_HOST_REQ_DISABLE                      | usual.event.bluetooth.host.REQ_DISABLE                      | ohos.permission.USE_BLUETOOTH                                |
110| COMMON_EVENT_BLUETOOTH_HOST_SCAN_MODE_UPDATE                 | usual.event.bluetooth.host.SCAN_MODE_UPDATE                 | ohos.permission.USE_BLUETOOTH                                |
111| COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_STARTED                | usual.event.bluetooth.host.DISCOVERY_STARTED                | ohos.permission.USE_BLUETOOTH                                |
112| COMMON_EVENT_BLUETOOTH_HOST_DISCOVERY_FINISHED               | usual.event.bluetooth.host.DISCOVERY_FINISHED               | ohos.permission.USE_BLUETOOTH                                |
113| COMMON_EVENT_BLUETOOTH_HOST_NAME_UPDATE                      | usual.event.bluetooth.host.NAME_UPDATE                      | ohos.permission.USE_BLUETOOTH                                |
114| COMMON_EVENT_BLUETOOTH_A2DPSINK_CONNECT_STATE_UPDATE         | usual.event.bluetooth.a2dpsink.CONNECT_STATE_UPDATE         | ohos.permission.USE_BLUETOOTH                                |
115| COMMON_EVENT_BLUETOOTH_A2DPSINK_PLAYING_STATE_UPDATE         | usual.event.bluetooth.a2dpsink.PLAYING_STATE_UPDATE         | ohos.permission.USE_BLUETOOTH                                |
116| COMMON_EVENT_BLUETOOTH_A2DPSINK_AUDIO_STATE_UPDATE           | usual.event.bluetooth.a2dpsink.AUDIO_STATE_UPDATE           | ohos.permission.USE_BLUETOOTH                                |
117| COMMON_EVENT_NFC_ACTION_ADAPTER_STATE_CHANGED                | usual.event.nfc.action.ADAPTER_STATE_CHANGED                | -                                                          |
118| COMMON_EVENT_NFC_ACTION_RF_FIELD_ON_DETECTED                 | usual.event.nfc.action.RF_FIELD_ON_DETECTED                 | ohos.permission.MANAGE_SECURE_SETTINGS                       |
119| COMMON_EVENT_NFC_ACTION_RF_FIELD_OFF_DETECTED                | usual.event.nfc.action.RF_FIELD_OFF_DETECTED                | ohos.permission.MANAGE_SECURE_SETTINGS                       |
120| COMMON_EVENT_DISCHARGING                                     | usual.event.DISCHARGING                                     | -                                                          |
121| COMMON_EVENT_CHARGING                                        | usual.event.CHARGING                                        | -                                                          |
122| COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED                        | usual.event.DEVICE_IDLE_MODE_CHANGED                        | -                                                          |
123| COMMON_EVENT_POWER_SAVE_MODE_CHANGED                         | usual.event.POWER_SAVE_MODE_CHANGED                         | -                                                          |
124| COMMON_EVENT_USER_ADDED                                      | usual.event.USER_ADDED                                      | ohos.permission.MANAGE_USERS                                 |
125| COMMON_EVENT_USER_REMOVED                                    | usual.event.USER_REMOVED                                    | ohos.permission.MANAGE_USERS                                 |
126| COMMON_EVENT_ABILITY_ADDED                                   | usual.event.ABILITY_ADDED                                   | ohos.permission.LISTEN_BUNDLE_CHANGE                         |
127| COMMON_EVENT_ABILITY_REMOVED                                 | usual.event.ABILITY_REMOVED                                 | ohos.permission.LISTEN_BUNDLE_CHANGE                         |
128| COMMON_EVENT_ABILITY_UPDATED                                 | usual.event.ABILITY_UPDATED                                 | ohos.permission.LISTEN_BUNDLE_CHANGE                         |
129| COMMON_EVENT_LOCATION_MODE_STATE_CHANGED                     | usual.event.location.MODE_STATE_CHANGED                     | -                                                          |
130| COMMON_EVENT_IVI_SLEEP                                       | common.event.IVI_SLEEP                                      | -                                                          |
131| COMMON_EVENT_IVI_PAUSE                                       | common.event.IVI_PAUSE                                      | -                                                          |
132| COMMON_EVENT_IVI_STANDBY                                     | common.event.IVI_STANDBY                                    | -                                                          |
133| COMMON_EVENT_IVI_LASTMODE_SAVE                               | common.event.IVI_LASTMODE_SAVE                              | -                                                          |
134| COMMON_EVENT_IVI_VOLTAGE_ABNORMAL                            | common.event.IVI_VOLTAGE_ABNORMAL                           | -                                                          |
135| COMMON_EVENT_IVI_HIGH_TEMPERATURE                            | common.event.IVI_HIGH_TEMPERATURE                           | -                                                          |
136| COMMON_EVENT_IVI_EXTREME_TEMPERATURE                         | common.event.IVI_EXTREME_TEMPERATURE                        | -                                                          |
137| COMMON_EVENT_IVI_TEMPERATURE_ABNORMAL                        | common.event.IVI_TEMPERATURE_ABNORMAL                       | -                                                          |
138| COMMON_EVENT_IVI_VOLTAGE_RECOVERY                            | common.event.IVI_VOLTAGE_RECOVERY                           | -                                                          |
139| COMMON_EVENT_IVI_TEMPERATURE_RECOVERY                        | common.event.IVI_TEMPERATURE_RECOVERY                       | -                                                          |
140| COMMON_EVENT_IVI_ACTIVE                                      | common.event.IVI_ACTIVE                                     | -                                                          |
141| COMMON_EVENT_USB_DEVICE_ATTACHED                             | usual.event.hardware.usb.action.USB_DEVICE_ATTACHED         | -                                                          |
142| COMMON_EVENT_USB_DEVICE_DETACHED                             | usual.event.hardware.usb.action.USB_DEVICE_DETACHED         | -                                                          |
143| COMMON_EVENT_USB_ACCESSORY_ATTACHED                          | usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED      | -                                                          |
144| COMMON_EVENT_USB_ACCESSORY_DETACHED                          | usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED      | -                                                          |
145| COMMON_EVENT_DISK_REMOVED                                    | usual.event.data.DISK_REMOVED                               | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
146| COMMON_EVENT_DISK_UNMOUNTED                                  | usual.event.data.DISK_UNMOUNTED                             | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
147| COMMON_EVENT_DISK_MOUNTED                                    | usual.event.data.DISK_MOUNTED                               | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
148| COMMON_EVENT_DISK_BAD_REMOVAL                                | usual.event.data.DISK_BAD_REMOVAL                           | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
149| COMMON_EVENT_DISK_UNMOUNTABLE                                | usual.event.data.DISK_UNMOUNTABLE                           | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
150| COMMON_EVENT_DISK_EJECT                                      | usual.event.data.DISK_EJECT                                 | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
151| COMMON_EVENT_VOLUME_REMOVED                                  | usual.event.data.VOLUME_REMOVED                             | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
152| COMMON_EVENT_VOLUME_REMOVED<sup>9+<sup>                      | usual.event.data.VOLUME_REMOVED                             | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
153| COMMON_EVENT_VOLUME_UNMOUNTED<sup>9+<sup>                    | usual.event.data.VOLUME_UNMOUNTED                           | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
154| COMMON_EVENT_VOLUME_MOUNTED<sup>9+<sup>                      | usual.event.data.VOLUME_MOUNTED                             | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
155| COMMON_EVENT_VOLUME_BAD_REMOVAL<sup>9+<sup>                  | usual.event.data.VOLUME_BAD_REMOVAL                         | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
156| COMMON_EVENT_VOLUME_EJECT<sup>9+<sup>                        | usual.event.data.VOLUME_EJECT                               | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
157| COMMON_EVENT_VOLUME_UNMOUNTED                                | usual.event.data.VOLUME_UNMOUNTED                           | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
158| COMMON_EVENT_VOLUME_MOUNTED                                  | usual.event.data.VOLUME_MOUNTED                             | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
159| COMMON_EVENT_VOLUME_BAD_REMOVAL                              | usual.event.data.VOLUME_BAD_REMOVAL                         | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
160| COMMON_EVENT_VOLUME_EJECT                                    | usual.event.data.VOLUME_EJECT                               | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE |
161| COMMON_EVENT_VISIBLE_ACCOUNTS_UPDATED                        | usual.event.data.VISIBLE_ACCOUNTS_UPDATED                   | ohos.permission.GET_APP_ACCOUNTS                             |
162| COMMON_EVENT_ACCOUNT_DELETED                                 | usual.event.data.ACCOUNT_DELETED                            | ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS               |
163| COMMON_EVENT_FOUNDATION_READY                                | usual.event.data.FOUNDATION_READY                           | ohos.permission.RECEIVER_STARTUP_COMPLETED                   |
164| COMMON_EVENT_AIRPLANE_MODE_CHANGED                           | usual.event.AIRPLANE_MODE                                   | -                                                          |
165| COMMON_EVENT_SPLIT_SCREEN                                    | usual.event.SPLIT_SCREEN                                    | ohos.permission.RECEIVER_SPLIT_SCREEN                        |
166
167
168## Modules to Import
169
170```js
171import CommonEvent from '@ohos.commonEvent';
172```
173
174## CommonEvent.publish
175
176publish(event: string, callback: AsyncCallback\<void>): void
177
178Publishes a common event. This API uses an asynchronous callback to return the result.
179
180**System capability**: SystemCapability.Notification.CommonEvent
181
182**Parameters**
183
184| Name    | Type                | Mandatory| Description                  |
185| -------- | -------------------- | ---- | ---------------------- |
186| event    | string               | Yes  | Name of the common event to publish.|
187| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|
188
189**Example**
190
191```js
192// Callback for common event publication
193function PublishCallBack(err) {
194	if (err.code) {
195        console.error("publish failed " + JSON.stringify(err));
196    } else {
197        console.info("publish");
198    }
199}
200
201// Publish a common event.
202CommonEvent.publish("event", PublishCallBack);
203```
204
205
206
207## CommonEvent.publish
208
209publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
210
211Publishes a common event with given attributes. This API uses an asynchronous callback to return the result.
212
213**System capability**: SystemCapability.Notification.CommonEvent
214
215**Parameters**
216
217| Name    | Type                  | Mandatory| Description                  |
218| -------- | ---------------------- | ---- | ---------------------- |
219| event    | string                 | Yes  | Name of the common event to publish. |
220| options  | [CommonEventPublishData](#commoneventpublishdata) | Yes  | Attributes of the common event to publish.|
221| callback | AsyncCallback\<void>  | Yes  | Callback used to return the result. |
222
223**Example**
224
225
226```js
227// Attributes of a common event.
228var options = {
229	code: 0,			 // Result code of the common event.
230	data: "initial data";// Result data of the common event.
231	isOrdered: true	 // The common event is an ordered one.
232}
233
234// Callback for common event publication
235function PublishCallBack(err) {
236	if (err.code) {
237        console.error("publish failed " + JSON.stringify(err));
238    } else {
239        console.info("publish");
240    }
241}
242
243// Publish a common event.
244CommonEvent.publish("event", options, PublishCallBack);
245```
246
247
248
249## CommonEvent.publishAsUser<sup>8+</sup>
250
251publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): void
252
253Publishes a common event to a specific user. This API uses an asynchronous callback to return the result.
254
255**System capability**: SystemCapability.Notification.CommonEvent
256
257**System API**: This is a system API and cannot be called by third-party applications.
258
259**Parameters**
260
261| Name    | Type                | Mandatory| Description                              |
262| -------- | -------------------- | ---- | ---------------------------------- |
263| event    | string               | Yes  | Name of the common event to publish.            |
264| userId   | number               | Yes  | User ID.|
265| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.            |
266
267**Example**
268
269```js
270// Callback for common event publication
271function PublishAsUserCallBack(err) {
272	if (err.code) {
273        console.error("publishAsUser failed " + JSON.stringify(err));
274    } else {
275        console.info("publishAsUser");
276    }
277}
278
279// Specify the user to whom the common event will be published.
280var userId = 100;
281
282// Publish a common event.
283CommonEvent.publishAsUser("event", userId, PublishAsUserCallBack);
284```
285
286
287
288## CommonEvent.publishAsUser<sup>8+</sup>
289
290publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
291
292Publishes a common event with given attributes to a specific user. This API uses an asynchronous callback to return the result.
293
294**System capability**: SystemCapability.Notification.CommonEvent
295
296**System API**: This is a system API and cannot be called by third-party applications.
297
298**Parameters**
299
300| Name    | Type                  | Mandatory| Description                  |
301| -------- | ---------------------- | ---- | ---------------------- |
302| event    | string                 | Yes  | Name of the common event to publish. |
303| userId   | number | Yes| User ID.|
304| options  | [CommonEventPublishData](#commoneventpublishdata) | Yes  | Attributes of the common event to publish.|
305| callback | AsyncCallback\<void>   | Yes  | Callback used to return the result. |
306
307**Example**
308
309
310```js
311// Attributes of a common event.
312var options = {
313	code: 0,			 // Result code of the common event.
314	data: "initial data",// Result data of the common event
315}
316
317// Callback for common event publication
318function PublishAsUserCallBack(err) {
319	if (err.code) {
320        console.error("publishAsUser failed " + JSON.stringify(err));
321    } else {
322        console.info("publishAsUser");
323    }
324}
325
326// Specify the user to whom the common event will be published.
327var userId = 100;
328
329// Publish a common event.
330CommonEvent.publishAsUser("event", userId, options, PublishAsUserCallBack);
331```
332
333
334
335## CommonEvent.createSubscriber
336
337createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void
338
339Creates a subscriber. This API uses an asynchronous callback to return the result.
340
341**System capability**: SystemCapability.Notification.CommonEvent
342
343**Parameters**
344
345| Name         | Type                                                        | Mandatory| Description                      |
346| ------------- | ------------------------------------------------------------ | ---- | -------------------------- |
347| subscribeInfo | [CommonEventSubscribeInfo](#commoneventsubscribeinfo)        | Yes  | Subscriber information.            |
348| callback      | AsyncCallback\<[CommonEventSubscriber](#commoneventsubscriber)> | Yes  | Callback used to return the result.|
349
350**Example**
351
352
353```js
354var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
355
356// Subscriber information.
357var subscribeInfo = {
358	events: ["event"]
359};
360
361// Callback for subscriber creation.
362function CreateSubscriberCallBack(err, commonEventSubscriber) {
363    if (err.code) {
364        console.error("createSubscriber failed " + JSON.stringify(err));
365    } else {
366        console.info("createSubscriber");
367        subscriber = commonEventSubscriber;
368    }
369}
370
371// Create a subscriber.
372CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
373```
374
375
376
377## CommonEvent.createSubscriber
378
379createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber>
380
381Creates a subscriber. This API uses a promise to return the result.
382
383**System capability**: SystemCapability.Notification.CommonEvent
384
385**Parameters**
386
387| Name         | Type                                                 | Mandatory| Description          |
388| ------------- | ----------------------------------------------------- | ---- | -------------- |
389| subscribeInfo | [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes  | Subscriber information.|
390
391**Return value**
392| Type                                                     | Description            |
393| --------------------------------------------------------- | ---------------- |
394| Promise\<[CommonEventSubscriber](#commoneventsubscriber)> | Promise used to return the subscriber object.|
395
396**Example**
397
398```js
399var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
400
401// Subscriber information.
402var subscribeInfo = {
403	events: ["event"]
404};
405
406// Create a subscriber.
407CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => {
408    console.info("createSubscriber");
409    subscriber = commonEventSubscriber;
410}).catch((err) => {
411    console.error("createSubscriber failed " + JSON.stringify(err));
412});
413```
414
415
416
417## CommonEvent.subscribe
418
419subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void
420
421Subscribes to common events. This API uses an asynchronous callback to return the result.
422
423**System capability**: SystemCapability.Notification.CommonEvent
424
425**Parameters**
426
427| Name      | Type                                               | Mandatory| Description                            |
428| ---------- | ---------------------------------------------------- | ---- | -------------------------------- |
429| subscriber | [CommonEventSubscriber](#commoneventsubscriber)     | Yes  | Subscriber object.                |
430| callback   | AsyncCallback\<[CommonEventData](#commoneventdata)> | Yes  | Callback used to return the result.|
431
432**Example**
433
434```js
435var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
436
437// Subscriber information.
438var subscribeInfo = {
439    events: ["event"]
440};
441
442// Callback for common event subscription.
443function SubscribeCallBack(err, data) {
444    if (err.code) {
445        console.error("subscribe failed " + JSON.stringify(err));
446    } else {
447        console.info("subscribe " + JSON.stringify(data));
448    }
449}
450
451// Callback for subscriber creation.
452function CreateSubscriberCallBack(err, commonEventSubscriber) {
453    if (err.code) {
454        console.error("createSubscriber failed " + JSON.stringify(err));
455    } else {
456        console.info("createSubscriber");
457        subscriber = commonEventSubscriber;
458        // Subscribe to a common event.
459        CommonEvent.subscribe(subscriber, SubscribeCallBack);
460    }
461}
462
463// Create a subscriber.
464CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
465```
466
467
468
469## CommonEvent.unsubscribe
470
471unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void
472
473Unsubscribes from common events. This API uses an asynchronous callback to return the result.
474
475**System capability**: SystemCapability.Notification.CommonEvent
476
477**Parameters**
478
479| Name      | Type                                            | Mandatory| Description                    |
480| ---------- | ----------------------------------------------- | ---- | ------------------------ |
481| subscriber | [CommonEventSubscriber](#commoneventsubscriber) | Yes  | Subscriber object.        |
482| callback   | AsyncCallback\<void>                            | No  | Callback used to return the result.|
483
484**Example**
485
486```js
487var subscriber;	// Used to save the created subscriber object for subsequent subscription and unsubscription.
488
489// Subscriber information.
490var subscribeInfo = {
491	events: ["event"]
492};
493
494// Callback for common event subscription.
495function SubscribeCallBack(err, data) {
496    if (err.code) {
497        console.info("subscribe failed " + JSON.stringify(err));
498    } else {
499        console.info("subscribe " + JSON.stringify(data));
500    }
501}
502
503// Callback for subscriber creation.
504function CreateSubscriberCallBack(err, commonEventSubscriber) {
505    if (err.code) {
506        console.info("createSubscriber failed " + JSON.stringify(err));
507    } else {
508        console.info("createSubscriber");
509        subscriber = commonEventSubscriber;
510        // Subscribe to a common event.
511        CommonEvent.subscribe(subscriber, SubscribeCallBack);
512    }
513}
514
515// Callback for common event unsubscription.
516function UnsubscribeCallBack(err) {
517	if (err.code) {
518        console.info("unsubscribe failed " + JSON.stringify(err));
519    } else {
520        console.info("unsubscribe");
521    }
522}
523
524// Create a subscriber.
525CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
526
527// Unsubscribe from the common event.
528CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack);
529```
530
531## CommonEventSubscriber
532
533### getCode
534
535getCode(callback: AsyncCallback\<number>): void
536
537Obtains the result code of this common event. This API uses an asynchronous callback to return the result.
538
539**System capability**: SystemCapability.Notification.CommonEvent
540
541**Parameters**
542
543| Name  | Type                  | Mandatory| Description              |
544| -------- | ---------------------- | ---- | ------------------ |
545| callback | AsyncCallback\<number> | Yes  | Callback used to return the result code.|
546
547**Example**
548
549```js
550var subscriber;	// Subscriber object successfully created.
551
552// Callback for result code obtaining of an ordered common event.
553function getCodeCallback(err, Code) {
554    if (err.code) {
555        console.error("getCode failed " + JSON.stringify(err));
556    } else {
557        console.info("getCode " + JSON.stringify(Code));
558    }
559}
560subscriber.getCode(getCodeCallback);
561```
562
563### getCode
564
565getCode(): Promise\<number>
566
567Obtains the result code of this common event. This API uses a promise to return the result.
568
569**System capability**: SystemCapability.Notification.CommonEvent
570
571**Return value**
572
573| Type            | Description                |
574| ---------------- | -------------------- |
575| Promise\<number> | Promise used to return the result.|
576
577**Example**
578
579```js
580var subscriber;	// Subscriber object successfully created.
581
582subscriber.getCode().then((Code) => {
583    console.info("getCode " + JSON.stringify(Code));
584}).catch((err) => {
585    console.error("getCode failed " + JSON.stringify(err));
586});
587```
588
589### setCode
590
591setCode(code: number, callback: AsyncCallback\<void>): void
592
593Sets the result code for this common event. This API uses an asynchronous callback to return the result.
594
595**System capability**: SystemCapability.Notification.CommonEvent
596
597**Parameters**
598
599| Name  | Type                | Mandatory| Description                  |
600| -------- | -------------------- | ---- | ---------------------- |
601| code     | number               | Yes  | Result code of the common event.  |
602| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|
603
604**Example**
605
606```js
607var subscriber;	// Subscriber object successfully created.
608
609// Callback for result code setting of an ordered common event.
610function setCodeCallback(err) {
611    if (err.code) {
612        console.error("setCode failed " + JSON.stringify(err));
613    } else {
614        console.info("setCode");
615    }
616}
617subscriber.setCode(1, setCodeCallback);
618```
619
620### setCode
621
622setCode(code: number): Promise\<void>
623
624Sets the result code for this common event. This API uses a promise to return the result.
625
626**System capability**: SystemCapability.Notification.CommonEvent
627
628**Parameters**
629
630| Name| Type  | Mandatory| Description              |
631| ------ | ------ | ---- | ------------------ |
632| code   | number | Yes  | Result code of the common event.|
633
634**Return value**
635
636| Type            | Description                |
637| ---------------- | -------------------- |
638| Promise\<void>   | Promise used to return the result.|
639
640**Example**
641
642```js
643var subscriber;	// Subscriber object successfully created.
644
645subscriber.setCode(1).then(() => {
646    console.info("setCode");
647}).catch((err) => {
648    console.error("setCode failed " + JSON.stringify(err));
649});
650```
651
652### getData
653
654getData(callback: AsyncCallback\<string>): void
655
656Obtains the result data of this common event. This API uses an asynchronous callback to return the result.
657
658**System capability**: SystemCapability.Notification.CommonEvent
659
660**Parameters**
661
662| Name  | Type                  | Mandatory| Description                |
663| -------- | ---------------------- | ---- | -------------------- |
664| callback | AsyncCallback\<string> | Yes  | Result data of the common event.|
665
666**Example**
667
668```js
669var subscriber;	// Subscriber object successfully created.
670
671// Callback for result data obtaining of an ordered common event.
672function getDataCallback(err, Data) {
673    if (err.code) {
674        console.error("getData failed " + JSON.stringify(err));
675    } else {
676        console.info("getData " + JSON.stringify(Data));
677    }
678}
679subscriber.getData(getDataCallback);
680```
681
682### getData
683
684getData(): Promise\<string>
685
686Obtains the result data of this common event. This API uses a promise to return the result.
687
688**System capability**: SystemCapability.Notification.CommonEvent
689
690**Return value**
691
692| Type            | Description              |
693| ---------------- | ------------------ |
694| Promise\<string> | Result data of the common event.|
695
696**Example**
697
698```js
699var subscriber;	// Subscriber object successfully created.
700
701subscriber.getData().then((Data) => {
702    console.info("getData " + JSON.stringify(Data));
703}).catch((err) => {
704    console.error("getData failed " + JSON.stringify(err));
705});
706```
707
708### setData
709
710setData(data: string, callback: AsyncCallback\<void>): void
711
712Sets the result data for this common event. This API uses an asynchronous callback to return the result.
713
714**System capability**: SystemCapability.Notification.CommonEvent
715
716**Parameters**
717
718| Name  | Type                | Mandatory| Description                |
719| -------- | -------------------- | ---- | -------------------- |
720| data     | string               | Yes  | Result data of the common event.  |
721| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|
722
723**Example**
724
725```js
726var subscriber;	// Subscriber object successfully created.
727
728// Callback for result data setting of an ordered common event
729function setDataCallback(err) {
730    if (err.code) {
731        console.error("setData failed " + JSON.stringify(err));
732    } else {
733        console.info("setData");
734    }
735}
736subscriber.setData("publish_data_changed", setDataCallback);
737```
738
739### setData
740
741setData(data: string): Promise\<void>
742
743Sets the result data for this common event. This API uses a promise to return the result.
744
745**System capability**: SystemCapability.Notification.CommonEvent
746
747**Parameters**
748
749| Name| Type  | Mandatory| Description                |
750| ------ | ------ | ---- | -------------------- |
751| data   | string | Yes  | Result data of the common event.|
752
753**Return value**
754
755| Type            | Description                |
756| ---------------- | -------------------- |
757| Promise\<void>   | Promise used to return the result.|
758
759**Example**
760
761```js
762var subscriber;	// Subscriber object successfully created.
763
764subscriber.setData("publish_data_changed").then(() => {
765    console.info("setData");
766}).catch((err) => {
767    console.error("setData failed " + JSON.stringify(err));
768});
769```
770
771### setCodeAndData
772
773setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
774
775Sets the result code and result data for this common event. This API uses an asynchronous callback to return the result.
776
777**System capability**: SystemCapability.Notification.CommonEvent
778
779**Parameters**
780
781| Name  | Type                | Mandatory| Description                  |
782| -------- | -------------------- | ---- | ---------------------- |
783| code     | number               | Yes  | Result code of the common event.  |
784| data     | string               | Yes  | Result data of the common event.  |
785| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|
786
787**Example**
788
789```js
790var subscriber;	// Subscriber object successfully created.
791
792// Callback for result code and result data setting of an ordered common event.
793function setCodeDataCallback(err) {
794    if (err.code) {
795        console.error("setCodeAndData failed " + JSON.stringify(err));
796    } else {
797        console.info("setCodeDataCallback");
798    }
799}
800subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCallback);
801```
802
803### setCodeAndData
804
805setCodeAndData(code: number, data: string): Promise\<void>
806
807Sets the result code and result data for this common event. This API uses a promise to return the result.
808
809**System capability**: SystemCapability.Notification.CommonEvent
810
811**Parameters**
812
813| Name| Type  | Mandatory| Description                |
814| ------ | ------ | ---- | -------------------- |
815| code   | number | Yes  | Result code of the common event.|
816| data   | string | Yes  | Result data of the common event.|
817
818**Return value**
819
820| Type            | Description                |
821| ---------------- | -------------------- |
822| Promise\<void>   | Promise used to return the result.|
823
824**Example**
825
826```js
827var subscriber;	// Subscriber object successfully created.
828
829subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
830    console.info("setCodeAndData");
831}).catch((err) => {
832    console.info("setCodeAndData failed " + JSON.stringify(err));
833});
834```
835
836### isOrderedCommonEvent
837
838isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
839
840Checks whether this common event is an ordered one. This API uses an asynchronous callback to return the result.
841
842**System capability**: SystemCapability.Notification.CommonEvent
843
844**Parameters**
845
846| Name  | Type                   | Mandatory| Description                              |
847| -------- | ----------------------- | ---- | ---------------------------------- |
848| callback | AsyncCallback\<boolean> | Yes  | Returns **true** if the common event is an ordered one; returns **false** otherwise.|
849
850**Example**
851
852```js
853var subscriber;	// Subscriber object successfully created.
854
855// Callback for checking whether the current common event is an ordered one.
856function isOrderedCallback(err, isOrdered) {
857    if (err.code) {
858        console.error("isOrderedCommonEvent failed " + JSON.stringify(err));
859    } else {
860        console.info("isOrdered " + JSON.stringify(isOrdered));
861    }
862}
863subscriber.isOrderedCommonEvent(isOrderedCallback);
864```
865
866### isOrderedCommonEvent
867
868isOrderedCommonEvent(): Promise\<boolean>
869
870Checks whether this common event is an ordered one. This API uses a promise to return the result.
871
872**System capability**: SystemCapability.Notification.CommonEvent
873
874**Return value**
875
876| Type             | Description                            |
877| ----------------- | -------------------------------- |
878| Promise\<boolean> | Returns **true** if the common event is an ordered one; returns **false** otherwise.|
879
880**Example**
881
882```js
883var subscriber;	// Subscriber object successfully created.
884
885subscriber.isOrderedCommonEvent().then((isOrdered) => {
886    console.info("isOrdered " + JSON.stringify(isOrdered));
887}).catch((err) => {
888    console.error("isOrdered failed " + JSON.stringify(err));
889});
890```
891
892### isStickyCommonEvent
893
894isStickyCommonEvent(callback: AsyncCallback\<boolean>): void
895
896Checks whether this common event is a sticky one. This API uses an asynchronous callback to return the result.
897
898**System capability**: SystemCapability.Notification.CommonEvent
899
900**Parameters**
901
902| Name  | Type                   | Mandatory| Description                              |
903| -------- | ----------------------- | ---- | ---------------------------------- |
904| callback | AsyncCallback\<boolean> | Yes  | Returns **true** if the common event is a sticky one; returns **false** otherwise.|
905
906**Example**
907
908```js
909var subscriber;	// Subscriber object successfully created.
910
911// Callback for checking whether the current common event is a sticky one.
912function isStickyCallback(err, isSticky) {
913    if (err.code) {
914        console.error("isStickyCommonEvent failed " + JSON.stringify(err));
915    } else {
916        console.info("isSticky " + JSON.stringify(isSticky));
917    }
918}
919subscriber.isStickyCommonEvent(isStickyCallback);
920```
921
922### isStickyCommonEvent
923
924isStickyCommonEvent(): Promise\<boolean>
925
926Checks whether this common event is a sticky one. This API uses a promise to return the result.
927
928**System capability**: SystemCapability.Notification.CommonEvent
929
930**Return value**
931
932| Type             | Description                            |
933| ----------------- | -------------------------------- |
934| Promise\<boolean> | Returns **true** if the common event is a sticky one; returns **false** otherwise.|
935
936**Example**
937
938```js
939var subscriber;	// Subscriber object successfully created.
940
941subscriber.isStickyCommonEvent().then((isSticky) => {
942    console.info("isSticky " + JSON.stringify(isSticky));
943}).catch((err) => {
944    console.error("isSticky failed " + JSON.stringify(err));
945});
946```
947
948### abortCommonEvent
949
950abortCommonEvent(callback: AsyncCallback\<void>): void
951
952Aborts 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.
953
954**System capability**: SystemCapability.Notification.CommonEvent
955
956**Parameters**
957
958| Name  | Type                | Mandatory| Description                |
959| -------- | -------------------- | ---- | -------------------- |
960| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|
961
962**Example**
963
964```js
965var subscriber;	// Subscriber object successfully created.
966
967// Callback for common event aborting.
968function abortCallback(err) {
969    if (err.code) {
970        console.error("abortCommonEvent failed " + JSON.stringify(err));
971    } else {
972        console.info("abortCommonEvent");
973    }
974}
975subscriber.abortCommonEvent(abortCallback);
976```
977
978### abortCommonEvent
979
980abortCommonEvent(): Promise\<void>
981
982Aborts 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.
983
984**System capability**: SystemCapability.Notification.CommonEvent
985
986**Return value**
987
988| Type            | Description                |
989| ---------------- | -------------------- |
990| Promise\<void>   | Promise used to return the result.|
991
992**Example**
993
994```js
995var subscriber;	// Subscriber object successfully created.
996
997subscriber.abortCommonEvent().then(() => {
998    console.info("abortCommonEvent");
999}).catch((err) => {
1000    console.error("abortCommonEvent failed " + JSON.stringify(err));
1001});
1002```
1003
1004### clearAbortCommonEvent
1005
1006clearAbortCommonEvent(callback: AsyncCallback\<void>): void
1007
1008Clears 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.
1009
1010**System capability**: SystemCapability.Notification.CommonEvent
1011
1012**Parameters**
1013
1014| Name  | Type                | Mandatory| Description                |
1015| -------- | -------------------- | ---- | -------------------- |
1016| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|
1017
1018**Example**
1019
1020```js
1021var subscriber;	// Subscriber object successfully created.
1022
1023// Callback for clearing the aborted state of the current common event.
1024function clearAbortCallback(err) {
1025    if (err.code) {
1026        console.error("clearAbortCommonEvent failed " + JSON.stringify(err));
1027    } else {
1028        console.info("clearAbortCommonEvent");
1029    }
1030}
1031subscriber.clearAbortCommonEvent(clearAbortCallback);
1032```
1033
1034### clearAbortCommonEvent
1035
1036clearAbortCommonEvent(): Promise\<void>
1037
1038Clears the aborted state of this common event. This API takes effect only for ordered common events. It uses a promise to return the result.
1039
1040**System capability**: SystemCapability.Notification.CommonEvent
1041
1042**Return value**
1043
1044| Type            | Description                |
1045| ---------------- | -------------------- |
1046| Promise\<void>   | Promise used to return the result.|
1047
1048**Example**
1049
1050```js
1051var subscriber;	// Subscriber object successfully created.
1052
1053subscriber.clearAbortCommonEvent().then(() => {
1054    console.info("clearAbortCommonEvent");
1055}).catch((err) => {
1056    console.error("clearAbortCommonEvent failed " + JSON.stringify(err));
1057});
1058```
1059
1060### getAbortCommonEvent
1061
1062getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
1063
1064Checks 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.
1065
1066**System capability**: SystemCapability.Notification.CommonEvent
1067
1068**Parameters**
1069
1070| Name  | Type                   | Mandatory| Description                              |
1071| -------- | ----------------------- | ---- | ---------------------------------- |
1072| callback | AsyncCallback\<boolean> | Yes  | Returns **true** if the ordered common event is in the aborted state; returns **false** otherwise.|
1073
1074**Example**
1075
1076```js
1077var subscriber;	// Subscriber object successfully created.
1078
1079// Callback for checking whether the current common event is in the aborted state.
1080function getAbortCallback(err, AbortCommonEvent) {
1081    if (err.code) {
1082        console.error("getAbortCommonEvent failed " + JSON.stringify(err));
1083    } else {
1084        console.info("AbortCommonEvent " + AbortCommonEvent)
1085    }
1086}
1087subscriber.getAbortCommonEvent(getAbortCallback);
1088```
1089
1090### getAbortCommonEvent
1091
1092getAbortCommonEvent(): Promise\<boolean>
1093
1094Checks 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.
1095
1096**System capability**: SystemCapability.Notification.CommonEvent
1097
1098**Return value**
1099
1100| Type             | Description                              |
1101| ----------------- | ---------------------------------- |
1102| Promise\<boolean> | Returns **true** if the ordered common event is in the aborted state; returns **false** otherwise.|
1103
1104**Example**
1105
1106```js
1107var subscriber;	// Subscriber object successfully created.
1108
1109subscriber.getAbortCommonEvent().then((AbortCommonEvent) => {
1110    console.info("AbortCommonEvent " + JSON.stringify(AbortCommonEvent));
1111}).catch((err) => {
1112    console.error("getAbortCommonEvent failed " + JSON.stringify(err));
1113});
1114```
1115
1116### getSubscribeInfo
1117
1118getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
1119
1120Obtains the subscriber information. This API uses an asynchronous callback to return the result.
1121
1122**System capability**: SystemCapability.Notification.CommonEvent
1123
1124**Parameters**
1125
1126| Name  | Type                                                        | Mandatory| Description                  |
1127| -------- | ------------------------------------------------------------ | ---- | ---------------------- |
1128| callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Yes  | Promise used to return the subscriber information.|
1129
1130**Example**
1131
1132```js
1133var subscriber;	// Subscriber object successfully created.
1134
1135// Callback for subscriber information obtaining.
1136function getSubscribeInfoCallback(err, SubscribeInfo) {
1137    if (err.code) {
1138        console.error("getSubscribeInfo failed " + JSON.stringify(err));
1139    } else {
1140        console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
1141    }
1142}
1143subscriber.getSubscribeInfo(getSubscribeInfoCallback);
1144```
1145
1146### getSubscribeInfo
1147
1148getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
1149
1150Obtains the subscriber information. This API uses a promise to return the result.
1151
1152**System capability**: SystemCapability.Notification.CommonEvent
1153
1154**Return value**
1155
1156| Type                                                        | Description                  |
1157| ------------------------------------------------------------ | ---------------------- |
1158| Promise\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Promise used to return the subscriber information.|
1159
1160**Example**
1161
1162```js
1163var subscriber;	// Subscriber object successfully created.
1164
1165subscriber.getSubscribeInfo().then((SubscribeInfo) => {
1166    console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo));
1167}).catch((err) => {
1168    console.error("getSubscribeInfo failed " + JSON.stringify(err));
1169});
1170```
1171
1172### finishCommonEvent<sup>9+</sup>
1173
1174finishCommonEvent(callback: AsyncCallback\<void\>): void
1175
1176Finishes this ordered common event. This API uses an asynchronous callback to return the result.
1177
1178**System capability**: SystemCapability.Notification.CommonEvent
1179
1180**Parameters**
1181
1182| Name  | Type                 | Mandatory| Description                             |
1183| -------- | -------------------- | ---- | -------------------------------- |
1184| callback | AsyncCallback\<void> | Yes  | Callback returned after the ordered common event is finished.|
1185
1186**Example**
1187
1188```js
1189var subscriber; // Subscriber object successfully created.
1190
1191function finishCommonEventCallback() {
1192    console.log('finishCommonEvent');
1193}
1194
1195subscriber.finishCommonEvent(finishCommonEventCallback);
1196```
1197
1198### finishCommonEvent<sup>9+</sup>
1199
1200finishCommonEvent(): Promise\<void\>
1201
1202Finishes this ordered common event. This API uses a promise to return the result.
1203
1204**System capability**: SystemCapability.Notification.CommonEvent
1205
1206**Return value**
1207
1208| Type            | Description                |
1209| ---------------- | -------------------- |
1210| Promise\<void>   | Promise used to return the result.|
1211
1212**Example**
1213
1214```js
1215var subscriber;	// Subscriber object successfully created.
1216
1217subscriber.finishCommonEvent().then(() => {
1218    console.log('finishCommonEvent');
1219}).catch(() => {
1220    console.log('finishCommonEvent failed');
1221})
1222```
1223
1224## CommonEventData
1225
1226**System capability**: SystemCapability.Notification.CommonEvent
1227
1228| Name      | Readable/Writable| Type                | Mandatory| Description                                                   |
1229| ---------- | -------- | -------------------- | ---- | ------------------------------------------------------- |
1230| event      | Read only    | string               | Yes  | Name of the common event that is being received.                             |
1231| bundleName | Read only    | string               | No  | Bundle name.                                             |
1232| code       | Read only    | number               | No  | Result code of the common event, which is used to transfer data of the int type.          |
1233| data       | Read only    | string               | No  | Custom result data of the common event, which is used to transfer data of the string type.|
1234| parameters | Read only    | {[key: string]: any} | No  | Additional information about the common event.                                 |
1235
1236
1237## CommonEventPublishData
1238
1239**System capability**: SystemCapability.Notification.CommonEvent
1240
1241| Name                 | Readable/Writable| Type                | Mandatory| Description                        |
1242| --------------------- | -------- | -------------------- | ---- | ---------------------------- |
1243| bundleName            | Read only    | string               | No  | Bundle name.                  |
1244| code                  | Read only    | number               | No  | Result code of the common event.      |
1245| data                  | Read only    | string               | No  | Custom result data of the common event.|
1246| subscriberPermissions | Read only    | Array\<string>       | No  | Permissions required for subscribers to receive the common event.            |
1247| isOrdered             | Read only    | boolean              | No  | Whether the common event is an ordered one.          |
1248| isSticky              | Read only    | boolean              | No  | Whether the common event is a sticky one.          |
1249| parameters            | Read only    | {[key: string]: any} | No  | Additional information about the common event.      |
1250
1251## CommonEventSubscribeInfo
1252
1253**System capability**: SystemCapability.Notification.CommonEvent
1254
1255| Name               | Readable/Writable| Type          | Mandatory| Description                                                        |
1256| ------------------- | -------- | -------------- | ---- | ------------------------------------------------------------ |
1257| events              | Read only    | Array\<string> | Yes  | Name of the common event to publish.                                        |
1258| publisherPermission | Read only    | string         | No  | Permissions required for publishers to publish the common event.                                            |
1259| publisherDeviceId   | Read only    | string         | No  | Device ID. The value must be the ID of an existing device on the same network.            |
1260| userId              | Read only    | number         | 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.|
1261| priority            | Read only    | number         | No  | Subscriber priority. The value ranges from -100 to 1000.                    |
1262