1# NotificationContent 2 3描述通知类型。 4 5> **说明:** 6> 7> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8 9## NotificationContent 10 11通知内容。 12 13**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification 14 15| 名称 | 类型 | 只读 | 可选 | 说明 | 16| ----------- | --------------------------------------------------------------------------- | ---- | --- | ------------------ | 17| contentType<sup>(deprecated)</sup> | [notification.ContentType](./js-apis-notification.md#contenttype) | 否 | 是 | 通知内容类型。<br>从API version 11开始不再维护,建议使用notificationContentType代替。 | 18| notificationContentType<sup>11+</sup> | [notificationManager.ContentType](./js-apis-notificationManager.md#contenttype) | 否 | 是 | 通知内容类型。 | 19| normal | [NotificationBasicContent](#notificationbasiccontent) | 否 | 是 | 基本类型通知内容。 | 20| longText | [NotificationLongTextContent](#notificationlongtextcontent) | 否 | 是 | 长文本类型通知内容。 | 21| multiLine | [NotificationMultiLineContent](#notificationmultilinecontent) | 否 | 是 | 多行类型通知内容。 | 22| picture | [NotificationPictureContent](#notificationpicturecontent) | 否 | 是 | 图片类型通知内容。 | 23| systemLiveView<sup>11+</sup> | [NotificationSystemLiveViewContent](#notificationsystemliveviewcontent) | 否 | 是 | 系统实况窗类型通知内容。不支持三方应用直接创建该类型通知,可以由系统代理创建系统实况窗类型通知后,三方应用发布同ID的通知来更新指定内容。| 24 25## NotificationBasicContent 26 27描述普通文本通知。 28 29**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification 30 31| 名称 | 类型 | 只读 | 可选 | 说明 | 32| -------------- | ------ | ---- |-----| ---------------------------------- | 33| title | string | 否 | 否 | 通知标题(不可为空字符串,大小不超过1024字节,超出部分会被截断)。 | 34| text | string | 否 | 否 | 通知内容(不可为空字符串,大小不超过3072字节,超出部分会被截断)。 | 35| additionalText | string | 否 | 是 | 通知附加内容,是对通知内容的补充(大小不超过3072字节,超出部分会被截断)。 | 36| lockscreenPicture<sup>12+</sup> | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | 否 | 是 | 通知在锁屏界面显示的图片。当前仅支持实况窗类型通知。图标像素的总字节数不超过192KB(图标像素的总字节数通过[getPixelBytesNumber](../apis-image-kit/js-apis-image.md#getpixelbytesnumber7)获取),建议图标像素长宽为128*128。实际显示效果依赖于设备能力和通知中心UI样式。 | 37 38## NotificationLongTextContent 39 40描述长文本通知。继承自[NotificationBasicContent](#notificationbasiccontent)。 41 42> **说明:** 43> 44> 实际显示效果依赖于设备能力和通知中心UI样式。 45 46**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification 47 48| 名称 | 类型 | 只读 | 可选 | 说明 | 49| -------------- | ------ | ---- | --- | -------------------------------- | 50| longText | string | 否 | 否 | 通知的长文本(不可为空字符串,大小不超过3072字节,超出部分会被截断)。 | 51| briefText | string | 否 | 否 | 通知概要内容,是对通知内容的总结(不可为空字符串,大小不超过1024字节,超出部分会被截断)。 | 52| expandedTitle | string | 否 | 否 | 通知展开时的标题(不可为空字符串,大小不超过1024字节,超出部分会被截断)。 | 53 54 55## NotificationMultiLineContent 56 57描述多行文本通知。继承自[NotificationBasicContent](#notificationbasiccontent)。 58 59> **说明:** 60> 61> 实际显示效果依赖于设备能力和通知中心UI样式。 62 63**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification 64 65| 名称 | 类型 | 只读 | 可选 | 说明 | 66| -------------- | --------------- | --- | --- | -------------------------------- | 67| briefText | string | 否 | 否 | 通知概要内容,是对通知内容的总结(不可为空字符串,大小不超过1024字节,超出部分会被截断)。 | 68| longTitle | string | 否 | 否 | 通知展开时的标题(不可为空字符串,大小不超过1024字节,超出部分会被截断)。| 69| lines | Array\<string\> | 否 | 否 | 通知的多行文本(每行大小不超过1024字节,超出部分会被截断)。 | 70 71 72## NotificationPictureContent 73 74描述附有图片的通知。继承自[NotificationBasicContent](#notificationbasiccontent)。 75 76> **说明:** 77> 78> 实际显示效果依赖于设备能力和通知中心UI样式。 79 80**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification 81 82| 名称 | 类型 | 只读 | 可选 | 说明 | 83| -------------- | -------------------------------------------- | ---- | --- |------------------------------------| 84| briefText | string | 否 | 否 | 通知概要内容,是对通知内容的总结(不可为空字符串,大小不超过1024字节,超出部分会被截断)。 | 85| expandedTitle | string | 否 | 否 | 通知展开时的标题(不可为空字符串,大小不超过1024字节,超出部分会被截断)。 | 86| picture | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | 否 | 否 | 通知的图片内容(图像像素的总字节数不能超过2MB)。| 87 88 89## NotificationSystemLiveViewContent 90 91描述系统实况窗通知内容。不支持三方应用直接创建该类型通知,可以由系统代理创建系统实况窗类型通知后,三方应用发布同ID的通知来更新指定内容。继承自[NotificationBasicContent](#notificationbasiccontent)。 92 93**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification 94 95| 名称 | 类型 | 只读| 可选 | 说明 | 96| ---------------------------- | ----------------------------------------------- | --- | --- | -----------------------------------| 97| typeCode<sup>11+</sup> | number | 否 | 否 | 类型标识符,标记调用方业务类型。 | 98| capsule<sup>11+</sup> | [NotificationCapsule](#notificationcapsule11) | 否 | 是 | 实况通知的胶囊。 | 99| button<sup>11+</sup> | [NotificationButton](#notificationbutton11) | 否 | 是 | 实况通知的按钮。 | 100| time<sup>11+</sup> | [NotificationTime](#notificationtime11) | 否 | 是 | 实况通知的时间。 | 101| progress<sup>11+</sup> | [NotificationProgress](#notificationprogress11) | 否 | 是 | 实况内容的进度。 | 102 103 104## NotificationCapsule<sup>11+</sup> 105 106描述通知胶囊。 107 108**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification 109 110| 名称 | 类型 | 只读 | 可选 | 说明 | 111| --------------- | -------------------------------------------- | --- | --- | -------------------------------- | 112| title | string | 否 | 是 | 胶囊标题。 | 113| icon | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | 否 | 是 | 胶囊图片。 | 114| backgroundColor | string | 否 | 是 | 背景颜色。 | 115 116 117## NotificationButton<sup>11+</sup> 118 119描述通知按钮。 120 121**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification 122 123| 名称 | 类型 | 只读 | 可选 | 说明 | 124| ----- | ----------------------------------------------------- | --- | --- | ----------------- | 125| names | Array\<string\> | 否 | 是 | 按钮名称(最多支持3个)。 | 126| icons | Array\<[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)\> | 否 | 是 | 按钮图片(最多支持3个)。 | 127| iconsResource<sup>12+</sup> | Array\<[Resource](../apis-arkui/arkui-ts/ts-types.md#resource)\> | 否 | 是 | 按钮资源(最多支持3个)。 | 128 129## NotificationTime<sup>11+</sup> 130 131描述通知计时信息。 132 133**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification 134 135| 名称 | 类型 | 只读 | 可选 | 说明 | 136| -------------- | ---------------- | --- | --- | -------------------------------- | 137| initialTime | number | 否 | 是 | 计时起始时间。单位:ms。 | 138| isCountDown | boolean | 否 | 是 | 是否倒计时。 | 139| isPaused | boolean | 否 | 是 | 是否暂停。 | 140| isInTitle | boolean | 否 | 是 | 时间是否展示在title中。 | 141 142**示例:** 143 144```ts 145// 该通知从3秒开始倒计时,并且时间展示在title中。 146time: { 147 initialTime: 3000, 148 isCountDown: true, 149 isPaused: false, 150 isInTitle: true, 151} 152``` 153 154 155## NotificationProgress<sup>11+</sup> 156 157描述通知进度。 158 159**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification 160 161| 名称 | 类型 | 只读 | 可选 | 说明 | 162| -------------- | --------------- | --- | --- | -------------------------------- | 163| maxValue | number | 否 | 是 | 进度最大值。 | 164| currentValue | number | 否 | 是 | 进度当前值。 | 165| isPercentage | boolean | 否 | 是 | 是否按百分比展示。 | 166