1# Introduction to Common Events
2
3
4Common Event Service (CES) is provided for applications to subscribe to, publish, and unsubscribe from common events.
5
6## Classification
7Common events are classified into system common events and custom common events.
8
9
10- System common events: defined in CES. Currently, only system applications and system services can publish system common events, such as HAP installation, update, and uninstall. For details about the supported system common events, see [System Common Events](../../reference/apis-basic-services-kit/common_event/commonEventManager-definitions.md).
11- Custom common events: customized by applications to implement cross-process event communication.
12
13
14Common events are also classified into unordered, ordered, and sticky common events.
15
16
17- Unordered common events: common events that CES forwards regardless of whether subscribers receive the events and when they subscribe to the events.
18- Ordered common events: common events that CES forwards based on the subscriber priority. CES preferentially forwards an ordered common event to the subscriber with higher priority, waits until the subscriber receives the event, and then forwards the events to the subscriber with lower priority. Subscribers with the same priority receive common events in a random order.
19- Sticky common events: common events that can be sent to a subscriber before or after they initiate a subscription. Only system applications and system services can send sticky common events, which remain in the system after being sent. The sends must first request the `ohos.permission.COMMONEVENT_STICKY` permission. For details, see [Declaring Permissions](../../security/AccessToken/declare-permissions.md).
20
21## Working Principles
22Each application can subscribe to common events as required. After your application subscribes to a common event, the system sends it to your application every time the event is published. Such an event may be published by the system, other applications, or your own application.
23
24**Figure 1** Common events
25![common-event](figures/common-event.png)
26
27## Safety Precautions
28
29- **For public event publishers**: Without restrictions, any application can subscribe to common events and read related information. In this case, sensitive information should not be carried in common events. Restrict the receiving scope of common events through the following manners:
30  - Use the **subscriberPermissions** parameter of [CommonEventPublishData](../../reference/apis-basic-services-kit/js-apis-inner-commonEvent-commonEventPublishData.md) to specify the permissions required by the subscriber.
31  - Use the **bundleName** parameter of [CommonEventPublishData](../../reference/apis-basic-services-kit/js-apis-inner-commonEvent-commonEventPublishData.md) to specify the bundle name of the subscriber.
32- **For common event subscribers**: After subscribing to custom common events, any application can send potential malicious common events to the subscribers. Restrict the publishing scope of common events through the following manners:
33  - Use the **publisherPermission** parameter of [CommonEventSubscribeInfo](../../reference/apis-basic-services-kit/js-apis-inner-commonEvent-commonEventSubscribeInfo.md) to specify the permissions required by the publisher.
34  - Use the **publisherBundleName** parameter of [CommonEventSubscribeInfo](../../reference/apis-basic-services-kit/js-apis-inner-commonEvent-commonEventSubscribeInfo.md) to specify the bundle name of the publisher.
35- The name of a custom common event must be globally unique. Otherwise, this common event may conflict with other common events.
36