Unread Messages & Message Notifications

Updated: 2025/10/10
Read Time: 5 min
Use the $cloud module to push device unread messages, task progress, and running status to the cloud control backend in real-time, enabling dynamic display on the group control screen casting interface.

Feature Overview

$cloud.notifyUnreadMessages() is used to notify the cloud control backend to update the current device's unread message count or other key status.
Scripts can read statistical data (such as message count, pending tasks, etc.) from the local SQLite database and synchronize it to the cloud control backend in real-time, enabling dynamic display on the screen casting interface.


Applicable Scenarios

  • Display the unread message count on the device side;
  • Synchronize script execution status or task progress;
  • Push custom logs, prompts, or alert information to the backend.

Implementation Logic

  1. Device-side SQLite Data Update
    • Unread message data is stored in the device's local SQLite;
    • Scripts can update or query related tables in real-time via the SQLite API.
  2. Call Notification Interface
    • After calling $cloud.notifyUnreadMessages(), the cloud control backend will automatically refresh the display;
    • Supports batch device synchronization, suitable for group control and multi-task monitoring scenarios.

$cloud.message(message)

Send a plain text message to the cloud control backend.

$cloud.message(message, type)

Send a typed message to the cloud control backend, used to distinguish message levels and log types.

Parameter Description:

ParameterTypeDescription
messagestringMessage content to send
typestringMessage type (optional)

Optional Types:

  • "verbose" — Verbose message;
  • "info" — Info message;
  • "warn" — Warning message;
  • "error" — Error message;
  • "log" — Log message

Examples:


Explanation

💡 Both $cloud.message() and $cloud.notifyUnreadMessages() are cloud control communication interfaces that encapsulate the device-side message reporting logic. They automatically forward message content to the cloud control backend via WebSocket / P2P channels, enabling real-time message synchronization display on the group control screen casting interface.