1e41f4b71Sopenharmony_ci# Removing Sticky Common Events (for System Applications Only)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## When to Use
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciSubscribers can receive sticky common events that have been sent. If the events are no longer forwarded, the event publisher needs to remove them. The system provides an API for removing sticky common events.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci## Available APIs
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ciFor details, see [API Reference](../../reference/apis-basic-services-kit/js-apis-commonEventManager.md).
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci| API| Description|
13e41f4b71Sopenharmony_ci| -------- | -------- |
14e41f4b71Sopenharmony_ci| removeStickyCommonEvent(event: string, callback: AsyncCallback\<void>): void | Removes a sticky common event.|
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## How to Develop
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci1. Declare the **ohos.permission.COMMONEVENT_STICKY** permission. For details, see [Declaring Permissions](../../security/AccessToken/declare-permissions.md).
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci2. Import the module.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci   ```ts
24e41f4b71Sopenharmony_ci   import Base from '@ohos.base';
25e41f4b71Sopenharmony_ci   import commonEventManager from '@ohos.commonEventManager';
26e41f4b71Sopenharmony_ci   import hilog from '@ohos.hilog';
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci   const TAG: string = 'ProcessModel';
29e41f4b71Sopenharmony_ci   const DOMAIN_NUMBER: number = 0xFF00;
30e41f4b71Sopenharmony_ci   ```
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci3. Call the [`removeStickyCommonEvent()`](../../reference/apis-basic-services-kit/js-apis-commonEventManager-sys.md#commoneventmanagerremovestickycommonevent10) method to remove the corresponding sticky common event.
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci   > **NOTE**
35e41f4b71Sopenharmony_ci   >
36e41f4b71Sopenharmony_ci   > The sticky common event to be removed must have been released by the application. For details about how to publish sticky common events, see [Publishing Common Events](common-event-publish.md).
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci   ```ts
39e41f4b71Sopenharmony_ci   // Remove the sticky common event. Replace the event field with the actual event name.
40e41f4b71Sopenharmony_ci   commonEventManager.removeStickyCommonEvent('event', (err: Base.BusinessError) => {
41e41f4b71Sopenharmony_ci     // sticky_event indicates the name of the target sticky common event.
42e41f4b71Sopenharmony_ci     if (err) {
43e41f4b71Sopenharmony_ci       hilog.error(DOMAIN_NUMBER, TAG, `Failed to remove sticky common event. Code is ${err.code}, message is ${err.message}`);
44e41f4b71Sopenharmony_ci       return;
45e41f4b71Sopenharmony_ci     }
46e41f4b71Sopenharmony_ci     //...
47e41f4b71Sopenharmony_ci     hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in removeing sticky event.`);
48e41f4b71Sopenharmony_ci   });
49e41f4b71Sopenharmony_ci   ```
50