Notification Management
Notification Management
Importing Modules
import notification from '@system.notification'
API
send
Sends a message.
interface SendMessage {
type: string, // Message type
notifyWay: string,
title: string,
icon?: string,
sender?: string,
content: string,
priority? number
}
getMessages
Reads all messages.
getCount
Gets the number of messages.
readMessages
Sets the message with the specified id to read status.
deleteMessage
Deletes the message with the specified id.
deleteAll
Deletes all messages.
subscribe
Subscribes to message notifications.
unsubscribe
Unsubscribe from message notifications.
Types
Message
interface Message {
type: 'text' | 'image' | 'schedule', // Message type
notifyWay: string, // Message notification method
title: string, // Message title
icon?: string, // URI of the message icon
sender?: string, // Sender name
content: string, // Message content; if it is an image message, it is the URI of the image
priority? number, // Message priority, defaults to 0
arrivedTime: number, // Timestamp when the message was sent; can be handled using a Date object
id: string // Unique identifier of the message
}
