# 消息通知 notification

# 接口声明

{ "name": "system.notification" }
1

# 导入模块

import notification from '@system.notification'const notification = require('@system.notification')
1

# 接口定义

# notification.publish

发布通知

# 参数:

参数名 类型 必填 说明
request Notification 消息通知对象
success Function 成功的回调
fail Function 失败的回调
complete Function 执行结束后的回调
# Notification

说明如下:

参数名 类型 必填 默认 说明
icon String - 通知小图标,应用下的图片的绝对路径
id number - 应用通知的唯一 id
appName String - 应用名称
contentType Number - 正文类型。 1:普通文本通知类型。 2:图片通知类型
content Content - 通知内容 与 contentType 对应
platform String - 消息渠道来源 (PHONE 时) IOS | Andriod
deliveryTime Number - 通知发送时间
actionButtons Array<ActionButton> - 通知按钮,最多两个按钮
largeIcon String - 通知大图标,应用下的图片的绝对路径
isUnremovable Boolean false 是否不可清除
appBundleName String - 应用包名 ,格式 com.xxx.xxx,该字段的值应由 native 填充
extraInfo {[key: String]: any} - 扩展参数
# Content

普通文本通知类型

名称 类型 必填 说明
title String 普通文本通知标题
text String 普通文本通知内容
additionalText String 可选参数,普通文本通知附加信息

图片通知类型

名称 类型 必填 说明
title String 通知标题
text String 通知内容
additionalText String 可选参数,通知附加信息
briefText String 图片文本通知简略内容
expandedTitle String 图片通知扩展标题
picture String 图片通知的图片,,应用下的图片的绝对路径
# ActionButton
参数名 类型 必填 说明
label String 按钮标题
action Action 点击按钮时触发的动作
extras {[key: String]: any} 扩展参数
# Action
参数名 类型 必填 说明
triggerMethod String 定义按钮点击触发的回调函数, 需要在 app.ux 中定义
prameters {[key: String]: any} 自定义参数,供回调函数使用

# 示例:

notification.publish({
  request: {
    icon: './icon.png',
    contentType: 1,
    content: {
      title: '收件通知',
      text: '门口xx收件,收件码:XXX'
    },
    channel: 1,
    deliveryTime: Date.now()
  },
  success: function() {},
  fail: function() {},
  complete: function() {}
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15