harmony 鸿蒙NotificationContent
NotificationContent
The NotificationContent module provides APIs for defining the notification content.
NOTE
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.
NotificationContent
Describes the notification contents.
System capability: SystemCapability.Notification.Notification
Name | Type | Read Only | Optional | Description |
---|---|---|---|---|
contentType(deprecated) | notification.ContentType | No | Yes | Notification content type. This API is deprecated since API version 11. You are advised to use notificationContentType instead. |
notificationContentType11+ | notificationManager.ContentType | No | Yes | Notification content type. |
normal | NotificationBasicContent | No | Yes | Normal text. |
longText | NotificationLongTextContent | No | Yes | Long text. |
multiLine | NotificationMultiLineContent | No | Yes | Multi-line text. |
picture | NotificationPictureContent | No | Yes | Picture-attached. |
systemLiveView11+ | 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. |
NotificationBasicContent
Describes the normal text notification.
System capability: SystemCapability.Notification.Notification
Name | Type | Read Only | Optional | Description |
---|---|---|---|---|
title | string | No | No | Notification title. It cannot be empty or exceed 1024 bytes. Excess content will be truncated. |
text | string | No | No | Notification content. It cannot be empty or exceed 3072 bytes. Excess content will be truncated. |
additionalText | string | No | Yes | Additional information of the notification. It cannot exceed 3072 bytes. Excess content will be truncated. |
lockscreenPicture12+ | image.PixelMap | 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. The recommended icon size is 128 × 128 pixels. The display effect depends on the device capability and notification center UI style. |
NotificationLongTextContent
Describes the long text notification. This API is inherited from NotificationBasicContent.
NOTE
The display effect depends on the device capability and notification center UI style.
System capability: SystemCapability.Notification.Notification
Name | Type | Read Only | Optional | Description |
---|---|---|---|---|
longText | string | No | No | Long text of the notification. It cannot be an empty string and exceed 3072 bytes. Excess content will be truncated. |
briefText | string | No | No | Brief text of the notification. It cannot be empty or exceed 1024 bytes. Excess content will be truncated. |
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. |
NotificationMultiLineContent
Describes the multi-line text notification. This API is inherited from NotificationBasicContent.
NOTE
When the multi-line text notification and another notification form a group notification, the group notification is displayed as a normal text notification 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.
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.The display effect depends on the device capability and notification center UI style.
System capability: SystemCapability.Notification.Notification
Name | Type | Read Only | Optional | Description |
---|---|---|---|---|
briefText | string | No | No | Brief text of the notification. It cannot be empty or exceed 1024 bytes. Excess content will be truncated. |
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. |
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. |
NotificationPictureContent
Describes the picture-attached notification. This API is inherited from NotificationBasicContent.
NOTE
The display effect depends on the device capability and notification center UI style.
System capability: SystemCapability.Notification.Notification
Name | Type | Read Only | Optional | Description |
---|---|---|---|---|
briefText | string | No | No | Brief text of the notification. It cannot be empty or exceed 1024 bytes. Excess content will be truncated. |
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. |
picture | image.PixelMap | No | No | Picture content of the notification. The total number of bytes of image pixels cannot exceed 2 MB. |
NotificationSystemLiveViewContent
Describes 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.
System capability: SystemCapability.Notification.Notification
Name | Type | Read Only | Optional | Description |
---|---|---|---|---|
typeCode11+ | number | No | No | Type code, which identifies the type of the service that invokes the API. |
capsule11+ | NotificationCapsule | No | Yes | Capsule of the notification. |
button11+ | NotificationButton | No | Yes | Button in the notification. |
time11+ | NotificationTime | No | Yes | Time of the notification. |
progress11+ | NotificationProgress | No | Yes | Progress of the notification. |
NotificationCapsule11+
Describe the notification capsule.
System capability: SystemCapability.Notification.Notification
Name | Type | Read Only | Optional | Description |
---|---|---|---|---|
title | string | No | Yes | Title of the capsule. |
icon | image.PixelMap | No | Yes | Icon of the capsule. |
backgroundColor | string | No | Yes | Background color of the capsule. |
NotificationButton11+
Describes the notification button.
System capability: SystemCapability.Notification.Notification
Name | Type | Read Only | Optional | Description |
---|---|---|---|---|
names | Array<string> | No | Yes | Button names. A maximum of three names are supported. |
icons | Array<image.PixelMap> | No | Yes | Button icons. A maximum of three icons are supported. |
iconsResource12+ | Array<Resource> | No | Yes | Button icon resources. A maximum of three icon resources are supported. |
NotificationTime11+
Describes the notification timing information.
System capability: SystemCapability.Notification.Notification
Name | Type | Read Only | Optional | Description |
---|---|---|---|---|
initialTime | number | No | Yes | Start time, in milliseconds. |
isCountDown | boolean | No | Yes | Whether to count down. The default value is false. - true: Yes. - false: No. |
isPaused | boolean | No | Yes | Whether to pause the progress. The default value is false. - true: Yes. - false: No. |
isInTitle | boolean | No | Yes | Whether the time is displayed in the title. The default value is false. - true: Yes. - false: No. |
Example:
// The notification counts down from three seconds and the time is displayed in the title.
time: {
initialTime: 3000,
isCountDown: true,
isPaused: false,
isInTitle: true,
}
NotificationProgress11+
Describes the notification progress.
System capability: SystemCapability.Notification.Notification
Name | Type | Read Only | Optional | Description |
---|---|---|---|---|
maxValue | number | No | Yes | Maximum progress value. |
currentValue | number | No | Yes | Current progress value. |
isPercentage | boolean | No | Yes | Whether to show the progress in percentage. The default value is false. - true: Yes. - false: No. |
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Notification Kit (User Notification Service)
harmony 鸿蒙Notification Error Codes
harmony 鸿蒙NotificationActionButton
harmony 鸿蒙NotificationCommonDef
harmony 鸿蒙NotificationContent (System API)
harmony 鸿蒙NotificationFlags (System API)
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦