• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# NotificationContent
2
3The **NotificationContent** module provides APIs for defining the notification content.
4
5> **NOTE**
6>
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.
8
9## NotificationContent
10
11Describes the notification contents.
12
13**System capability**: SystemCapability.Notification.Notification
14
15| Name          | Type                                                                       | Read-Only| Optional| Description              |
16| -----------   | --------------------------------------------------------------------------- | ---- | --- | ------------------ |
17| contentType<sup>(deprecated)</sup> | [notification.ContentType](./js-apis-notification.md#contenttype)  | No | Yes | Notification content type.<br>This API is deprecated since API version 11. You are advised to use **notificationContentType** instead.      |
18| notificationContentType<sup>11+</sup>    | [notificationManager.ContentType](./js-apis-notificationManager.md#contenttype)                | No | Yes | Notification content type.      |
19| normal         | [NotificationBasicContent](#notificationbasiccontent)                      | No | Yes | Normal text.  |
20| longText       | [NotificationLongTextContent](#notificationlongtextcontent)                | No | Yes | Long text.|
21| multiLine      | [NotificationMultiLineContent](#notificationmultilinecontent)              | No | Yes | Multi-line text.  |
22| picture        | [NotificationPictureContent](#notificationpicturecontent)                  | No | Yes | Picture-attached.  |
23| systemLiveView<sup>11+</sup> | [NotificationSystemLiveViewContent](#notificationsystemliveviewcontent)    | No | Yes | System live view. A third-party application cannot directly create a notification of this type. After the system proxy creates a system live view, the third-party application releases a notification with the same ID to update the specified content.|
24
25## NotificationBasicContent
26
27Describes the normal text notification.
28
29**System capability**: SystemCapability.Notification.Notification
30
31| Name          | Type   | Read-Only| Optional| Description                              |
32| -------------- | ------ | ---- |-----| ---------------------------------- |
33| title          | string |  No |  No | Notification title. It cannot be empty or exceed 1024 bytes. Excess content will be truncated.        |
34| text           | string |  No |  No | Notification content. It cannot be empty or exceed 3072 bytes. Excess content will be truncated.        |
35| additionalText | string |  No |  Yes | Additional information of the notification. It cannot exceed 3072 bytes. Excess content will be truncated.  |
36| lockscreenPicture<sup>12+</sup> | [image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md) |  No |  Yes | Picture of a notification displayed on the lock screen. Currently, only the live view notification is supported. The total number of the icon pixel bytes cannot exceed 192 KB (which is obtained through [getPixelBytesNumber](../apis-image-kit/arkts-apis-image-PixelMap.md#getpixelbytesnumber7)). The recommended icon size is 128 × 128 pixels. The display effect depends on the device capability and notification center UI style.  |
37
38## NotificationLongTextContent
39
40Describes the long text notification. This API is inherited from [NotificationBasicContent](#notificationbasiccontent).
41
42> **NOTE**
43>
44> The display effect depends on the device capability and notification center UI style.
45
46**System capability**: SystemCapability.Notification.Notification
47
48| Name          | Type   | Read-Only| Optional| Description                            |
49| -------------- | ------ | ---- | --- | -------------------------------- |
50| longText       | string |  No | No | Long text of the notification. It cannot be an empty string and exceed 3072 bytes. Excess content will be truncated.                    |
51| briefText      | string |  No | No | Brief text of the notification. It cannot be empty or exceed 1024 bytes. Excess content will be truncated.  |
52| expandedTitle  | string |  No | No | Title of the notification in the expanded state. It cannot be empty or exceed 1024 bytes. Excess content will be truncated.                |
53
54
55## NotificationMultiLineContent
56
57Describes the multi-line text notification. This API is inherited from [NotificationBasicContent](#notificationbasiccontent).
58
59> **NOTE**
60>
61> - When the multi-line text notification and another notification form a group notification, the group notification is displayed as a [normal text notification](#notificationbasiccontent) by default. After the group notification is expanded, the value of **longTitle** is used as the title, and the value of **lines** is used as the multi-line text content.<br>When the multi-line text notification is displayed independently, the value of **longTitle** is used as the title, and the value of **lines** is used as the multi-line text content.
62>
63> - The display effect depends on the device capability and notification center UI style.
64
65**System capability**: SystemCapability.Notification.Notification
66
67| Name          | Type           | Read-Only| Optional| Description                            |
68| -------------- | --------------- | --- | --- | -------------------------------- |
69| briefText      | string          | No | No | Brief text of the notification. It cannot be empty or exceed 1024 bytes. Excess content will be truncated.|
70| longTitle      | string          | No | No | Title of the notification in the expanded state. It cannot be empty or exceed 1024 bytes. Excess content will be truncated.|
71| lines          | Array\<string\> | No | No | Multi-line text of a notification. A maximum of three lines are supported, and each line cannot exceed 1024 bytes. Excess content will be truncated.                 |
72
73
74## NotificationPictureContent
75
76Describes the picture-attached notification. This API is inherited from [NotificationBasicContent](#notificationbasiccontent).
77
78> **NOTE**
79>
80> The display effect depends on the device capability and notification center UI style.
81
82**System capability**: SystemCapability.Notification.Notification
83
84| Name          | Type                                         | Read-Only| Optional| Description                              |
85| -------------- | -------------------------------------------- | ---- | --- |------------------------------------|
86| briefText      | string                                       |  No | No | Brief text of the notification. It cannot be empty or exceed 1024 bytes. Excess content will be truncated.|
87| expandedTitle  | string                                       |  No | No | Title of the notification in the expanded state. It cannot be empty or exceed 1024 bytes. Excess content will be truncated.   |
88| picture        | [image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md) |  No | No | Picture content of the notification. The total number of bytes of image pixels cannot exceed 2 MB.|
89
90
91## NotificationSystemLiveViewContent
92
93Describes the system live view notification. A third-party application cannot directly create a notification of this type. After the system proxy creates a system live view, the third-party application releases a notification with the same ID to update the specified content. This API is inherited from [NotificationBasicContent](#notificationbasiccontent).
94
95**System capability**: SystemCapability.Notification.Notification
96
97| Name                        | Type                                            | Read-Only| Optional| Description                              |
98| ---------------------------- | ----------------------------------------------- | --- | --- | -----------------------------------|
99| typeCode<sup>11+</sup>       | number                                          | No | No | Type code, which identifies the type of the service that invokes the API.      |
100| capsule<sup>11+</sup>        | [NotificationCapsule](#notificationcapsule11)   | No | Yes | Capsule of the notification.                    |
101| button<sup>11+</sup>         | [NotificationButton](#notificationbutton11)     | No | Yes | Button in the notification.                    |
102| time<sup>11+</sup>           | [NotificationTime](#notificationtime11)         | No | Yes | Time of the notification.                    |
103| progress<sup>11+</sup>       | [NotificationProgress](#notificationprogress11) | No | Yes | Progress of the notification.                    |
104
105
106## NotificationCapsule<sup>11+</sup>
107
108Describe the notification capsule.
109
110**System capability**: SystemCapability.Notification.Notification
111
112| Name           | Type                                         | Read-Only| Optional| Description                           |
113| --------------- | -------------------------------------------- | --- | --- | -------------------------------- |
114| title           | string                                       | No | Yes | Title of the capsule, with a maximum of 200 bytes. Excess part will be truncated.                       |
115| icon            | [image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md) | No | Yes | Icon of the capsule.                       |
116| backgroundColor | string                                       | No | Yes | Background color of the capsule.                       |
117
118
119## NotificationButton<sup>11+</sup>
120
121Describes the notification button.
122
123**System capability**: SystemCapability.Notification.Notification
124
125| Name | Type                                                  | Read-Only| Optional| Description            |
126| ----- | ----------------------------------------------------- | --- | --- | ----------------- |
127| names | Array\<string\>                                       | No |  Yes| Button names. A maximum of three names are supported.  |
128| icons | Array\<[image.PixelMap](../apis-image-kit/arkts-apis-image-PixelMap.md)\> | No |  Yes| Button icons. A maximum of three icons are supported.  |
129| iconsResource<sup>12+</sup> | Array\<[Resource](../apis-arkui/arkui-ts/ts-types.md#resource)\> | No |  Yes| Button icon resources. A maximum of three icon resources are supported.  |
130
131## NotificationTime<sup>11+</sup>
132
133Describes the notification timing information.
134
135**System capability**: SystemCapability.Notification.Notification
136
137| Name          | Type             | Read-Only| Optional| Description                            |
138| -------------- | ---------------- | --- | --- | -------------------------------- |
139| initialTime    | number           | No | Yes | Start time, in milliseconds.               |
140| isCountDown    | boolean          | No | Yes | Whether to count down. The default value is **false**.<br>- **true**: Yes.<br>- **false**: No. |
141| isPaused       | boolean          | No | Yes | Whether to pause the progress. The default value is **false**.<br>- **true**: Yes.<br>- **false**: No.  |
142| isInTitle      | boolean          | No | Yes | Whether the time is displayed in the title. The default value is **false**.<br>- **true**: Yes.<br>- **false**: No. |
143
144**Example**:
145
146```ts
147// The notification counts down from three seconds and the time is displayed in the title.
148time: {
149    initialTime: 3000,
150    isCountDown: true,
151    isPaused: false,
152    isInTitle: true,
153}
154```
155
156
157## NotificationProgress<sup>11+</sup>
158
159Describes the notification progress.
160
161**System capability**: SystemCapability.Notification.Notification
162
163| Name          | Type           | Read-Only| Optional| Description                            |
164| -------------- | --------------- | --- | --- | -------------------------------- |
165| maxValue        | number         | No | Yes | Maximum progress value.                      |
166| currentValue    | number         | No | Yes | Current progress value.                      |
167| isPercentage    | boolean        | No | Yes | Whether to show the progress in percentage. The default value is **false**.<br>- **true**: Yes.<br>- **false**: No. |
168