未验证 提交 d9b2c727 编写于 作者: O openharmony_ci 提交者: Gitee

!16854 新增removeStickyCommonEvent接口文档

Merge pull request !16854 from FangJinliang/pr_0404
...@@ -20,13 +20,11 @@ import CommonEventManager from '@ohos.commonEventManager'; ...@@ -20,13 +20,11 @@ import CommonEventManager from '@ohos.commonEventManager';
## CommonEventManager.publish ## CommonEventManager.publish
```ts
publish(event: string, callback: AsyncCallback<void>): void publish(event: string, callback: AsyncCallback<void>): void
```
发布公共事件,并在发布后执行相应的回调函数。 发布公共事件,并在发布后执行相应的回调函数。
**系统能力:** `SystemCapability.Notification.CommonEvent` **系统能力:** SystemCapability.Notification.CommonEvent
**参数:** **参数:**
...@@ -61,13 +59,11 @@ try { ...@@ -61,13 +59,11 @@ try {
## CommonEventManager.publish ## CommonEventManager.publish
```ts
publish(event: string, options: CommonEventPublishData, callback: AsyncCallback<void>): void publish(event: string, options: CommonEventPublishData, callback: AsyncCallback<void>): void
```
以回调的形式发布公共事件。 以回调的形式发布公共事件。
**系统能力:** `SystemCapability.Notification.CommonEvent` **系统能力:**SystemCapability.Notification.CommonEvent
**参数:** **参数:**
...@@ -110,13 +106,11 @@ try { ...@@ -110,13 +106,11 @@ try {
## CommonEventManager.publishAsUser<sup> ## CommonEventManager.publishAsUser<sup>
```ts
publishAsUser(event: string, userId: number, callback: AsyncCallback<void>): void publishAsUser(event: string, userId: number, callback: AsyncCallback<void>): void
```
以回调的形式向指定用户发布公共事件。 以回调的形式向指定用户发布公共事件。
**系统能力:** `SystemCapability.Notification.CommonEvent` **系统能力:** SystemCapability.Notification.CommonEvent
**系统API**:此接口为系统接口,三方应用不支持调用。 **系统API**:此接口为系统接口,三方应用不支持调用。
...@@ -157,13 +151,11 @@ try { ...@@ -157,13 +151,11 @@ try {
## CommonEventManager.publishAsUser ## CommonEventManager.publishAsUser
```ts
publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback<void>): void publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback<void>): void
```
以回调形式向指定用户发布公共事件并指定发布信息。 以回调形式向指定用户发布公共事件并指定发布信息。
**系统能力:** `SystemCapability.Notification.CommonEvent` **系统能力:** SystemCapability.Notification.CommonEvent
**系统API**:此接口为系统接口,三方应用不支持调用。 **系统API**:此接口为系统接口,三方应用不支持调用。
...@@ -212,13 +204,11 @@ try { ...@@ -212,13 +204,11 @@ try {
## CommonEventManager.createSubscriber ## CommonEventManager.createSubscriber
```ts
createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback<CommonEventSubscriber>): void createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback<CommonEventSubscriber>): void
```
以回调形式创建订阅者。 以回调形式创建订阅者。
**系统能力:** `SystemCapability.Notification.CommonEvent` **系统能力:** SystemCapability.Notification.CommonEvent
**参数:** **参数:**
...@@ -258,13 +248,11 @@ try { ...@@ -258,13 +248,11 @@ try {
## CommonEventManager.createSubscriber ## CommonEventManager.createSubscriber
```ts
createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise<CommonEventSubscriber> createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise<CommonEventSubscriber>
```
以Promise形式创建订阅者。 以Promise形式创建订阅者。
**系统能力:** `SystemCapability.Notification.CommonEvent` **系统能力:** SystemCapability.Notification.CommonEvent
**参数:** **参数:**
...@@ -299,13 +287,11 @@ CommonEventManager.createSubscriber(subscribeInfo).then((commonEventSubscriber) ...@@ -299,13 +287,11 @@ CommonEventManager.createSubscriber(subscribeInfo).then((commonEventSubscriber)
## CommonEventManager.subscribe ## CommonEventManager.subscribe
```ts
subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback<CommonEventData>): void subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback<CommonEventData>): void
```
以回调形式订阅公共事件。 以回调形式订阅公共事件。
**系统能力:** `SystemCapability.Notification.CommonEvent` **系统能力:** SystemCapability.Notification.CommonEvent
**参数:** **参数:**
...@@ -360,13 +346,11 @@ try { ...@@ -360,13 +346,11 @@ try {
## CommonEventManager.unsubscribe ## CommonEventManager.unsubscribe
```ts
unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback<void>): void unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback<void>): void
```
以回调形式取消订阅公共事件。 以回调形式取消订阅公共事件。
**系统能力:** `SystemCapability.Notification.CommonEvent` **系统能力:** SystemCapability.Notification.CommonEvent
**参数:** **参数:**
...@@ -428,3 +412,68 @@ try { ...@@ -428,3 +412,68 @@ try {
console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`); console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} }
``` ```
## CommonEventManager.removeStickyCommonEvent<sup>10+</sup>
removeStickyCommonEvent(event: string, callback: AsyncCallback<void>): void
以回调形式移除粘性公共事件。
**系统能力:** SystemCapability.Notification.CommonEvent
**需要权限**: ohos.permission.COMMONEVENT_STICKY
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | -------------------------------- |
| event | string | 是 | 表示被移除的粘性公共事件。 |
| callback | AsyncCallback\<void> | 是 | 表示移除粘性公共事件的回调方法。 |
**示例:**
```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.removeStickyCommonEvent<sup>10+</sup>
removeStickyCommonEvent(event: string): Promise<void>
以Promise形式移除粘性公共事件。
**系统能力:** SystemCapability.Notification.CommonEvent
**需要权限**: ohos.permission.COMMONEVENT_STICKY
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------------------- |
| event | string | 是 | 表示被移除的粘性公共事件。 |
**返回值:**
| 类型 | 说明 |
| -------------- | ---------------------------- |
| Promise\<void> | 表示移除粘性公共事件的对象。 |
**示例:**
```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}`);
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册