diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md b/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md index b3bdfc02bd4ab3e0e3dd7081dcab3205f2b11dd8..71359cac05b2716a4ed36012a18c4734cdc4e60b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEventManager.md @@ -20,13 +20,11 @@ import CommonEventManager from '@ohos.commonEventManager'; ## CommonEventManager.publish -```ts publish(event: string, callback: AsyncCallback): void -``` 发布公共事件,并在发布后执行相应的回调函数。 -**系统能力:** `SystemCapability.Notification.CommonEvent` +**系统能力:** SystemCapability.Notification.CommonEvent **参数:** @@ -61,13 +59,11 @@ try { ## CommonEventManager.publish -```ts publish(event: string, options: CommonEventPublishData, callback: AsyncCallback): void -``` 以回调的形式发布公共事件。 -**系统能力:** `SystemCapability.Notification.CommonEvent` +**系统能力:**SystemCapability.Notification.CommonEvent **参数:** @@ -110,13 +106,11 @@ try { ## CommonEventManager.publishAsUser -```ts publishAsUser(event: string, userId: number, callback: AsyncCallback): void -``` 以回调的形式向指定用户发布公共事件。 -**系统能力:** `SystemCapability.Notification.CommonEvent` +**系统能力:** SystemCapability.Notification.CommonEvent **系统API**:此接口为系统接口,三方应用不支持调用。 @@ -157,13 +151,11 @@ try { ## CommonEventManager.publishAsUser -```ts publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback): void -``` 以回调形式向指定用户发布公共事件并指定发布信息。 -**系统能力:** `SystemCapability.Notification.CommonEvent` +**系统能力:** SystemCapability.Notification.CommonEvent **系统API**:此接口为系统接口,三方应用不支持调用。 @@ -212,13 +204,11 @@ try { ## CommonEventManager.createSubscriber -```ts createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback): void -``` 以回调形式创建订阅者。 -**系统能力:** `SystemCapability.Notification.CommonEvent` +**系统能力:** SystemCapability.Notification.CommonEvent **参数:** @@ -258,13 +248,11 @@ try { ## CommonEventManager.createSubscriber -```ts createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise -``` 以Promise形式创建订阅者。 -**系统能力:** `SystemCapability.Notification.CommonEvent` +**系统能力:** SystemCapability.Notification.CommonEvent **参数:** @@ -299,13 +287,11 @@ CommonEventManager.createSubscriber(subscribeInfo).then((commonEventSubscriber) ## CommonEventManager.subscribe -```ts subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback): void -``` 以回调形式订阅公共事件。 -**系统能力:** `SystemCapability.Notification.CommonEvent` +**系统能力:** SystemCapability.Notification.CommonEvent **参数:** @@ -360,13 +346,11 @@ try { ## CommonEventManager.unsubscribe -```ts unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback): void -``` 以回调形式取消订阅公共事件。 -**系统能力:** `SystemCapability.Notification.CommonEvent` +**系统能力:** SystemCapability.Notification.CommonEvent **参数:** @@ -427,4 +411,69 @@ try { } catch (err) { console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`); } -``` \ No newline at end of file +``` + +## CommonEventManager.removeStickyCommonEvent10+ + +removeStickyCommonEvent(event: string, callback: AsyncCallback): void + +以回调形式移除粘性公共事件。 + +**系统能力:** SystemCapability.Notification.CommonEvent + +**需要权限**: ohos.permission.COMMONEVENT_STICKY + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | -------------------------------- | +| event | string | 是 | 表示被移除的粘性公共事件。 | +| callback | AsyncCallback\ | 是 | 表示移除粘性公共事件的回调方法。 | + +**示例:** + + +```ts +CommonEventManager.removeStickyCommonEvent("sticky_event", (err) => { + if (err) { + console.info(`Remove sticky event AsyncCallback failed, errCode: ${err.code}, errMes: ${err.message}`); + return; + } + console.info(`Remove sticky event AsyncCallback success`); + } +}); +``` + +## CommonEventManager.removeStickyCommonEvent10+ + +removeStickyCommonEvent(event: string): Promise + +以Promise形式移除粘性公共事件。 + +**系统能力:** SystemCapability.Notification.CommonEvent + +**需要权限**: ohos.permission.COMMONEVENT_STICKY + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------- | +| event | string | 是 | 表示被移除的粘性公共事件。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ---------------------------- | +| Promise\ | 表示移除粘性公共事件的对象。 | + +**示例:** + + +```ts +commonEventManager.removeStickyCommonEvent("sticky_event").then(() => { + console.info(`Remove sticky event AsyncCallback success`); +}).catch ((err) => { + console.info(`Remove sticky event AsyncCallback failed, errCode: ${err.code}, errMes: ${err.message}`); +}); +``` +