A [WantAgent](../reference/apis/js-apis-app-ability-wantAgent.md) object encapsulates an intention to start a specified ability, release a common event, and more. In OpenHarmony, a **WantAgent** object can be passed in a notification from the publisher to the subscriber, so as to trigger the intention specified. For example, you may want the user to start a specific ability by touching the notification published by your application. In this case, you can add a **WantAgent** object that encapsulates such an action to the notification. After receiving the **WantAgent** object, the system triggers it once the user touches the notification from the notification panel, starting the specified ability.
A **WantAgent** object encapsulates an intention to start a specified ability, release a common event, and more. In OpenHarmony, a **WantAgent** object can be passed in a notification from the publisher to the subscriber, so as to trigger the intention specified. For example, you may want the user to start a specific ability by touching the notification published by your application. In this case, you can add a **WantAgent** object that encapsulates such an action to the notification. After receiving the **WantAgent** object, the system triggers it once the user touches the notification from the notification panel, starting the specified ability.
Below you can see the process of adding a **WantAgent** object to a notification. The notification publisher requests a **WantAgent** object from the Ability Manager Service (AMS), and then sends a notification carrying the **WantAgent** object to the home screen. When the user touches the notification from the notification panel on the home screen, the **WantAgent** object is triggered.
Below you can see the process of adding a **WantAgent** object to a notification. The notification publisher requests a **WantAgent** object from the Ability Manager Service (AMS), and then sends a notification carrying the **WantAgent** object to the home screen. When the user touches the notification from the notification panel on the home screen, the **WantAgent** object is triggered.
**Figure 1** Publishing a notification with a WantAgent object
**Figure 1** Publishing a notification with a WantAgent object
Scenario 2: Create a [WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md) object for publishing a [common event](../application-models/common-event-overview.md).
Scenario 2: Create a [WantAgentInfo](../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md) object for publishing a [common event](../application-models/common-event-overview.md).
```typescript
```ts
letwantAgentObj=null;// Save the WantAgent object created. It will be used to complete the trigger operations.
letwantAgentObj=null;// Save the WantAgent object created. It will be used to complete the trigger operations.
// Set the action type through operationType of WantAgentInfo.
// Set the action type through operationType of WantAgentInfo.
...
@@ -77,27 +76,27 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
...
@@ -77,27 +76,27 @@ For details about the APIs, see [@ohos.app.ability.wantAgent](../reference/apis/
}
}
```
```
4. Invoke the [getWantAgent()](../reference/apis/js-apis-app-ability-wantAgent.md#wantagentgetwantagent) API to create a **WantAgent** object.
console.error(`[ANS] failed to publish, error[${err}]`);
console.error(`[ANS] failed to publish, error[${err}]`);
return;
return;
}
}
console.info(`[ANS] publish success`);
console.info(`[ANS] publish success`);
});
});
```
```
6. When the user touches the notification from the notification panel, the system automatically triggers the action specified in the **WantAgent** object.
6. When the user touches the notification from the notification panel, the system automatically triggers the action specified in the **WantAgent** object.
The progress notification is a commonly used notification type, mainly used to display the progress of an ongoing operation, such as file downloading. When publishing a progress notification through the notification subsystem, you can use the readily available template by specifying the related attributes, such as the template name and template data.
The progress notification is a commonly used notification type, mainly used to display the progress of an ongoing operation, such as file downloading. When publishing a progress notification through the notification subsystem, you can use the readily available template by specifying the related attributes, such as the template name and template data.
In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#notificationtemplate), which can only be of the progress type, **data** indicates custom template data.
In the [NotificationTemplate](../reference/apis/js-apis-inner-notification-notificationTemplate.md), which can only be of the progress type, **data** indicates custom template data.
## Available APIs
## Available APIs
...
@@ -20,13 +20,13 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n
...
@@ -20,13 +20,13 @@ In the [NotificationTemplate](../reference/apis/js-apis-notificationManager.md#n
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
For details about the system parameter design principles and definitions, see
For details about the system parameter design principles and definitions, see
> - The APIs of this module are no longer maintained since API version 9. It is recommended that you use [@ohos.systemParameterV9](js-apis-system-parameterV9.md) instead.
> - The APIs of this module are no longer maintained since API version 9. It is recommended that you use [@ohos.systemParameterEnhance](js-apis-system-parameterEnhance.md) instead.
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are system APIs.
> - The APIs provided by this module are system APIs.
> - Third-party applications cannot use the APIs provided by this module, because system parameters each require specific discretionary access control (DAC) and MAC permissions.
> - Third-party applications cannot use the APIs provided by this module, because system parameters each require specific discretionary access control (DAC) and MAC permissions.
This error code is reported when the **Action** attribute in the **want** is null for the event to send.
This error code is reported when the **Action** attribute in the **want** object is null for the event to send.
**Possible Causes**
**Possible Causes**
The **Action** attribute in the **want** is null for the event to send.
The **Action** attribute in the **want** object is null for the event to send.
**Solution**
**Solution**
Make sure the **Action** attribute in the **want** is not null.
Make sure the **Action** attribute in the **want** object is not null.
## 1500002 Failed to Send Common Events from a Sandbox Application
## 1500002 Failed to Send Common Events from a Sandbox Application
**Error Message**
**Error Message**
sandbox application can not send common event
A sandbox application cannot send common events.
**Description**
**Description**
This error code is reported when an attempt is made to send a common event from a sandbox application.
This error code is reported when an attempt is made to send a common event from a sandbox application.
**Possible Causes**
**Possible Causes**
Common events from a sandbox application are blocked.
Common events from a sandbox application are blocked.
**Solution**
**Solution**
Check whether the application used to send a common event is a sandbox application. If so, switch to another application.
Check whether the application used to send a common event is a sandbox application. If so, switch to another application.
## 1500003 Event Sending Frequency Is Too High
## 1500003 Event Sending Frequency Is Too High
**Error Message**
**Error Message**
common event send frequency too high
Too many common events are send in a short period of time.
**Description**
**Description**
This error code is reported when the application sends common events too frequently.
This error code is reported when the application sends common events too frequently.
**Possible Causes**
**Possible Causes**
The number of common events sent by the application in a given time frame has reached the maximum.
The number of common events sent by the application in a given time frame has reached the maximum.
**Solution**
**Solution**
Do not send common events too frequently.
Do not send common events too frequently.
## 1500004 Failed to Send System Common Events
## 1500004 Failed to Send System Common Events
**Error Message**
**Error Message**
not System services or System app
A third-party application cannot send system common events.
**Description**
**Description**
This error code is reported when the application cannot send system common events.
This error code is reported when the application cannot send system common events.
**Possible Causes**
**Possible Causes**
The application is not a system application or system service.
The application is not a system application or system service.
**Solution**
**Solution**
Make sure the application to send system common events is a system application or system service.
Make sure the application to send system common events is a system application or system service.
## 1500005 Subscriber Not Found
## 1500005 Subscriber Not Found
**Error Message**
**Error Message**
subscriber can not found
The subscriber is not found.
**Description**
**Description**
This error code is reported when the subscriber cannot be found.
This error code is reported when the subscriber cannot be found.
**Possible Causes**
**Possible Causes**
The subscriber is deleted.
The subscriber is deleted.
**Solution**
**Solution**
Check whether the subscription has already been canceled. If the subscription has been canceled, the subscriber is deleted.
Check whether the subscription has already been canceled. If the subscription has been canceled, the subscriber is deleted.
## 1500006 Invalid User ID
## 1500006 Invalid User ID
**Error Message**
**Error Message**
usreId is invalid
Invalid userId.
**Description**
**Description**
This error code is reported when the user ID is invalid.
This error code is reported when the user ID is invalid.
**Possible Causes**
**Possible Causes**
The user ID is different from the system user ID, or the application is not a system application or subsystem process.
The user ID is different from the system user ID, or the application is not a system application or system service.
**Solution**
**Solution**
Check whether the current user ID is the same as the system user ID. If they are different, check whether the application is a system application or subsystem process
1. Make sure the current user ID is the same as the system user ID.
2. Make sure the application is a system application or system service.
## 1500007 Failed to Send a Request Through IPC
## 1500007 Failed to Send a Request Through IPC
**Error Message**
**Error Message**
message send error
Failed to send the message.
**Description**
**Description**
This error code is reported when the attempt to send a request through IPC fails.
This error code is reported when the attempt to send a request through IPC fails.
**Possible Causes**
**Possible Causes**
The connection object fails to be created.
The connection object fails to be created.
**Solution**
**Solution**
Do not set up connections frequently. Try again later.
Do not set up connections frequently. Try again later.
## 1500008 Failed to Read Data
## 1500008 Failed to Read Data
**Error Message**
**Error Message**
CEMS error
Failed to read the data.
**Description**
**Description**
This error code is reported when an error occurs on the server.
This error code is reported when an error occurs on the server.
**Possible Causes**
**Possible Causes**
A service exception occurs when the server processes data.
A service exception occurs when the server processes data.
**Solution**
**Solution**
Try again later.
Try again later.
## 1500009 System Error
## 1500009 System Error
**Error Message**
**Error Message**
system error
System error.
**Description**
**Description**
This error code is reported when an exception occurs in the system during service processing, for example, when the current system time fails to be obtained.
This error code is reported when an exception occurs in the system during service processing, for example, when the current system time fails to be obtained.