1e41f4b71Sopenharmony_ci# @ohos.notification (Notification)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **Notification** module provides notification management capabilities, covering notifications, notification slots, notification subscription, notification enabled status, and notification badge status.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> The APIs provided by this module are no longer maintained since API version 9. You are advised to use [@ohos.notificationManager](js-apis-notificationManager.md).
8e41f4b71Sopenharmony_ci> 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.
9e41f4b71Sopenharmony_ci>
10e41f4b71Sopenharmony_ci> Notification subscription and unsubscription APIs are available only to system applications.
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci## Modules to Import
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci```ts
15e41f4b71Sopenharmony_ciimport Notification from '@ohos.notification';
16e41f4b71Sopenharmony_ci```
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci## Notification.publish
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_cipublish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ciPublishes a notification. This API uses an asynchronous callback to return the result.
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci**Parameters**
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci| Name    | Type                                       | Mandatory | Description                                       |
29e41f4b71Sopenharmony_ci| -------- | ------------------------------------------- | ---- | ------------------------------------------- |
30e41f4b71Sopenharmony_ci| request  | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish. |
31e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\>                       | Yes  | Callback used to return the result.                       |
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**Example**
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci```ts
36e41f4b71Sopenharmony_ciimport NotificationManager from '@ohos.notificationManager';
37e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci// publish callback
40e41f4b71Sopenharmony_cilet publishCallback = (err: Base.BusinessError) => {
41e41f4b71Sopenharmony_ci  if (err) {
42e41f4b71Sopenharmony_ci    console.error(`publish failed, code is ${err}`);
43e41f4b71Sopenharmony_ci  } else {
44e41f4b71Sopenharmony_ci    console.info("publish success");
45e41f4b71Sopenharmony_ci  }
46e41f4b71Sopenharmony_ci}
47e41f4b71Sopenharmony_ci// NotificationRequest object
48e41f4b71Sopenharmony_cilet notificationRequest: NotificationManager.NotificationRequest = {
49e41f4b71Sopenharmony_ci  id: 1,
50e41f4b71Sopenharmony_ci  content: {
51e41f4b71Sopenharmony_ci    contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
52e41f4b71Sopenharmony_ci    normal: {
53e41f4b71Sopenharmony_ci      title: "test_title",
54e41f4b71Sopenharmony_ci      text: "test_text",
55e41f4b71Sopenharmony_ci      additionalText: "test_additionalText"
56e41f4b71Sopenharmony_ci    }
57e41f4b71Sopenharmony_ci  }
58e41f4b71Sopenharmony_ci};
59e41f4b71Sopenharmony_ciNotification.publish(notificationRequest, publishCallback);
60e41f4b71Sopenharmony_ci```
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci## Notification.publish
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_cipublish(request: NotificationRequest): Promise\<void\>
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ciPublishes a notification. This API uses a promise to return the result.
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci**Parameters**
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci| Name    | Type                                       | Mandatory | Description                                       |
73e41f4b71Sopenharmony_ci| -------- | ------------------------------------------- | ---- | ------------------------------------------- |
74e41f4b71Sopenharmony_ci| request  | [NotificationRequest](#notificationrequest) | Yes  | Content and related configuration of the notification to publish. |
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci**Return value**
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci| Type    | Description        | 
79e41f4b71Sopenharmony_ci| ------- |------------|
80e41f4b71Sopenharmony_ci| Promise\<void\> | Promise that returns no value. |  
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci**Example**
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci```ts
85e41f4b71Sopenharmony_ciimport NotificationManager from '@ohos.notificationManager';
86e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci// NotificationRequest object
89e41f4b71Sopenharmony_cilet notificationRequest: NotificationManager.NotificationRequest = {
90e41f4b71Sopenharmony_ci  id: 1,
91e41f4b71Sopenharmony_ci  content: {
92e41f4b71Sopenharmony_ci    contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
93e41f4b71Sopenharmony_ci    normal: {
94e41f4b71Sopenharmony_ci      title: "test_title",
95e41f4b71Sopenharmony_ci      text: "test_text",
96e41f4b71Sopenharmony_ci      additionalText: "test_additionalText"
97e41f4b71Sopenharmony_ci    }
98e41f4b71Sopenharmony_ci  }
99e41f4b71Sopenharmony_ci};
100e41f4b71Sopenharmony_ciNotification.publish(notificationRequest).then(() => {
101e41f4b71Sopenharmony_ci  console.info("publish success");
102e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
103e41f4b71Sopenharmony_ci  console.error(`publish failed, code is ${err}`);
104e41f4b71Sopenharmony_ci});
105e41f4b71Sopenharmony_ci```
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci## Notification.cancel
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_cicancel(id: number, label: string, callback: AsyncCallback\<void\>): void
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ciCancels a notification with the specified ID and label. This API uses an asynchronous callback to return the result.
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci**Parameters**
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci| Name    | Type                 | Mandatory | Description                |
118e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | -------------------- |
119e41f4b71Sopenharmony_ci| id       | number                | Yes  | Notification ID.              |
120e41f4b71Sopenharmony_ci| label    | string                | Yes  | Notification label.            |
121e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. |
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci**Example**
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci```ts
126e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci// cancel callback
129e41f4b71Sopenharmony_cilet cancelCallback = (err: Base.BusinessError) => {
130e41f4b71Sopenharmony_ci  if (err) {
131e41f4b71Sopenharmony_ci    console.info("cancel failed " + JSON.stringify(err));
132e41f4b71Sopenharmony_ci  } else {
133e41f4b71Sopenharmony_ci    console.info("cancel success");
134e41f4b71Sopenharmony_ci  }
135e41f4b71Sopenharmony_ci}
136e41f4b71Sopenharmony_ciNotification.cancel(0, "label", cancelCallback);
137e41f4b71Sopenharmony_ci```
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci## Notification.cancel
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_cicancel(id: number, label?: string): Promise\<void\>
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ciCancels a notification with the specified ID and optional label. This API uses a promise to return the result.
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ci**Parameters**
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci| Name | Type  | Mandatory | Description    |
152e41f4b71Sopenharmony_ci| ----- | ------ | ---- | -------- |
153e41f4b71Sopenharmony_ci| id    | number | Yes  | Notification ID.  |
154e41f4b71Sopenharmony_ci| label | string | No  | Notification label. This parameter is left empty by default. |
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci**Return value**
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci| Type    | Description        | 
159e41f4b71Sopenharmony_ci| ------- |------------|
160e41f4b71Sopenharmony_ci| Promise\<void\> | Promise that returns no value. |  
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci**Example**
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_ci```ts
165e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ciNotification.cancel(0).then(() => {
168e41f4b71Sopenharmony_ci	console.info("cancel success");
169e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
170e41f4b71Sopenharmony_ci  console.error(`cancel failed, code is ${err}`);
171e41f4b71Sopenharmony_ci});
172e41f4b71Sopenharmony_ci```
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci## Notification.cancel
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_cicancel(id: number, callback: AsyncCallback\<void\>): void
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ciCancels a notification with the specified ID. This API uses an asynchronous callback to return the result.
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci**Parameters**
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci| Name    | Type                 | Mandatory | Description                |
187e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | -------------------- |
188e41f4b71Sopenharmony_ci| id       | number                | Yes  | Notification ID.              |
189e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. |
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci**Example**
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci```ts
194e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci// cancel callback
197e41f4b71Sopenharmony_cilet cancelCallback = (err: Base.BusinessError) => {
198e41f4b71Sopenharmony_ci  if (err) {
199e41f4b71Sopenharmony_ci    console.info("cancel failed " + JSON.stringify(err));
200e41f4b71Sopenharmony_ci  } else {
201e41f4b71Sopenharmony_ci    console.info("cancel success");
202e41f4b71Sopenharmony_ci  }
203e41f4b71Sopenharmony_ci}
204e41f4b71Sopenharmony_ciNotification.cancel(0, cancelCallback);
205e41f4b71Sopenharmony_ci```
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ci## Notification.cancelAll
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_cicancelAll(callback: AsyncCallback\<void\>): void
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ciCancels all notifications. This API uses an asynchronous callback to return the result.
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci**Parameters**
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci| Name    | Type                 | Mandatory | Description                |
220e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | -------------------- |
221e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. |
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci**Example**
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ci```ts
226e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci// cancel callback
229e41f4b71Sopenharmony_cilet cancelAllCallback = (err: Base.BusinessError) => {
230e41f4b71Sopenharmony_ci  if (err) {
231e41f4b71Sopenharmony_ci    console.info("cancelAll failed " + JSON.stringify(err));
232e41f4b71Sopenharmony_ci  } else {
233e41f4b71Sopenharmony_ci    console.info("cancelAll success");
234e41f4b71Sopenharmony_ci  }
235e41f4b71Sopenharmony_ci}
236e41f4b71Sopenharmony_ciNotification.cancelAll(cancelAllCallback);
237e41f4b71Sopenharmony_ci```
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci## Notification.cancelAll
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_cicancelAll(): Promise\<void\>
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ciCancels all notifications. This API uses a promise to return the result.
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci**Return value**
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ci| Type    | Description        | 
250e41f4b71Sopenharmony_ci| ------- |------------|
251e41f4b71Sopenharmony_ci| Promise\<void\> | Promise that returns no value. |  
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci**Example**
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ci```ts
256e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ciNotification.cancelAll().then(() => {
259e41f4b71Sopenharmony_ci	console.info("cancelAll success");
260e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
261e41f4b71Sopenharmony_ci  console.error(`cancelAll failed, code is ${err}`);
262e41f4b71Sopenharmony_ci});
263e41f4b71Sopenharmony_ci```
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci## Notification.addSlot
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_ciaddSlot(type: SlotType, callback: AsyncCallback\<void\>): void
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ciAdds a notification slot of a specified type. This API uses an asynchronous callback to return the result.
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci**Parameters**
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci| Name    | Type                 | Mandatory | Description                  |
276e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ---------------------- |
277e41f4b71Sopenharmony_ci| type     | [SlotType](#slottype)              | Yes  | Type of the notification slot to add. |
278e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.  |
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ci**Example**
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci```ts
283e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci// addSlot callback
286e41f4b71Sopenharmony_cilet addSlotCallBack = (err: Base.BusinessError) => {
287e41f4b71Sopenharmony_ci  if (err) {
288e41f4b71Sopenharmony_ci    console.info("addSlot failed " + JSON.stringify(err));
289e41f4b71Sopenharmony_ci  } else {
290e41f4b71Sopenharmony_ci    console.info("addSlot success");
291e41f4b71Sopenharmony_ci  }
292e41f4b71Sopenharmony_ci}
293e41f4b71Sopenharmony_ciNotification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);
294e41f4b71Sopenharmony_ci```
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci## Notification.addSlot
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ciaddSlot(type: SlotType): Promise\<void\>
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ciAdds a notification slot of a specified type. This API uses a promise to return the result.
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci**Parameters**
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci| Name | Type    | Mandatory | Description                  |
307e41f4b71Sopenharmony_ci| ---- | -------- | ---- | ---------------------- |
308e41f4b71Sopenharmony_ci| type | [SlotType](#slottype) | Yes  | Type of the notification slot to add. |
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci**Return value**
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci| Type    | Description        | 
313e41f4b71Sopenharmony_ci| ------- |------------|
314e41f4b71Sopenharmony_ci| Promise\<void\> | Promise that returns no value. |  
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ci**Example**
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ci```ts
319e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ciNotification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => {
322e41f4b71Sopenharmony_ci  console.info("addSlot success");
323e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
324e41f4b71Sopenharmony_ci  console.error(`addSlot failed, code is ${err}`);
325e41f4b71Sopenharmony_ci});
326e41f4b71Sopenharmony_ci```
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ci## Notification.getSlot
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_cigetSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ciObtains a notification slot of a specified type. This API uses an asynchronous callback to return the result.
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci**Parameters**
337e41f4b71Sopenharmony_ci
338e41f4b71Sopenharmony_ci| Name    | Type                             | Mandatory | Description                                                       |
339e41f4b71Sopenharmony_ci| -------- | --------------------------------- | ---- | ----------------------------------------------------------- |
340e41f4b71Sopenharmony_ci| slotType | [SlotType](#slottype)                          | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes. |
341e41f4b71Sopenharmony_ci| callback | AsyncCallback\<[NotificationSlot](#notificationslot)\> | Yes  | Callback used to return the result.                                       |
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci**Example**
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci```ts
346e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
347e41f4b71Sopenharmony_ci
348e41f4b71Sopenharmony_ci// getSlot callback
349e41f4b71Sopenharmony_cilet getSlotCallback = (err: Base.BusinessError) => {
350e41f4b71Sopenharmony_ci  if (err) {
351e41f4b71Sopenharmony_ci    console.info("getSlot failed " + JSON.stringify(err));
352e41f4b71Sopenharmony_ci  } else {
353e41f4b71Sopenharmony_ci    console.info("getSlot success");
354e41f4b71Sopenharmony_ci  }
355e41f4b71Sopenharmony_ci}
356e41f4b71Sopenharmony_cilet slotType: Notification.SlotType = Notification.SlotType.SOCIAL_COMMUNICATION;
357e41f4b71Sopenharmony_ciNotification.getSlot(slotType, getSlotCallback);
358e41f4b71Sopenharmony_ci```
359e41f4b71Sopenharmony_ci
360e41f4b71Sopenharmony_ci## Notification.getSlot
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_cigetSlot(slotType: SlotType): Promise\<NotificationSlot\>
363e41f4b71Sopenharmony_ci
364e41f4b71Sopenharmony_ciObtains a notification slot of a specified type. This API uses a promise to return the result.
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci**Parameters**
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ci| Name    | Type    | Mandatory | Description                                                       |
371e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ----------------------------------------------------------- |
372e41f4b71Sopenharmony_ci| slotType | [SlotType](#slottype) | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes. |
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ci**Return value**
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ci| Type                                                       | Description                                                        |
377e41f4b71Sopenharmony_ci| ----------------------------------------------------------- | ------------------------------------------------------------ |
378e41f4b71Sopenharmony_ci| Promise\<NotificationSlot\> | Promise used to return the result. |
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci**Example**
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci```ts
383e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_cilet slotType: Notification.SlotType = Notification.SlotType.SOCIAL_COMMUNICATION;
386e41f4b71Sopenharmony_ciNotification.getSlot(slotType).then((data) => {
387e41f4b71Sopenharmony_ci  console.info("getSlot success, data: " + JSON.stringify(data));
388e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
389e41f4b71Sopenharmony_ci  console.error(`getSlot failed, code is ${err}`);
390e41f4b71Sopenharmony_ci});
391e41f4b71Sopenharmony_ci```
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ci## Notification.getSlots
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_cigetSlots(callback: AsyncCallback\<Array\<NotificationSlot>>): void
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ciObtains all notification slots. This API uses an asynchronous callback to return the result.
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci**Parameters**
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci| Name    | Type                             | Mandatory | Description                |
404e41f4b71Sopenharmony_ci| -------- | --------------------------------- | ---- | -------------------- |
405e41f4b71Sopenharmony_ci| callback | AsyncCallback\<Array\<[NotificationSlot](#notificationslot)>> | Yes  | Callback used to return the result. |
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_ci**Example**
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ci```ts
410e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ci// getSlots callback
413e41f4b71Sopenharmony_cifunction getSlotsCallback(err: Base.BusinessError) {
414e41f4b71Sopenharmony_ci  if (err) {
415e41f4b71Sopenharmony_ci    console.info("getSlots failed " + JSON.stringify(err));
416e41f4b71Sopenharmony_ci  } else {
417e41f4b71Sopenharmony_ci    console.info("getSlots success");
418e41f4b71Sopenharmony_ci  }
419e41f4b71Sopenharmony_ci}
420e41f4b71Sopenharmony_ciNotification.getSlots(getSlotsCallback);
421e41f4b71Sopenharmony_ci```
422e41f4b71Sopenharmony_ci
423e41f4b71Sopenharmony_ci## Notification.getSlots
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_cigetSlots(): Promise\<Array\<NotificationSlot\>>
426e41f4b71Sopenharmony_ci
427e41f4b71Sopenharmony_ciObtains all notification slots of this application. This API uses a promise to return the result.
428e41f4b71Sopenharmony_ci
429e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
430e41f4b71Sopenharmony_ci
431e41f4b71Sopenharmony_ci**Return value**
432e41f4b71Sopenharmony_ci
433e41f4b71Sopenharmony_ci| Type                                                       | Description                                                        |
434e41f4b71Sopenharmony_ci| ----------------------------------------------------------- | ------------------------------------------------------------ |
435e41f4b71Sopenharmony_ci| Promise\<Array\<[NotificationSlot](#notificationslot)\>\> | Promise used to return the result. |
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ci**Example**
438e41f4b71Sopenharmony_ci
439e41f4b71Sopenharmony_ci```ts
440e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
441e41f4b71Sopenharmony_ci
442e41f4b71Sopenharmony_ciNotification.getSlots().then((data) => {
443e41f4b71Sopenharmony_ci  console.info("getSlots success, data: " + JSON.stringify(data));
444e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
445e41f4b71Sopenharmony_ci  console.error(`getSlots failed, code is ${err}`);
446e41f4b71Sopenharmony_ci});
447e41f4b71Sopenharmony_ci```
448e41f4b71Sopenharmony_ci
449e41f4b71Sopenharmony_ci## Notification.removeSlot
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ciremoveSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
452e41f4b71Sopenharmony_ci
453e41f4b71Sopenharmony_ciRemoves a notification slot of a specified type. This API uses an asynchronous callback to return the result.
454e41f4b71Sopenharmony_ci
455e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
456e41f4b71Sopenharmony_ci
457e41f4b71Sopenharmony_ci**Parameters**
458e41f4b71Sopenharmony_ci
459e41f4b71Sopenharmony_ci| Name    | Type                 | Mandatory | Description                                                       |
460e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | ----------------------------------------------------------- |
461e41f4b71Sopenharmony_ci| slotType | [SlotType](#slottype)              | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes. |
462e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result.                                       |
463e41f4b71Sopenharmony_ci
464e41f4b71Sopenharmony_ci**Example**
465e41f4b71Sopenharmony_ci
466e41f4b71Sopenharmony_ci```ts
467e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
468e41f4b71Sopenharmony_ci
469e41f4b71Sopenharmony_ci// removeSlot callback
470e41f4b71Sopenharmony_cilet removeSlotCallback = (err: Base.BusinessError) => {
471e41f4b71Sopenharmony_ci  if (err) {
472e41f4b71Sopenharmony_ci    console.info("removeSlot failed " + JSON.stringify(err));
473e41f4b71Sopenharmony_ci  } else {
474e41f4b71Sopenharmony_ci    console.info("removeSlot success");
475e41f4b71Sopenharmony_ci  }
476e41f4b71Sopenharmony_ci}
477e41f4b71Sopenharmony_cilet slotType: Notification.SlotType = Notification.SlotType.SOCIAL_COMMUNICATION;
478e41f4b71Sopenharmony_ciNotification.removeSlot(slotType, removeSlotCallback);
479e41f4b71Sopenharmony_ci```
480e41f4b71Sopenharmony_ci
481e41f4b71Sopenharmony_ci## Notification.removeSlot
482e41f4b71Sopenharmony_ci
483e41f4b71Sopenharmony_ciremoveSlot(slotType: SlotType): Promise\<void\>
484e41f4b71Sopenharmony_ci
485e41f4b71Sopenharmony_ciRemoves a notification slot of a specified type. This API uses a promise to return the result.
486e41f4b71Sopenharmony_ci
487e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
488e41f4b71Sopenharmony_ci
489e41f4b71Sopenharmony_ci**Parameters**
490e41f4b71Sopenharmony_ci
491e41f4b71Sopenharmony_ci| Name    | Type    | Mandatory | Description                                                       |
492e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ----------------------------------------------------------- |
493e41f4b71Sopenharmony_ci| slotType | [SlotType](#slottype) | Yes  | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes. |
494e41f4b71Sopenharmony_ci
495e41f4b71Sopenharmony_ci**Return value**
496e41f4b71Sopenharmony_ci
497e41f4b71Sopenharmony_ci| Type    | Description        | 
498e41f4b71Sopenharmony_ci| ------- |------------|
499e41f4b71Sopenharmony_ci| Promise\<void\> | Promise that returns no value. |  
500e41f4b71Sopenharmony_ci
501e41f4b71Sopenharmony_ci**Example**
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ci```ts
504e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_cilet slotType: Notification.SlotType = Notification.SlotType.SOCIAL_COMMUNICATION;
507e41f4b71Sopenharmony_ciNotification.removeSlot(slotType).then(() => {
508e41f4b71Sopenharmony_ci  console.info("removeSlot success");
509e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
510e41f4b71Sopenharmony_ci  console.error(`removeSlot failed, code is ${err}`);
511e41f4b71Sopenharmony_ci});
512e41f4b71Sopenharmony_ci```
513e41f4b71Sopenharmony_ci
514e41f4b71Sopenharmony_ci## Notification.removeAllSlots
515e41f4b71Sopenharmony_ci
516e41f4b71Sopenharmony_ciremoveAllSlots(callback: AsyncCallback\<void\>): void
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_ciRemoves all notification slots. This API uses an asynchronous callback to return the result.
519e41f4b71Sopenharmony_ci
520e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
521e41f4b71Sopenharmony_ci
522e41f4b71Sopenharmony_ci**Parameters**
523e41f4b71Sopenharmony_ci
524e41f4b71Sopenharmony_ci| Name    | Type                 | Mandatory | Description                |
525e41f4b71Sopenharmony_ci| -------- | --------------------- | ---- | -------------------- |
526e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. |
527e41f4b71Sopenharmony_ci
528e41f4b71Sopenharmony_ci**Example**
529e41f4b71Sopenharmony_ci
530e41f4b71Sopenharmony_ci```ts
531e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_cilet removeAllCallBack = (err: Base.BusinessError) => {
534e41f4b71Sopenharmony_ci  if (err) {
535e41f4b71Sopenharmony_ci    console.info("removeAllSlots failed " + JSON.stringify(err));
536e41f4b71Sopenharmony_ci  } else {
537e41f4b71Sopenharmony_ci    console.info("removeAllSlots success");
538e41f4b71Sopenharmony_ci  }
539e41f4b71Sopenharmony_ci}
540e41f4b71Sopenharmony_ciNotification.removeAllSlots(removeAllCallBack);
541e41f4b71Sopenharmony_ci```
542e41f4b71Sopenharmony_ci
543e41f4b71Sopenharmony_ci## Notification.removeAllSlots
544e41f4b71Sopenharmony_ci
545e41f4b71Sopenharmony_ciremoveAllSlots(): Promise\<void\>
546e41f4b71Sopenharmony_ci
547e41f4b71Sopenharmony_ciRemoves all notification slots. This API uses a promise to return the result.
548e41f4b71Sopenharmony_ci
549e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
550e41f4b71Sopenharmony_ci
551e41f4b71Sopenharmony_ci**Return value**
552e41f4b71Sopenharmony_ci
553e41f4b71Sopenharmony_ci| Type    | Description        | 
554e41f4b71Sopenharmony_ci| ------- |------------|
555e41f4b71Sopenharmony_ci| Promise\<void\> | Promise that returns no value. |  
556e41f4b71Sopenharmony_ci
557e41f4b71Sopenharmony_ci**Example**
558e41f4b71Sopenharmony_ci
559e41f4b71Sopenharmony_ci```ts
560e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
561e41f4b71Sopenharmony_ci
562e41f4b71Sopenharmony_ciNotification.removeAllSlots().then(() => {
563e41f4b71Sopenharmony_ci  console.info("removeAllSlots success");
564e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
565e41f4b71Sopenharmony_ci  console.error(`removeAllSlots failed, code is ${err}`);
566e41f4b71Sopenharmony_ci});
567e41f4b71Sopenharmony_ci```
568e41f4b71Sopenharmony_ci
569e41f4b71Sopenharmony_ci## Notification.getActiveNotificationCount
570e41f4b71Sopenharmony_ci
571e41f4b71Sopenharmony_cigetActiveNotificationCount(callback: AsyncCallback\<number\>): void
572e41f4b71Sopenharmony_ci
573e41f4b71Sopenharmony_ciObtains the number of active notifications of this application. This API uses an asynchronous callback to return the result.
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_ci**Parameters**
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_ci| Name    | Type                  | Mandatory | Description                  |
580e41f4b71Sopenharmony_ci| -------- | ---------------------- | ---- | ---------------------- |
581e41f4b71Sopenharmony_ci| callback | AsyncCallback\<number\> | Yes  | Callback used to return the result. |
582e41f4b71Sopenharmony_ci
583e41f4b71Sopenharmony_ci**Example**
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ci```ts
586e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
587e41f4b71Sopenharmony_ci
588e41f4b71Sopenharmony_cilet getActiveNotificationCountCallback = (err: Base.BusinessError, data: number) => {
589e41f4b71Sopenharmony_ci  if (err) {
590e41f4b71Sopenharmony_ci    console.info("getActiveNotificationCount failed " + JSON.stringify(err));
591e41f4b71Sopenharmony_ci  } else {
592e41f4b71Sopenharmony_ci    console.info("getActiveNotificationCount success");
593e41f4b71Sopenharmony_ci  }
594e41f4b71Sopenharmony_ci}
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ciNotification.getActiveNotificationCount(getActiveNotificationCountCallback);
597e41f4b71Sopenharmony_ci```
598e41f4b71Sopenharmony_ci
599e41f4b71Sopenharmony_ci## Notification.getActiveNotificationCount
600e41f4b71Sopenharmony_ci
601e41f4b71Sopenharmony_cigetActiveNotificationCount(): Promise\<number\>
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_ciObtains the number of active notifications of this application. This API uses a promise to return the result.
604e41f4b71Sopenharmony_ci
605e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ci**Return value**
608e41f4b71Sopenharmony_ci
609e41f4b71Sopenharmony_ci| Type             | Description                                       |
610e41f4b71Sopenharmony_ci| ----------------- | ------------------------------------------- |
611e41f4b71Sopenharmony_ci| Promise\<number\> | Promise used to return the result. |
612e41f4b71Sopenharmony_ci
613e41f4b71Sopenharmony_ci**Example**
614e41f4b71Sopenharmony_ci
615e41f4b71Sopenharmony_ci```ts
616e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
617e41f4b71Sopenharmony_ci
618e41f4b71Sopenharmony_ciNotification.getActiveNotificationCount().then((data: number) => {
619e41f4b71Sopenharmony_ci  console.info("getActiveNotificationCount success, data: " + JSON.stringify(data));
620e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
621e41f4b71Sopenharmony_ci  console.error(`getAllActiveNotifications failed, code is ${err}`);
622e41f4b71Sopenharmony_ci});
623e41f4b71Sopenharmony_ci```
624e41f4b71Sopenharmony_ci
625e41f4b71Sopenharmony_ci## Notification.getActiveNotifications
626e41f4b71Sopenharmony_ci
627e41f4b71Sopenharmony_cigetActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
628e41f4b71Sopenharmony_ci
629e41f4b71Sopenharmony_ciObtains active notifications of this application. This API uses an asynchronous callback to return the result.
630e41f4b71Sopenharmony_ci
631e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
632e41f4b71Sopenharmony_ci
633e41f4b71Sopenharmony_ci**Parameters**
634e41f4b71Sopenharmony_ci
635e41f4b71Sopenharmony_ci| Name    | Type                                                        | Mandatory | Description                          |
636e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------ |
637e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array\<[NotificationRequest](#notificationrequest)\>> | Yes  | Callback used to return the result. |
638e41f4b71Sopenharmony_ci
639e41f4b71Sopenharmony_ci**Example**
640e41f4b71Sopenharmony_ci
641e41f4b71Sopenharmony_ci```ts
642e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
643e41f4b71Sopenharmony_ciimport NotificationManager from '@ohos.notificationManager';
644e41f4b71Sopenharmony_ci
645e41f4b71Sopenharmony_cilet getActiveNotificationsCallback = (err: Base.BusinessError, data: NotificationManager.NotificationRequest[]) => {
646e41f4b71Sopenharmony_ci  if (err) {
647e41f4b71Sopenharmony_ci    console.info("getActiveNotifications failed " + JSON.stringify(err));
648e41f4b71Sopenharmony_ci  } else {
649e41f4b71Sopenharmony_ci    console.info("getActiveNotifications success");
650e41f4b71Sopenharmony_ci  }
651e41f4b71Sopenharmony_ci}
652e41f4b71Sopenharmony_ci
653e41f4b71Sopenharmony_ciNotification.getActiveNotifications(getActiveNotificationsCallback);
654e41f4b71Sopenharmony_ci```
655e41f4b71Sopenharmony_ci
656e41f4b71Sopenharmony_ci## Notification.getActiveNotifications
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_cigetActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_ciObtains active notifications of this application. This API uses a promise to return the result.
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
663e41f4b71Sopenharmony_ci
664e41f4b71Sopenharmony_ci**Return value**
665e41f4b71Sopenharmony_ci
666e41f4b71Sopenharmony_ci| Type                                                        | Description                                   |
667e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | --------------------------------------- |
668e41f4b71Sopenharmony_ci| Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> | Promise used to return the result. |
669e41f4b71Sopenharmony_ci
670e41f4b71Sopenharmony_ci**Example**
671e41f4b71Sopenharmony_ci
672e41f4b71Sopenharmony_ci```ts
673e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
674e41f4b71Sopenharmony_ciimport NotificationManager from '@ohos.notificationManager';
675e41f4b71Sopenharmony_ci
676e41f4b71Sopenharmony_ciNotification.getActiveNotifications().then((data: NotificationManager.NotificationRequest[]) => {
677e41f4b71Sopenharmony_ci  console.info("removeGroupByBundle success, data: " + JSON.stringify(data));
678e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
679e41f4b71Sopenharmony_ci  console.error(`removeGroupByBundle failed, code is ${err}`);
680e41f4b71Sopenharmony_ci});
681e41f4b71Sopenharmony_ci```
682e41f4b71Sopenharmony_ci
683e41f4b71Sopenharmony_ci## Notification.cancelGroup<sup>8+</sup>
684e41f4b71Sopenharmony_ci
685e41f4b71Sopenharmony_cicancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
686e41f4b71Sopenharmony_ci
687e41f4b71Sopenharmony_ciCancels notifications under a notification group of this application. This API uses an asynchronous callback to return the result.
688e41f4b71Sopenharmony_ci
689e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
690e41f4b71Sopenharmony_ci
691e41f4b71Sopenharmony_ci**Parameters**
692e41f4b71Sopenharmony_ci
693e41f4b71Sopenharmony_ci| Name     | Type                 | Mandatory | Description                        |
694e41f4b71Sopenharmony_ci| --------- | --------------------- | ---- | ---------------------------- |
695e41f4b71Sopenharmony_ci| groupName | string                | Yes  | Name of the notification group, which is specified through [NotificationRequest](#notificationrequest) when the notification is published. |
696e41f4b71Sopenharmony_ci| callback  | AsyncCallback\<void\> | Yes  | Callback used to return the result. |
697e41f4b71Sopenharmony_ci
698e41f4b71Sopenharmony_ci**Example**
699e41f4b71Sopenharmony_ci
700e41f4b71Sopenharmony_ci```ts
701e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
702e41f4b71Sopenharmony_ci
703e41f4b71Sopenharmony_cilet cancelGroupCallback = (err: Base.BusinessError) => {
704e41f4b71Sopenharmony_ci  if (err) {
705e41f4b71Sopenharmony_ci    console.info("cancelGroup failed " + JSON.stringify(err));
706e41f4b71Sopenharmony_ci  } else {
707e41f4b71Sopenharmony_ci    console.info("cancelGroup success");
708e41f4b71Sopenharmony_ci  }
709e41f4b71Sopenharmony_ci}
710e41f4b71Sopenharmony_ci
711e41f4b71Sopenharmony_cilet groupName: string = "GroupName";
712e41f4b71Sopenharmony_ci
713e41f4b71Sopenharmony_ciNotification.cancelGroup(groupName, cancelGroupCallback);
714e41f4b71Sopenharmony_ci```
715e41f4b71Sopenharmony_ci
716e41f4b71Sopenharmony_ci## Notification.cancelGroup<sup>8+</sup>
717e41f4b71Sopenharmony_ci
718e41f4b71Sopenharmony_cicancelGroup(groupName: string): Promise\<void\>
719e41f4b71Sopenharmony_ci
720e41f4b71Sopenharmony_ciCancels notifications under a notification group of this application. This API uses a promise to return the result.
721e41f4b71Sopenharmony_ci
722e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
723e41f4b71Sopenharmony_ci
724e41f4b71Sopenharmony_ci**Parameters**
725e41f4b71Sopenharmony_ci
726e41f4b71Sopenharmony_ci| Name     | Type  | Mandatory | Description          |
727e41f4b71Sopenharmony_ci| --------- | ------ | ---- | -------------- |
728e41f4b71Sopenharmony_ci| groupName | string | Yes  | Name of the notification group. |
729e41f4b71Sopenharmony_ci
730e41f4b71Sopenharmony_ci**Return value**
731e41f4b71Sopenharmony_ci
732e41f4b71Sopenharmony_ci| Type    | Description        | 
733e41f4b71Sopenharmony_ci| ------- |------------|
734e41f4b71Sopenharmony_ci| Promise\<void\> | Promise that returns no value. |  
735e41f4b71Sopenharmony_ci
736e41f4b71Sopenharmony_ci**Example**
737e41f4b71Sopenharmony_ci
738e41f4b71Sopenharmony_ci```ts
739e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
740e41f4b71Sopenharmony_ci
741e41f4b71Sopenharmony_cilet groupName: string = "GroupName";
742e41f4b71Sopenharmony_ciNotification.cancelGroup(groupName).then(() => {
743e41f4b71Sopenharmony_ci	console.info("cancelGroup success");
744e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
745e41f4b71Sopenharmony_ci  console.error(`cancelGroup failed, code is ${err}`);
746e41f4b71Sopenharmony_ci});
747e41f4b71Sopenharmony_ci```
748e41f4b71Sopenharmony_ci
749e41f4b71Sopenharmony_ci## Notification.isSupportTemplate<sup>8+</sup>
750e41f4b71Sopenharmony_ci
751e41f4b71Sopenharmony_ciisSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): void
752e41f4b71Sopenharmony_ci
753e41f4b71Sopenharmony_ciChecks whether a specified template exists. This API uses an asynchronous callback to return the result.
754e41f4b71Sopenharmony_ci
755e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
756e41f4b71Sopenharmony_ci
757e41f4b71Sopenharmony_ci**Parameters**
758e41f4b71Sopenharmony_ci
759e41f4b71Sopenharmony_ci| Name      | Type                    | Mandatory | Description                      |
760e41f4b71Sopenharmony_ci| ------------ | ------------------------ | ---- | -------------------------- |
761e41f4b71Sopenharmony_ci| templateName | string                   | Yes  | Template name.                  |
762e41f4b71Sopenharmony_ci| callback     | AsyncCallback\<boolean\> | Yes  | Callback used to return the result. |
763e41f4b71Sopenharmony_ci
764e41f4b71Sopenharmony_ci**Example**
765e41f4b71Sopenharmony_ci
766e41f4b71Sopenharmony_ci```ts
767e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
768e41f4b71Sopenharmony_ci
769e41f4b71Sopenharmony_cilet templateName: string = 'process';
770e41f4b71Sopenharmony_cifunction isSupportTemplateCallback(err: Base.BusinessError, data: boolean) {
771e41f4b71Sopenharmony_ci  if (err) {
772e41f4b71Sopenharmony_ci    console.info("isSupportTemplate failed " + JSON.stringify(err));
773e41f4b71Sopenharmony_ci  } else {
774e41f4b71Sopenharmony_ci    console.info("isSupportTemplate success");
775e41f4b71Sopenharmony_ci  }
776e41f4b71Sopenharmony_ci}
777e41f4b71Sopenharmony_ci
778e41f4b71Sopenharmony_ciNotification.isSupportTemplate(templateName, isSupportTemplateCallback);
779e41f4b71Sopenharmony_ci```
780e41f4b71Sopenharmony_ci
781e41f4b71Sopenharmony_ci## Notification.isSupportTemplate<sup>8+</sup>
782e41f4b71Sopenharmony_ci
783e41f4b71Sopenharmony_ciisSupportTemplate(templateName: string): Promise\<boolean\>
784e41f4b71Sopenharmony_ci
785e41f4b71Sopenharmony_ciChecks whether a specified template exists. This API uses a promise to return the result.
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
788e41f4b71Sopenharmony_ci
789e41f4b71Sopenharmony_ci**Parameters**
790e41f4b71Sopenharmony_ci
791e41f4b71Sopenharmony_ci| Name      | Type  | Mandatory | Description    |
792e41f4b71Sopenharmony_ci| ------------ | ------ | ---- | -------- |
793e41f4b71Sopenharmony_ci| templateName | string | Yes  | Template name. |
794e41f4b71Sopenharmony_ci
795e41f4b71Sopenharmony_ci**Return value**
796e41f4b71Sopenharmony_ci
797e41f4b71Sopenharmony_ci| Type              | Description           |
798e41f4b71Sopenharmony_ci| ------------------ | --------------- |
799e41f4b71Sopenharmony_ci| Promise\<boolean\> | Promise used to return the result. |
800e41f4b71Sopenharmony_ci
801e41f4b71Sopenharmony_ci**Example**
802e41f4b71Sopenharmony_ci
803e41f4b71Sopenharmony_ci```ts
804e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
805e41f4b71Sopenharmony_ci
806e41f4b71Sopenharmony_cilet templateName: string = 'process';
807e41f4b71Sopenharmony_ciNotification.isSupportTemplate(templateName).then((data: boolean) => {
808e41f4b71Sopenharmony_ci  console.info("isSupportTemplate success, data: " + JSON.stringify(data));
809e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
810e41f4b71Sopenharmony_ci  console.error(`isSupportTemplate failed, code is ${err}`);
811e41f4b71Sopenharmony_ci});
812e41f4b71Sopenharmony_ci```
813e41f4b71Sopenharmony_ci
814e41f4b71Sopenharmony_ci## Notification.requestEnableNotification<sup>8+</sup>
815e41f4b71Sopenharmony_ci
816e41f4b71Sopenharmony_cirequestEnableNotification(callback: AsyncCallback\<void\>): void
817e41f4b71Sopenharmony_ci
818e41f4b71Sopenharmony_ciRequests notification to be enabled for this application. This API uses an asynchronous callback to return the result.
819e41f4b71Sopenharmony_ci
820e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_ci**Parameters**
823e41f4b71Sopenharmony_ci
824e41f4b71Sopenharmony_ci| Name  | Type                    | Mandatory | Description                      |
825e41f4b71Sopenharmony_ci| -------- | ------------------------ | ---- | -------------------------- |
826e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void\> | Yes  | Callback used to return the result. |
827e41f4b71Sopenharmony_ci
828e41f4b71Sopenharmony_ci**Example**
829e41f4b71Sopenharmony_ci
830e41f4b71Sopenharmony_ci```ts
831e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
832e41f4b71Sopenharmony_ci
833e41f4b71Sopenharmony_cilet requestEnableNotificationCallback = (err: Base.BusinessError) => {
834e41f4b71Sopenharmony_ci  if (err) {
835e41f4b71Sopenharmony_ci    console.info("requestEnableNotification failed " + JSON.stringify(err));
836e41f4b71Sopenharmony_ci  } else {
837e41f4b71Sopenharmony_ci    console.info("requestEnableNotification success");
838e41f4b71Sopenharmony_ci  }
839e41f4b71Sopenharmony_ci};
840e41f4b71Sopenharmony_ci
841e41f4b71Sopenharmony_ciNotification.requestEnableNotification(requestEnableNotificationCallback);
842e41f4b71Sopenharmony_ci```
843e41f4b71Sopenharmony_ci
844e41f4b71Sopenharmony_ci## Notification.requestEnableNotification<sup>8+</sup>
845e41f4b71Sopenharmony_ci
846e41f4b71Sopenharmony_cirequestEnableNotification(): Promise\<void\>
847e41f4b71Sopenharmony_ci
848e41f4b71Sopenharmony_ciRequests notification to be enabled for this application. This API uses a promise to return the result.
849e41f4b71Sopenharmony_ci
850e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
851e41f4b71Sopenharmony_ci
852e41f4b71Sopenharmony_ci**Return value**
853e41f4b71Sopenharmony_ci
854e41f4b71Sopenharmony_ci| Type    | Description        | 
855e41f4b71Sopenharmony_ci| ------- |------------|
856e41f4b71Sopenharmony_ci| Promise\<void\> | Promise that returns no value. |  
857e41f4b71Sopenharmony_ci
858e41f4b71Sopenharmony_ci**Example**
859e41f4b71Sopenharmony_ci
860e41f4b71Sopenharmony_ci```ts
861e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
862e41f4b71Sopenharmony_ci
863e41f4b71Sopenharmony_ciNotification.requestEnableNotification().then(() => {
864e41f4b71Sopenharmony_ci  console.info("requestEnableNotification success");
865e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
866e41f4b71Sopenharmony_ci  console.error(`requestEnableNotification failed, code is ${err}`);
867e41f4b71Sopenharmony_ci});
868e41f4b71Sopenharmony_ci```
869e41f4b71Sopenharmony_ci
870e41f4b71Sopenharmony_ci## Notification.isDistributedEnabled<sup>8+</sup>
871e41f4b71Sopenharmony_ci
872e41f4b71Sopenharmony_ciisDistributedEnabled(callback: AsyncCallback\<boolean>): void
873e41f4b71Sopenharmony_ci
874e41f4b71Sopenharmony_ciChecks whether this device supports distributed notifications. This API uses an asynchronous callback to return the result.
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_ci**Parameters**
879e41f4b71Sopenharmony_ci
880e41f4b71Sopenharmony_ci| Name  | Type                    | Mandatory | Description                      |
881e41f4b71Sopenharmony_ci| -------- | ------------------------ | ---- | -------------------------- |
882e41f4b71Sopenharmony_ci| callback | AsyncCallback\<boolean\> | Yes  | Callback used to return the result. |
883e41f4b71Sopenharmony_ci
884e41f4b71Sopenharmony_ci**Example**
885e41f4b71Sopenharmony_ci
886e41f4b71Sopenharmony_ci```ts
887e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
888e41f4b71Sopenharmony_ci
889e41f4b71Sopenharmony_cilet isDistributedEnabledCallback = (err: Base.BusinessError, data: boolean) => {
890e41f4b71Sopenharmony_ci  if (err) {
891e41f4b71Sopenharmony_ci    console.info("isDistributedEnabled failed " + JSON.stringify(err));
892e41f4b71Sopenharmony_ci  } else {
893e41f4b71Sopenharmony_ci    console.info("isDistributedEnabled success " + JSON.stringify(data));
894e41f4b71Sopenharmony_ci  }
895e41f4b71Sopenharmony_ci};
896e41f4b71Sopenharmony_ci
897e41f4b71Sopenharmony_ciNotification.isDistributedEnabled(isDistributedEnabledCallback);
898e41f4b71Sopenharmony_ci```
899e41f4b71Sopenharmony_ci
900e41f4b71Sopenharmony_ci## Notification.isDistributedEnabled<sup>8+</sup>
901e41f4b71Sopenharmony_ci
902e41f4b71Sopenharmony_ciisDistributedEnabled(): Promise\<boolean>
903e41f4b71Sopenharmony_ci
904e41f4b71Sopenharmony_ciChecks whether this device supports distributed notifications. This API uses a promise to return the result.
905e41f4b71Sopenharmony_ci
906e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
907e41f4b71Sopenharmony_ci
908e41f4b71Sopenharmony_ci**Return value**
909e41f4b71Sopenharmony_ci
910e41f4b71Sopenharmony_ci| Type              | Description                                         |
911e41f4b71Sopenharmony_ci| ------------------ | --------------------------------------------- |
912e41f4b71Sopenharmony_ci| Promise\<boolean\> | Promise used to return the result. |
913e41f4b71Sopenharmony_ci
914e41f4b71Sopenharmony_ci**Example**
915e41f4b71Sopenharmony_ci
916e41f4b71Sopenharmony_ci```ts
917e41f4b71Sopenharmony_ciimport Base from '@ohos.base';
918e41f4b71Sopenharmony_ci
919e41f4b71Sopenharmony_ciNotification.isDistributedEnabled().then((data: boolean) => {
920e41f4b71Sopenharmony_ci    console.info("isDistributedEnabled success, data: " + JSON.stringify(data));
921e41f4b71Sopenharmony_ci}).catch((err: Base.BusinessError) => {
922e41f4b71Sopenharmony_ci  console.error(`isDistributedEnabled failed, code is ${err}`);
923e41f4b71Sopenharmony_ci});
924e41f4b71Sopenharmony_ci```
925e41f4b71Sopenharmony_ci
926e41f4b71Sopenharmony_ci## ContentType
927e41f4b71Sopenharmony_ci
928e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
929e41f4b71Sopenharmony_ci
930e41f4b71Sopenharmony_ci| Name                             | Value         | Description              |
931e41f4b71Sopenharmony_ci| --------------------------------- | ----------- | ------------------ |
932e41f4b71Sopenharmony_ci| NOTIFICATION_CONTENT_BASIC_TEXT   | NOTIFICATION_CONTENT_BASIC_TEXT | Normal text notification.    |
933e41f4b71Sopenharmony_ci| NOTIFICATION_CONTENT_LONG_TEXT    | NOTIFICATION_CONTENT_LONG_TEXT | Long text notification.  |
934e41f4b71Sopenharmony_ci| NOTIFICATION_CONTENT_PICTURE      | NOTIFICATION_CONTENT_PICTURE | Picture-attached notification.    |
935e41f4b71Sopenharmony_ci| NOTIFICATION_CONTENT_CONVERSATION | NOTIFICATION_CONTENT_CONVERSATION | Conversation notification.    |
936e41f4b71Sopenharmony_ci| NOTIFICATION_CONTENT_MULTILINE    | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification. |
937e41f4b71Sopenharmony_ci
938e41f4b71Sopenharmony_ci## SlotLevel
939e41f4b71Sopenharmony_ci
940e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
941e41f4b71Sopenharmony_ci
942e41f4b71Sopenharmony_ci| Name                             | Value         | Description              |
943e41f4b71Sopenharmony_ci| --------------------------------- | ----------- | ------------------ |
944e41f4b71Sopenharmony_ci| LEVEL_NONE                        | 0           | The notification function is disabled.    |
945e41f4b71Sopenharmony_ci| LEVEL_MIN                         | 1           | The notification function is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone. |
946e41f4b71Sopenharmony_ci| LEVEL_LOW                         | 2           | The notification function is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone. |
947e41f4b71Sopenharmony_ci| LEVEL_DEFAULT                     | 3           | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone but no banner. |
948e41f4b71Sopenharmony_ci| LEVEL_HIGH                        | 4           | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone and banner. |
949e41f4b71Sopenharmony_ci
950e41f4b71Sopenharmony_ci
951e41f4b71Sopenharmony_ci## BundleOption<sup>deprecated</sup>
952e41f4b71Sopenharmony_ci
953e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
954e41f4b71Sopenharmony_ci
955e41f4b71Sopenharmony_ci> **NOTE**
956e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [notificationManager.BundleOption](js-apis-inner-notification-notificationCommonDef.md#bundleoption).
957e41f4b71Sopenharmony_ci
958e41f4b71Sopenharmony_ci| Name  | Type  | Mandatory | Description  |
959e41f4b71Sopenharmony_ci| ------ | ------ | --- |  ------ |
960e41f4b71Sopenharmony_ci| bundle | string | Yes | Bundle information of the application. |
961e41f4b71Sopenharmony_ci| uid    | number | No | User ID. The default value is 0. |
962e41f4b71Sopenharmony_ci
963e41f4b71Sopenharmony_ci## NotificationKey<sup>deprecated</sup>
964e41f4b71Sopenharmony_ci
965e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
966e41f4b71Sopenharmony_ci
967e41f4b71Sopenharmony_ci> **NOTE**
968e41f4b71Sopenharmony_ci> This API is supported since API version 7 and deprecated since API version 9. <!--Del-->You are advised to use [notificationManager.NotificationKey](js-apis-notificationSubscribe-sys.md#notificationkey).<!--DelEnd-->
969e41f4b71Sopenharmony_ci
970e41f4b71Sopenharmony_ci| Name | Type  | Readable | Writable | Description    |
971e41f4b71Sopenharmony_ci| ----- | ------ | ---- | --- | -------- |
972e41f4b71Sopenharmony_ci| id    | number | Yes | Yes | Notification ID.  |
973e41f4b71Sopenharmony_ci| label | string | Yes | Yes | Notification label. |
974e41f4b71Sopenharmony_ci
975e41f4b71Sopenharmony_ci
976e41f4b71Sopenharmony_ci## SlotType
977e41f4b71Sopenharmony_ci
978e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
979e41f4b71Sopenharmony_ci
980e41f4b71Sopenharmony_ci| Name                | Value      | Description      |
981e41f4b71Sopenharmony_ci| -------------------- | -------- | ---------- |
982e41f4b71Sopenharmony_ci| UNKNOWN_TYPE         | 0 | Unknown type. |
983e41f4b71Sopenharmony_ci| SOCIAL_COMMUNICATION | 1 | Notification slot for social communication. |
984e41f4b71Sopenharmony_ci| SERVICE_INFORMATION  | 2 | Notification slot for service information. |
985e41f4b71Sopenharmony_ci| CONTENT_INFORMATION  | 3 | Notification slot for content consultation. |
986e41f4b71Sopenharmony_ci| OTHER_TYPES          | 0xFFFF | Notification slot for other purposes. |
987e41f4b71Sopenharmony_ci
988e41f4b71Sopenharmony_ci
989e41f4b71Sopenharmony_ci## NotificationActionButton
990e41f4b71Sopenharmony_ci
991e41f4b71Sopenharmony_ciDescribes the button displayed in the notification.
992e41f4b71Sopenharmony_ci
993e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
994e41f4b71Sopenharmony_ci
995e41f4b71Sopenharmony_ci| Name     | Type                                           | Readable | Writable | Description                     |
996e41f4b71Sopenharmony_ci| --------- | ----------------------------------------------- | --- | ---- | ------------------------- |
997e41f4b71Sopenharmony_ci| title     | string                                          | Yes | Yes | Button title.                 |
998e41f4b71Sopenharmony_ci| wantAgent | [WantAgent](../apis-ability-kit/js-apis-wantAgent.md)   | Yes | Yes | **WantAgent** of the button. |
999e41f4b71Sopenharmony_ci| extras    | { [key: string]: any }                          | Yes | Yes | Extra information of the button.             |
1000e41f4b71Sopenharmony_ci| userInput<sup>8+</sup> | [NotificationUserInput](#notificationuserinput8) | Yes | Yes | User input object.         |
1001e41f4b71Sopenharmony_ci
1002e41f4b71Sopenharmony_ci
1003e41f4b71Sopenharmony_ci## NotificationBasicContent
1004e41f4b71Sopenharmony_ci
1005e41f4b71Sopenharmony_ciDescribes the normal text notification.
1006e41f4b71Sopenharmony_ci
1007e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
1008e41f4b71Sopenharmony_ci
1009e41f4b71Sopenharmony_ci| Name          | Type  | Readable | Writable | Description                              |
1010e41f4b71Sopenharmony_ci| -------------- | ------ | ---- | ---- | ---------------------------------- |
1011e41f4b71Sopenharmony_ci| title          | string | Yes  | Yes  | Notification title.                        |
1012e41f4b71Sopenharmony_ci| text           | string | Yes  | Yes  | Notification content.                        |
1013e41f4b71Sopenharmony_ci| additionalText | string | Yes  | Yes  | Additional information of the notification. |
1014e41f4b71Sopenharmony_ci
1015e41f4b71Sopenharmony_ci
1016e41f4b71Sopenharmony_ci## NotificationLongTextContent
1017e41f4b71Sopenharmony_ci
1018e41f4b71Sopenharmony_ciDescribes the long text notification.
1019e41f4b71Sopenharmony_ci
1020e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
1021e41f4b71Sopenharmony_ci
1022e41f4b71Sopenharmony_ci| Name          | Type  | Readable | Writable | Description                            |
1023e41f4b71Sopenharmony_ci| -------------- | ------ | ---- | --- | -------------------------------- |
1024e41f4b71Sopenharmony_ci| title          | string | Yes | Yes | Notification title.                        |
1025e41f4b71Sopenharmony_ci| text           | string | Yes | Yes | Notification content.                        |
1026e41f4b71Sopenharmony_ci| additionalText | string | Yes | Yes | Additional information of the notification. |
1027e41f4b71Sopenharmony_ci| longText       | string | Yes | Yes | Long text of the notification.                    |
1028e41f4b71Sopenharmony_ci| briefText      | string | Yes | Yes | Brief text of the notification. |
1029e41f4b71Sopenharmony_ci| expandedTitle  | string | Yes | Yes | Title of the notification in the expanded state.                |
1030e41f4b71Sopenharmony_ci
1031e41f4b71Sopenharmony_ci
1032e41f4b71Sopenharmony_ci## NotificationMultiLineContent
1033e41f4b71Sopenharmony_ci
1034e41f4b71Sopenharmony_ciDescribes the multi-line text notification.
1035e41f4b71Sopenharmony_ci
1036e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
1037e41f4b71Sopenharmony_ci
1038e41f4b71Sopenharmony_ci| Name          | Type           | Readable | Writable | Description                            |
1039e41f4b71Sopenharmony_ci| -------------- | --------------- | --- | --- | -------------------------------- |
1040e41f4b71Sopenharmony_ci| title          | string          | Yes | Yes | Notification title.                        |
1041e41f4b71Sopenharmony_ci| text           | string          | Yes | Yes | Notification content.                        |
1042e41f4b71Sopenharmony_ci| additionalText | string          | Yes | Yes | Additional information of the notification. |
1043e41f4b71Sopenharmony_ci| briefText      | string          | Yes | Yes | Brief text of the notification. |
1044e41f4b71Sopenharmony_ci| longTitle      | string          | Yes | Yes | Title of the notification in the expanded state.                |
1045e41f4b71Sopenharmony_ci| lines          | Array\<string\> | Yes | Yes | Multi-line text of the notification.                  |
1046e41f4b71Sopenharmony_ci
1047e41f4b71Sopenharmony_ci
1048e41f4b71Sopenharmony_ci## NotificationPictureContent
1049e41f4b71Sopenharmony_ci
1050e41f4b71Sopenharmony_ciDescribes the picture-attached notification.
1051e41f4b71Sopenharmony_ci
1052e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
1053e41f4b71Sopenharmony_ci
1054e41f4b71Sopenharmony_ci| Name          | Type          | Readable | Writable | Description                            |
1055e41f4b71Sopenharmony_ci| -------------- | -------------- | ---- | --- | -------------------------------- |
1056e41f4b71Sopenharmony_ci| title          | string         | Yes | Yes | Notification title.                        |
1057e41f4b71Sopenharmony_ci| text           | string         | Yes | Yes | Notification content.                        |
1058e41f4b71Sopenharmony_ci| additionalText | string         | Yes | Yes | Additional information of the notification. |
1059e41f4b71Sopenharmony_ci| briefText      | string         | Yes | Yes | Brief text of the notification. |
1060e41f4b71Sopenharmony_ci| expandedTitle  | string         | Yes | Yes | Title of the notification in the expanded state.                |
1061e41f4b71Sopenharmony_ci| picture        | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | Yes | Yes | Picture attached to the notification.                  |
1062e41f4b71Sopenharmony_ci
1063e41f4b71Sopenharmony_ci
1064e41f4b71Sopenharmony_ci## NotificationContent
1065e41f4b71Sopenharmony_ci
1066e41f4b71Sopenharmony_ciDescribes the notification content.
1067e41f4b71Sopenharmony_ci
1068e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
1069e41f4b71Sopenharmony_ci
1070e41f4b71Sopenharmony_ci| Name       | Type                                                        | Readable | Writable | Description              |
1071e41f4b71Sopenharmony_ci| ----------- | ------------------------------------------------------------ | ---- | --- | ------------------ |
1072e41f4b71Sopenharmony_ci| contentType | [notification.ContentType](#contenttype)                                  | Yes | Yes | Notification content type.      |
1073e41f4b71Sopenharmony_ci| normal      | [NotificationBasicContent](#notificationbasiccontent)        | Yes | Yes | Normal text.  |
1074e41f4b71Sopenharmony_ci| longText    | [NotificationLongTextContent](#notificationlongtextcontent)  | Yes | Yes | Long text. |
1075e41f4b71Sopenharmony_ci| multiLine   | [NotificationMultiLineContent](#notificationmultilinecontent) | Yes | Yes | Multi-line text.  |
1076e41f4b71Sopenharmony_ci| picture     | [NotificationPictureContent](#notificationpicturecontent)    | Yes | Yes | Picture-attached.  |
1077e41f4b71Sopenharmony_ci
1078e41f4b71Sopenharmony_ci## NotificationRequest
1079e41f4b71Sopenharmony_ci
1080e41f4b71Sopenharmony_ciDescribes the notification request.
1081e41f4b71Sopenharmony_ci
1082e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
1083e41f4b71Sopenharmony_ci
1084e41f4b71Sopenharmony_ci| Name                 | Type                                         | Readable | Writable | Description                      |
1085e41f4b71Sopenharmony_ci| --------------------- | --------------------------------------------- | ---- | --- | -------------------------- |
1086e41f4b71Sopenharmony_ci| content               | [NotificationContent](#notificationcontent)   | Yes | Yes | Notification content.                  |
1087e41f4b71Sopenharmony_ci| id                    | number                                        | Yes | Yes | Notification ID.                    |
1088e41f4b71Sopenharmony_ci| slotType              | [notification.SlotType](#slottype)                         | Yes | Yes | Slot type.                  |
1089e41f4b71Sopenharmony_ci| isOngoing             | boolean                                       | Yes | Yes | Whether the notification is an ongoing notification.            |
1090e41f4b71Sopenharmony_ci| isUnremovable         | boolean                                       | Yes | Yes | Whether the notification can be removed.                |
1091e41f4b71Sopenharmony_ci| deliveryTime          | number                                        | Yes | Yes | Time when the notification is sent.              |
1092e41f4b71Sopenharmony_ci| tapDismissed          | boolean                                       | Yes | Yes | Whether the notification is automatically cleared.          |
1093e41f4b71Sopenharmony_ci| autoDeletedTime       | number                                        | Yes | Yes | Time when the notification is automatically cleared.            |
1094e41f4b71Sopenharmony_ci| wantAgent             | [WantAgent](../apis-ability-kit/js-apis-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected after being clicked.  |
1095e41f4b71Sopenharmony_ci| extraInfo             | {[key: string]: any}                          | Yes | Yes | Extended parameters.                  |
1096e41f4b71Sopenharmony_ci| color                 | number                                        | Yes | Yes | Background color of the notification. Not supported currently. |
1097e41f4b71Sopenharmony_ci| colorEnabled          | boolean                                       | Yes | Yes | Whether the notification background color is enabled. Not supported currently. |
1098e41f4b71Sopenharmony_ci| isAlertOnce           | boolean                                       | Yes | Yes | Whether the notification triggers an alert only once. |
1099e41f4b71Sopenharmony_ci| isStopwatch           | boolean                                       | Yes | Yes | Whether to display the stopwatch.          |
1100e41f4b71Sopenharmony_ci| isCountDown           | boolean                                       | Yes | Yes | Whether to display the countdown time.        |
1101e41f4b71Sopenharmony_ci| isFloatingIcon        | boolean                                       | Yes | Yes | Whether the notification is displayed as a floating icon in the status bar.        |
1102e41f4b71Sopenharmony_ci| label                 | string                                        | Yes | Yes | Notification label.                  |
1103e41f4b71Sopenharmony_ci| badgeIconStyle        | number                                        | Yes | Yes | Notification badge type.              |
1104e41f4b71Sopenharmony_ci| showDeliveryTime      | boolean                                       | Yes | Yes | Whether to display the time when the notification is delivered.          |
1105e41f4b71Sopenharmony_ci| actionButtons         | Array\<[NotificationActionButton](#notificationactionbutton)\>             | Yes | Yes | Buttons in the notification. Up to two buttons are allowed.    |
1106e41f4b71Sopenharmony_ci| smallIcon             | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | Yes | Yes | Small notification icon. This field is optional, and the icon size cannot exceed 30 KB. |
1107e41f4b71Sopenharmony_ci| largeIcon             | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | Yes | Yes | Large notification icon. This field is optional, and the icon size cannot exceed 30 KB. |
1108e41f4b71Sopenharmony_ci| creatorBundleName     | string                                        | Yes | No | Name of the bundle that creates the notification.            |
1109e41f4b71Sopenharmony_ci| creatorUid            | number                                        | Yes | No | UID used for creating the notification.             |
1110e41f4b71Sopenharmony_ci| creatorPid            | number                                        | Yes | No | PID used for creating the notification.             |
1111e41f4b71Sopenharmony_ci| creatorUserId<sup>8+</sup>| number                                    | Yes | No | ID of the user who creates the notification.          |
1112e41f4b71Sopenharmony_ci| hashCode              | string                                        | Yes | No | Unique ID of the notification.              |
1113e41f4b71Sopenharmony_ci| groupName<sup>8+</sup>| string                                        | Yes | Yes | Notification group name.                |
1114e41f4b71Sopenharmony_ci| template<sup>8+</sup> | [NotificationTemplate](#notificationtemplate8) | Yes | Yes | Notification template.                  |
1115e41f4b71Sopenharmony_ci| distributedOption<sup>8+</sup>   | [DistributedOptions](#distributedoptions8)                 | Yes | Yes | Distributed notification options.         |
1116e41f4b71Sopenharmony_ci| notificationFlags<sup>8+</sup> | [NotificationFlags](./js-apis-inner-notification-notificationFlags.md)                    | Yes | No | Notification flags.         |
1117e41f4b71Sopenharmony_ci| removalWantAgent<sup>9+</sup> | [WantAgent](../apis-ability-kit/js-apis-wantAgent.md) | Yes | Yes | **WantAgent** instance to which the notification will be redirected when it is removed.         |
1118e41f4b71Sopenharmony_ci| badgeNumber<sup>9+</sup> | number                    | Yes | Yes | Number of notifications displayed on the application icon.         |
1119e41f4b71Sopenharmony_ci
1120e41f4b71Sopenharmony_ci## DistributedOptions<sup>8+</sup>
1121e41f4b71Sopenharmony_ci
1122e41f4b71Sopenharmony_ciDescribes distributed notifications options.
1123e41f4b71Sopenharmony_ci
1124e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
1125e41f4b71Sopenharmony_ci
1126e41f4b71Sopenharmony_ci| Name                  | Type           | Readable | Writable | Description                              |
1127e41f4b71Sopenharmony_ci| ---------------------- | -------------- | ---- | ---- | ---------------------------------- |
1128e41f4b71Sopenharmony_ci| isDistributed          | boolean        | Yes  | Yes  | Whether the notification is a distributed notification.                 |
1129e41f4b71Sopenharmony_ci| supportDisplayDevices  | Array\<string> | Yes  | Yes  | List of the devices to which the notification can be synchronized.        |
1130e41f4b71Sopenharmony_ci| supportOperateDevices  | Array\<string> | Yes  | Yes  | List of the devices on which the notification can be opened.             |
1131e41f4b71Sopenharmony_ci
1132e41f4b71Sopenharmony_ci
1133e41f4b71Sopenharmony_ci## NotificationSlot
1134e41f4b71Sopenharmony_ci
1135e41f4b71Sopenharmony_ciDescribes the notification slot.
1136e41f4b71Sopenharmony_ci
1137e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
1138e41f4b71Sopenharmony_ci
1139e41f4b71Sopenharmony_ci| Name                | Type                 | Readable | Writable | Description                    |
1140e41f4b71Sopenharmony_ci| -------------------- | --------------------- | ---- | --- |------------------------|
1141e41f4b71Sopenharmony_ci| type                 | [notification.SlotType](#slottype) | Yes | Yes | Slot type.                 |
1142e41f4b71Sopenharmony_ci| level                | [notification.SlotLevel](#slotlevel)                | Yes | Yes | Notification level. If this parameter is not set, the default value is used based on the notification slot type. |
1143e41f4b71Sopenharmony_ci| desc                 | string                | Yes | Yes | Notification slot description.             |
1144e41f4b71Sopenharmony_ci| badgeFlag            | boolean               | Yes | Yes | Whether to display the badge.               |
1145e41f4b71Sopenharmony_ci| bypassDnd            | boolean               | Yes | Yes | Whether to bypass DND mode in the system.      |
1146e41f4b71Sopenharmony_ci| lockscreenVisibility | number                | Yes | Yes | Mode for displaying the notification on the lock screen.        |
1147e41f4b71Sopenharmony_ci| vibrationEnabled     | boolean               | Yes | Yes | Whether vibration is enabled for the notification.                |
1148e41f4b71Sopenharmony_ci| sound                | string                | Yes | Yes | Notification alert tone.                |
1149e41f4b71Sopenharmony_ci| lightEnabled         | boolean               | Yes | Yes | Whether the indicator blinks for the notification.                 |
1150e41f4b71Sopenharmony_ci| lightColor           | number                | Yes | Yes | Indicator color of the notification.                |
1151e41f4b71Sopenharmony_ci| vibrationValues      | Array\<number\>       | Yes | Yes | Vibration mode of the notification.               |
1152e41f4b71Sopenharmony_ci| enabled<sup>9+</sup> | boolean               | Yes | No | Whether the notification slot is enabled.          |
1153e41f4b71Sopenharmony_ci
1154e41f4b71Sopenharmony_ci## NotificationTemplate<sup>8+</sup>
1155e41f4b71Sopenharmony_ci
1156e41f4b71Sopenharmony_ciDescribes the notification template.
1157e41f4b71Sopenharmony_ci
1158e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
1159e41f4b71Sopenharmony_ci
1160e41f4b71Sopenharmony_ci| Name | Type                   | Readable | Writable | Description      |
1161e41f4b71Sopenharmony_ci| ---- | ---------------------- | ---- | ---- | ---------- |
1162e41f4b71Sopenharmony_ci| name | string                 | Yes  | Yes  | Template name. |
1163e41f4b71Sopenharmony_ci| data | Record<string, Object> | Yes  | Yes  | Template data. |
1164e41f4b71Sopenharmony_ci
1165e41f4b71Sopenharmony_ci
1166e41f4b71Sopenharmony_ci## NotificationUserInput<sup>8+</sup>
1167e41f4b71Sopenharmony_ci
1168e41f4b71Sopenharmony_ciProvides the notification user input.
1169e41f4b71Sopenharmony_ci
1170e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Notification.Notification
1171e41f4b71Sopenharmony_ci
1172e41f4b71Sopenharmony_ci| Name    | Type  | Readable | Writable | Description                         |
1173e41f4b71Sopenharmony_ci| -------- | ------ | --- | ---- | ----------------------------- |
1174e41f4b71Sopenharmony_ci| inputKey | string | Yes | Yes | Key to identify the user input. |
1175