• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Common Event and Notification Development
2
3## What is the emitter data size limit?
4
5Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
6
7The emitter data size cannot exceed 10240.
8
9## How do I implement the click-a-notification-to-open-an-application function?
10
11Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
12
13You can implement this function by setting the **wantAgent** attribute in the **NotificationRequest** parameter of the **Notification.publish** API.
14
15Reference: [Notification](../reference/apis/js-apis-notification.md#notificationpublish) and [WantAgent](../reference/apis/js-apis-app-ability-wantAgent.md)
16
17Example:
18
19```ts
20import WantAgent from '@ohos.app.ability.wantAgent';
21
22async function publishNotification() {
23  let wantAgentInfo = {
24    wants: [
25      {
26        bundleName: "com.example.myapplication",
27        abilityName: "EntryAbility",
28      }
29    ],
30    operationType: WantAgent.OperationType.START_ABILITIES,
31    requestCode: 0,
32  }
33  const wantAgent = await WantAgent.getWantAgent(wantAgentInfo)
34  let contentType = Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT;
35  await Notification.publish({
36    content: {
37      contentType: contentType,
38      normal: {
39        title: "Test Title",
40        text: "Test content",
41      }
42    },
43    id: 1,
44    wantAgent: wantAgent
45  })
46  prompt.showToast ({ message: "Sent successfully." })
47}
48```
49