The **Emitter** module provides APIs for sending and processing in-process events, including the APIs for processing events that are subscribed to in persistent or one-shot manner, unsubscribing from events, and emitting events to the event queue.
The **Emitter** module provides the capabilities of sending and processing inter- or intra-thread events in a process. You can use the APIs of this module to subscribe to an event in persistent or one-shot manner, unsubscribe from an event, or emit an event to the event queue.
> **NOTE**
> **NOTE**
>
>
> The initial APIs of this module are supported since API version 7.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used in the FA model or stage model.
| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in persistent manner. The **EventPriority** settings do not take effect.|
| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in persistent manner. The [EventPriority](#eventpriority) settings do not take effect.|
| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. |
| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback to execute after the event is received. |
**Example**
**Example**
...
@@ -37,26 +39,28 @@ Subscribes to an event in persistent manner. This API uses a callback to return
...
@@ -37,26 +39,28 @@ Subscribes to an event in persistent manner. This API uses a callback to return
letinnerEvent={
letinnerEvent={
eventId:1
eventId:1
};
};
functionEmitterCallback(eventData){
// Execute the callback after receiving the event whose eventId is 1.
| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in one-shot manner. The **EventPriority** settings do not take effect.|
| event | [InnerEvent](#innerevent) | Yes | Event to subscribe to in one-shot manner. The [EventPriority](#eventpriority) settings do not take effect.|
| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback used to return the event. |
| callback | Callback\<[EventData](#eventdata)\> | Yes | Callback to execute after the event is received. |
**Example**
**Example**
...
@@ -64,10 +68,12 @@ Subscribes to an event in one-shot manner and unsubscribes from it after the eve
...
@@ -64,10 +68,12 @@ Subscribes to an event in one-shot manner and unsubscribes from it after the eve
letinnerEvent={
letinnerEvent={
eventId:1
eventId:1
};
};
functionEmitterCallback(eventData){
// Execute the callback after receiving the event whose eventId is 1.
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
sandbox application can not send common event
**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
common event send frequency too high
**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
not System services or System app
**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
subscriber can 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
userId is invalid
**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.
**Solution**
The user ID is different from the system user ID, or the application is not a system application or system service.
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
**Solution**
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
message send error
**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
CEMS error
**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.
This error code is reported when an internal processing error occurs, such as a memory allocation or multi-thread processing error.
This error code is reported when an internal error occurs, such as a memory allocation or multi-thread processing error.
**Possible Causes**
**Possible Causes**
1. Common kernel errors such as memory allocation and multi-thread processing errors occur.
A common kernel error, such as a memory allocation or multi-thread processing error, occurs.
**Solution**
**Solution**
...
@@ -36,8 +36,9 @@ This error code is reported when a serialization or deserialization error occurs
...
@@ -36,8 +36,9 @@ This error code is reported when a serialization or deserialization error occurs
**Solution**
**Solution**
1. Make sure the input parameter value is within the valid range.
1. Make sure the input parameter value length is within the valid range.
2. Make sure the notification subsystem is not being started.
2. Make sure the input parameter value is valid.
3. Make sure the notification subsystem has been started.
## 1600003 Failed to Connect to the Service
## 1600003 Failed to Connect to the Service
...
@@ -47,7 +48,7 @@ Failed to connect to service.
...
@@ -47,7 +48,7 @@ Failed to connect to service.
**Description**
**Description**
This error code is reported when the notification subsystem is abnormal due to a service connection failure.
This error code is reported when the connection with the notification subsystem fails.
**Possible Causes**
**Possible Causes**
...
@@ -66,15 +67,15 @@ Notification is not enabled.
...
@@ -66,15 +67,15 @@ Notification is not enabled.
**Description**
**Description**
This error code is reported when the notification function is disabled.
This error code is reported when the notification feature is disabled.
**Possible Causes**
**Possible Causes**
The notification function is set to its default state (default) or manually disabled.
The notification feature is not enabled manually. By default, this feature is disabled.
**Solution**
**Solution**
Enable the notification function.
Enable the notification feature.
## 1600005 Notification Slot Is Disabled
## 1600005 Notification Slot Is Disabled
...
@@ -102,16 +103,16 @@ Notification is not allowed to remove.
...
@@ -102,16 +103,16 @@ Notification is not allowed to remove.
**Description**
**Description**
This error code is reported when **isUnremoveable** is set to **true** and an attempt is made to remove all notifications or when **isRemoveAllowed** is set to **false** and an attempt is made to remove a specific notification.
This error code is reported when the notification removal does not comply with the permission settings.
**Possible Causes**
**Possible Causes**
1. When **isUnremoveable** is set to **true**, notifications can only be removed on a one-by-one basis.
1. When **isUnremovable** is set to **true**, notifications can only be removed on a one-by-one basis.
2. When **isRemoveAllowed** is set to **false**, no notification can be deleted.
2. When **isRemoveAllowed** is set to **false**, no notification can be removed.
**Solution**
**Solution**
1. Check whether **unremovable** is set to **true**.
1. Check whether **isUnremovable** is set to **true**
2. Check whether **isRemoveAllowed** is set to **false**.
2. Check whether **isRemoveAllowed** is set to **false**.
## 1600007 Notification Not Found
## 1600007 Notification Not Found
...
@@ -131,7 +132,7 @@ This error code is reported when the target notification is not found.
...
@@ -131,7 +132,7 @@ This error code is reported when the target notification is not found.
**Solution**
**Solution**
Make sure the notification exists.
1.Make sure the notification exists.
## 1600008 User Not Found
## 1600008 User Not Found
...
@@ -208,7 +209,7 @@ This error code is reported when the template configuration file fails to be rea
...
@@ -208,7 +209,7 @@ This error code is reported when the template configuration file fails to be rea
**Solution**
**Solution**
1. Check for the **/system/etc/notification_template/external.json** file.
1. Check for the **/system/etc/notification_template/external.json** file.
2. Update the version to 3.2 or later.
2. Update the system version to 3.2 or later.
## 17700001 Bundle Name Not Found
## 17700001 Bundle Name Not Found
...
@@ -228,4 +229,5 @@ This error code is reported when the specified bund name is not found.
...
@@ -228,4 +229,5 @@ This error code is reported when the specified bund name is not found.