文档管理中心

@system.notification (通知消息)

Phone12+PC/2in113+Tablet12+TV19+Wearable18+
说明
  • 从API Version 7 开始,该接口不再维护,推荐使用新接口@ohos.notification (Notification模块)

  • 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

导入模块

收起
自动换行
深色代码主题
复制
  1. import notification from '@system.notification';

ActionResult

Phone12+PC/2in113+Tablet12+TV19+Wearable18+

系统能力:SystemCapability.Notification.Notification

展开
名称 类型 必填 说明
bundleName string 单击通知后要重定向到的应用程序的Bundle名。
abilityName string 单击通知后要重定向到的应用程序的Ability名称。
uri string 要重定向到的页面的uri。

ShowNotificationOptions

Phone12+PC/2in113+Tablet12+TV19+Wearable18+

系统能力:SystemCapability.Notification.Notification

展开
名称 类型 必填 说明
contentTitle string 通知标题。
contentText string 通知内容
clickAction(deprecated) ActionResult

通知被点击后触发的行为。

从API version 7开始不再维护。

notification.show

Phone12+PC/2in113+Tablet12+TV19+Wearable18+

show(options?: ShowNotificationOptions): void

显示通知。

系统能力: SystemCapability.Notification.Notification

参数:

展开
参数名 类型 必填 说明
options ShowNotificationOptions 通知标题。

示例:

收起
自动换行
深色代码主题
复制
  1. let notificationObj: notification = {
  2. show() {
  3. notification.show({
  4. contentTitle: 'title info',
  5. contentText: 'text',
  6. clickAction: {
  7. bundleName: 'com.example.testapp',
  8. abilityName: 'notificationDemo',
  9. uri: '/path/to/notification'
  10. }
  11. });
  12. }
  13. }