Skip to main content

Overview

Chat events are emitted when chat-level changes occur, such as when a chat’s read status changes.

Events

chat-read-status-changed

Emitted when a chat’s read status changes (marked as read or unread).
data
object
Chat read status change information
import { SDK } from 'advanced-imessage';

const client = SDK();

client.on('chat-read-status-changed', (data) => {
  const status = data.read ? 'read' : 'unread';
  console.log(`Chat ${data.chatGuid} marked as ${status}`);
});

await client.connect();

Event Methods

on()

Register a listener that will be called every time the event is emitted.
client.on('chat-read-status-changed', (data) => {
  console.log(data);
});

once()

Register a listener that will be called only once, then automatically removed.
client.once('chat-read-status-changed', (data) => {
  console.log('First chat read status change:', data);
});

off()

Remove a specific listener from an event.
const handler = (data) => {
  console.log(data);
};

client.on('chat-read-status-changed', handler);

// Later, remove the listener
client.off('chat-read-status-changed', handler);
You must pass the exact same function reference to off() that was passed to on(). Anonymous functions cannot be removed.

Build docs developers (and LLMs) love