通知管理
通知管理
导入模块
import notification from '@system.notification'
API
send
发送一条消息。
interface SendMessage {
type: string, // 消息类型
notifyWay: string,
title: string,
icon?: string,
sender?: string,
content: string,
priority? number
}
getMessages
读取所有的消息。
getCount
获取消息的条数。
readMessages
将指定 id
的消息设置为已读状态。
deleteMessage
删除指定 id
的消息。
deleteAll
删除所有消息。
subscribe
订阅消息通知。
unsubscribe
取消订阅消息通知。
类型
Message
interface Message {
type: 'text' | 'image' | 'schedule', // 消息类型
notifyWay: string, // 消息通知方式
title: string, // 消息的标题
icon?: string, // 消息图标的 URI
sender?: string, // 发送者名字
content: string, // 消息的内容,如果是图片消息则是图片的 URI
priority? number, // 消息的优先级,默认为 0
arrivedTime: number, // 发送消息的时间戳,可使用 Date 对象来操作
id: string // 消息的唯一标识符
}