From acb46f5f983adec89d18cdf6f6b6d262a79795ed Mon Sep 17 00:00:00 2001 From: "ester.zhou" Date: Thu, 4 May 2023 15:07:05 +0800 Subject: [PATCH] Update docs (16854) Signed-off-by: ester.zhou --- .../apis/commonEventManager-definitions.md | 5 + .../apis/js-apis-commonEventManager.md | 202 +++++++++++++++--- 2 files changed, 179 insertions(+), 28 deletions(-) diff --git a/en/application-dev/reference/apis/commonEventManager-definitions.md b/en/application-dev/reference/apis/commonEventManager-definitions.md index 4d400882bb..52859bcc01 100644 --- a/en/application-dev/reference/apis/commonEventManager-definitions.md +++ b/en/application-dev/reference/apis/commonEventManager-definitions.md @@ -932,6 +932,11 @@ Indicates that the HTTP proxy configuration has changed. - Value: **usual.event.HTTP_PROXY_CHANGE** - Required subscriber permissions: none +## COMMON_EVENT_DOMAIN_ACCOUNT_STATUS_CHANGED10+ +Indicates that the domain account status has changed. +- Value: **usual.event.DOMAIN_ACCOUNT_STATUS_CHANGED** +- Required subscriber permissions: none + ## COMMON_EVENT_SIM_STATE_CHANGED10+ Indicates that the SIM card state has changed. - Value: **usual.event.SIM_STATE_CHANGED** diff --git a/en/application-dev/reference/apis/js-apis-commonEventManager.md b/en/application-dev/reference/apis/js-apis-commonEventManager.md index c94524533f..292df5cbe5 100644 --- a/en/application-dev/reference/apis/js-apis-commonEventManager.md +++ b/en/application-dev/reference/apis/js-apis-commonEventManager.md @@ -20,9 +20,7 @@ For details about the definitions of all system common events, see [System Commo ## CommonEventManager.publish -```ts -publish(event: string, callback: AsyncCallback): void -``` +publish(event: string, callback: AsyncCallback\): void Publishes a common event and executes an asynchronous callback after the event is published. @@ -37,7 +35,15 @@ Publishes a common event and executes an asynchronous callback after the event i **Error codes** -For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 401 | The parameter check failed. | +| 1500004 | not System services. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | +| 1500009 | error obtaining system parameters. | **Example** @@ -61,9 +67,7 @@ try { ## CommonEventManager.publish -```ts -publish(event: string, options: CommonEventPublishData, callback: AsyncCallback): void -``` +publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\): void Publishes a common event with given attributes. This API uses an asynchronous callback to return the result. @@ -79,7 +83,15 @@ Publishes a common event with given attributes. This API uses an asynchronous ca **Error codes** -For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 401 | The parameter check failed. | +| 1500004 | not System services. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | +| 1500009 | error obtaining system parameters. | **Example** @@ -110,9 +122,7 @@ try { ## CommonEventManager.publishAsUser -```ts -publishAsUser(event: string, userId: number, callback: AsyncCallback): void -``` +publishAsUser(event: string, userId: number, callback: AsyncCallback\): void Publishes a common event to a specific user. This API uses an asynchronous callback to return the result. @@ -130,7 +140,16 @@ Publishes a common event to a specific user. This API uses an asynchronous callb **Error codes** -For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 202 | not system app. | +| 401 | The parameter check failed. | +| 1500004 | not System services. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | +| 1500009 | error obtaining system parameters. | **Example** @@ -157,9 +176,7 @@ try { ## CommonEventManager.publishAsUser -```ts -publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback): void -``` +publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\): void Publishes a common event with given attributes to a specific user. This API uses an asynchronous callback to return the result. @@ -178,7 +195,16 @@ Publishes a common event with given attributes to a specific user. This API uses **Error codes** -For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 202 | not system app. | +| 401 | The parameter check failed. | +| 1500004 | not System services. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | +| 1500009 | error obtaining system parameters. | **Example** @@ -212,9 +238,7 @@ try { ## CommonEventManager.createSubscriber -```ts -createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback): void -``` +createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\): void Creates a subscriber. This API uses an asynchronous callback to return the result. @@ -227,6 +251,14 @@ Creates a subscriber. This API uses an asynchronous callback to return the resul | subscribeInfo | [CommonEventSubscribeInfo](./js-apis-inner-commonEvent-commonEventSubscribeInfo.md) | Yes | Subscriber information. | | callback | AsyncCallback\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Yes | Callback used to return the result.| +**Error codes** + + For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 401 | The parameter check failed. | + **Example** @@ -258,9 +290,7 @@ try { ## CommonEventManager.createSubscriber -```ts -createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise -``` +createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\ Creates a subscriber. This API uses a promise to return the result. @@ -277,6 +307,14 @@ Creates a subscriber. This API uses a promise to return the result. | --------------------------------------------------------- | ---------------- | | Promise\<[CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md)> | Promise used to return the subscriber object.| +**Error codes** + + For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 401 | The parameter check failed. | + **Example** ```ts @@ -299,9 +337,7 @@ CommonEventManager.createSubscriber(subscribeInfo).then((commonEventSubscriber) ## CommonEventManager.subscribe -```ts -subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback): void -``` +subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\): void Subscribes to common events. This API uses an asynchronous callback to return the result. @@ -314,6 +350,17 @@ Subscribes to common events. This API uses an asynchronous callback to return th | subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | Yes | Subscriber object. | | callback | AsyncCallback\<[CommonEventData](./js-apis-inner-commonEvent-commonEventData.md)> | Yes | Callback used to return the result.| +**Error codes** + + For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 401 | The parameter check failed. | +| 801 | capability not supported. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | + **Example** ```ts @@ -360,9 +407,7 @@ try { ## CommonEventManager.unsubscribe -```ts -unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback): void -``` +unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\): void Unsubscribes from common events. This API uses an asynchronous callback to return the result. @@ -375,6 +420,17 @@ Unsubscribes from common events. This API uses an asynchronous callback to retur | subscriber | [CommonEventSubscriber](./js-apis-inner-commonEvent-commonEventSubscriber.md) | Yes | Subscriber object. | | callback | AsyncCallback\ | No | Callback used to return the result.| +**Error codes** + + For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 401 | The parameter check failed. | +| 801 | capability not supported. | +| 1500007 | error sending message to Common Event Service. | +| 1500008 | Common Event Service does not complete initialization. | + **Example** ```ts @@ -428,3 +484,93 @@ try { console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`); } ``` + +## CommonEventManager.removeStickyCommonEvent10+ + +removeStickyCommonEvent(event: string, callback: AsyncCallback\): void + +Removes a sticky common event. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Notification.CommonEvent + +**Required permissions**: ohos.permission.COMMONEVENT_STICKY + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | -------------------------------- | +| event | string | Yes | Sticky common event to remove. | +| callback | AsyncCallback\ | Yes | Callback used to return the result.| + +**Error codes** + + For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 201 | The application dose not have permission to call the interface. | +| 202 | not system app. | +| 401 | The parameter check failed. | +| 1500004 | not system service. | +| 1500007 | The message send error. | +| 1500008 | The CEMS error. | + +**Example** + + +```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\ + +Removes a sticky common event. This API uses a promise to return the result. + +**System capability**: SystemCapability.Notification.CommonEvent + +**Required permissions**: ohos.permission.COMMONEVENT_STICKY + +**Parameters** + +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | -------------------------- | +| event | string | Yes | Sticky common event to remove.| + +**Return value** + +| Type | Description | +| -------------- | ---------------------------- | +| Promise\ | Promise used to return the result.| + +**Error codes** + + For details about the error codes, see [Event Error Codes](../errorcodes/errorcode-CommonEventService.md). + +| ID| Error Message | +| -------- | ----------------------------------- | +| 201 | The application dose not have permission to call the interface. | +| 202 | not system app. | +| 401 | The parameter check failed. | +| 1500004 | not system service. | +| 1500007 | The message send error. | +| 1500008 | The CEMS error. | + +**Example** + + +```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}`); +}); +``` -- GitLab