• 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
11**System capability**: SystemCapability.Notification.Notification
12
13| Name          | Type                                                                       | Read-only| Mandatory| Description              |
14| -----------   | --------------------------------------------------------------------------- | ---- | --- | ------------------ |
15| contentType<sup>(deprecated)</sup> | [ContentType](./js-apis-notificationManager.md#contenttype)  | No | No | Notification content type.<br>This API is deprecated since API version 11. You are advised to use **notificationContentType** instead.      |
16| notificationContentType<sup>11+</sup>    | [ContentType](./js-apis-notificationManager.md#contenttype)                | No | No | Notification content type.      |
17| normal         | [NotificationBasicContent](#notificationbasiccontent)                      | No | No | Normal text.  |
18| longText       | [NotificationLongTextContent](#notificationlongtextcontent)                | No | No | Long text.|
19| multiLine      | [NotificationMultiLineContent](#notificationmultilinecontent)              | No | No | Multi-line text.  |
20| picture        | [NotificationPictureContent](#notificationpicturecontent)                  | No | No | Picture-attached.  |
21| systemLiveView<sup>11+</sup> | [NotificationSystemLiveViewContent](#notificationsystemliveviewcontent)    | No | No | System live view (for system applications only).|
22| liveView<sup>11+</sup>       | [NotificationLiveViewContent](#notificationliveviewcontent11)              | No | No | Common live view.<br>**System API**: This is a system API.|
23
24## NotificationBasicContent
25
26Describes the normal text notification.
27
28**System capability**: SystemCapability.Notification.Notification
29
30| Name          | Type   | Read-only| Mandatory| Description                              |
31| -------------- | ------ | ---- |-----| ---------------------------------- |
32| title          | string |  No |  Yes | Notification title. It cannot be an empty string.        |
33| text           | string |  No |  Yes | Notification content. It cannot be an empty string.        |
34| additionalText | string |  No |  No | Additional information of the notification.  |
35
36
37## NotificationLongTextContent
38
39Describes the long text notification.
40
41**System capability**: SystemCapability.Notification.Notification
42
43| Name          | Type   | Read-only| Mandatory| Description                            |
44| -------------- | ------ | ---- | --- | -------------------------------- |
45| title          | string |  No | Yes | Notification title. It cannot be an empty string.                        |
46| text           | string |  No | Yes | Notification content. It cannot be an empty string.                        |
47| additionalText | string |  No | No | Additional information of the notification.  |
48| longText       | string |  No | Yes | Long text of the notification. It cannot be an empty string.                    |
49| briefText      | string |  No | Yes | Brief text of the notification. It cannot be an empty string.  |
50| expandedTitle  | string |  No | Yes | Title of the notification in the expanded state. It cannot be an empty string.                |
51
52
53## NotificationMultiLineContent
54
55Describes the multi-line text notification.
56
57**System capability**: SystemCapability.Notification.Notification
58
59| Name          | Type           | Read-only| Mandatory| Description                            |
60| -------------- | --------------- | --- | --- | -------------------------------- |
61| title          | string          | No | Yes | Notification title. It cannot be an empty string.      |
62| text           | string          | No | Yes | Notification content. It cannot be an empty string.      |
63| additionalText | string          | No | No | Additional information of the notification.|
64| briefText      | string          | No | Yes | Brief text of the notification. It cannot be an empty string.|
65| longTitle      | string          | No | Yes | Title of the notification in the expanded state. It cannot be an empty string.|
66| lines          | Array\<string\> | No | Yes | Multi-line text of the notification.                 |
67
68
69## NotificationPictureContent
70
71Describes the picture-attached notification.
72
73**System capability**: SystemCapability.Notification.Notification
74
75| Name          | Type                                         | Read-only| Mandatory| Description                              |
76| -------------- | -------------------------------------------- | ---- | --- |------------------------------------|
77| title          | string                                       |  No | Yes | Notification title. It cannot be an empty string.         |
78| text           | string                                       |  No | Yes | Notification content. It cannot be an empty string.         |
79| additionalText | string                                       |  No | No | Additional information of the notification.   |
80| briefText      | string                                       |  No | Yes | Brief text of the notification. It cannot be an empty string.|
81| expandedTitle  | string                                       |  No | Yes | Title of the notification in the expanded state. It cannot be an empty string.   |
82| picture        | [image.PixelMap](js-apis-image.md#pixelmap7) |  No | Yes | Picture attached to the notification. The maximum size is 2 MB.|
83
84
85## NotificationSystemLiveViewContent
86
87Describes the live view notification. This API is available for system applications only.
88
89**System capability**: SystemCapability.Notification.Notification
90
91| Name                        | Type                                            | Read-only| Mandatory| Description                              |
92| ---------------------------- | ----------------------------------------------- | --- | --- | -----------------------------------|
93| title                        | string                                          | No | Yes | Notification title. It cannot be an empty string.         |
94| text                         | string                                          | No | Yes | Notification content. It cannot be an empty string.         |
95| additionalText               | string                                          | No | No | Additional information of the notification.    |
96| typeCode<sup>11+</sup>       | number                                          | No | Yes | Type code, which identifies the type of the service that invokes the API.      |
97| capsule<sup>11+</sup>        | [NotificationCapsule](#notificationcapsule11)   | No | No | Capsule of the notification.                    |
98| button<sup>11+</sup>         | [NotificationButton](#notificationbutton11)     | No | No | Button in the notification.                    |
99| time<sup>11+</sup>           | [NotificationTime](#notificationtime11)         | No | No | Time of the notification.                    |
100| progress<sup>11+</sup>       | [NotificationProgress](#notificationprogress11) | No | No | Progress of the notification.                    |
101
102
103## NotificationCapsule<sup>11+</sup>
104
105Describe the notification capsule.
106
107**System capability**: SystemCapability.Notification.Notification
108
109| Name           | Type                                         | Read-only| Mandatory| Description                           |
110| --------------- | -------------------------------------------- | --- | --- | -------------------------------- |
111| title           | string                                       | No | No | Title of the capsule.                       |
112| icon            | [image.PixelMap](js-apis-image.md#pixelmap7) | No | No | Icon of the capsule.                       |
113| backgroundColor | string                                       | No | No | Background color of the capsule.                       |
114
115
116## NotificationButton<sup>11+</sup>
117
118Describes the notification button.
119
120**System capability**: SystemCapability.Notification.Notification
121
122| Name | Type                                                  | Read-only| Mandatory| Description            |
123| ----- | ----------------------------------------------------- | --- | --- | ----------------- |
124| names | Array\<string\>                                       | No |  No| Button names. A maximum of three names are supported.  |
125| icons | Array\<[image.PixelMap](js-apis-image.md#pixelmap7)\> | No |  No| Button icons. A maximum of three icons are supported.  |
126
127
128## NotificationTime<sup>11+</sup>
129
130Describes the notification time.
131
132**System capability**: SystemCapability.Notification.Notification
133
134| Name          | Type             | Read-only| Mandatory| Description                            |
135| -------------- | ---------------- | --- | --- | -------------------------------- |
136| initialTime    | number           | No | No | Start time.               |
137| isCountDown    | boolean          | No | No | Whether to count down.                    |
138| isPaused       | boolean          | No | No | Whether to pause the progress.                      |
139| isInTitle      | boolean          | No | No | Whether the time is displayed in the title.          |
140
141
142## NotificationProgress<sup>11+</sup>
143
144Describes the notification progress.
145
146**System capability**: SystemCapability.Notification.Notification
147
148| Name          | Type           | Read-only| Mandatory| Description                            |
149| -------------- | --------------- | --- | --- | -------------------------------- |
150| maxValue        | number         | No | No | Maximum progress value.                      |
151| currentValue    | number         | No | No | Current progress value.                      |
152| isPercentage    | boolean        | No | No | Whether to show the progress in percentage.                  |
153
154## NotificationLiveViewContent<sup>11+</sup>
155
156Describes the common live view.
157
158**System capability**: SystemCapability.Notification.Notification
159
160**System API**: This is a system API.
161
162| Name          | Type                                                               | Read-only| Mandatory| Description                                                 |
163| -------------- | ------------------------------------------------------------------ | --- | --- | ------------------------------------------------------|
164| status         | [LiveViewStatus](#liveviewstatus11)                                | No | Yes | Notification status.                 |
165| version        | number                                                             | No | No | Version number of the notification. If the version number stored in the database is 0xffffffff, the value of this parameter is not verified for the update and ended states. Otherwise, it needs to be verified and it must be greater than the version number stored in the database to pass the verification. If this parameter is left blank, the default value **0xffffffff** is used.|
166| extraInfo      | [key: string] object                                               | No | No | Extra information of the live view.          |
167| pictureInfo    | [key: string] Array\<[image.PixelMap](js-apis-image.md#pixelmap7)> | No | No | Extra image information of the live view.|
168
169## LiveViewStatus<sup>11+</sup>
170
171Describes the status of the common live view.
172
173**System capability**: SystemCapability.Security.AccessToken
174
175**System API**: This is a system API.
176
177| Name                        | Value|   Description  |
178| ---------------------------- |----|----------|
179| LIVE_VIEW_CREATE             | 0  | The live view is created.    |
180| LIVE_VIEW_INCREMENTAL_UPDATE | 1  | The live view is updated in incremental mode.|
181| LIVE_VIEW_END                | 2  | The live view is ended.    |
182| LIVE_VIEW_FULL_UPDATE        | 3  | The live view is updated in full mode.|
183