Receiving Messages
The SDK decrypts each inbound message before delivering it to your code, you always receive plaintext.
DecryptedMessage
interface DecryptedMessage {
messageId: string; // Unique message identifier
fromUserId: string; // Sender's user ID
toUserId: string; // Recipient's user ID
timestamp: number; // Unix ms timestamp
plaintext: string; // Decrypted message content
}Usage
const unlisten = client.onMessage((msg) => {
console.log(`[${msg.fromUserId}] ${msg.plaintext}`);
});
// Remove listener when done
unlisten();Offline messages: When the SDK connects, it automatically fetches messages that accumulated while the user was offline and delivers them through the same callback.