Send & receive text
The core realtime pattern is send a JSON payload to a receiver ID and handle incoming messages in onMessage. This hub covers the concept; language pages have complete examples.
The send() contract
senderId
Yes
Must match the connecting user's userId
receiverId
One of
Single recipient user ID
data
Yes
JSON-serializable payload β typically { type: "text", text: "..." }
saveHistory
No
Default true β persist for chat history APIs
Example payload:
{
"type": "text",
"text": "Hello from DNotifier!"
}Use any type string your app understands. DNotifier does not enforce a fixed enum.
Receiving messages
Register onMessage when constructing the client:
Each message includes:
metadataβsender,timestamp,id,typepayloadβ body withtoJSON(),toString(),raw(),toBase64()
Requirements
transport: "ws"β realtime send/receive uses WebSocketconnect()completed βisConnectedmust betrueMatching
appIdβ sender and receiver must use the same application
Language guides
JavaScript / TypeScript
Dart / Flutter
Related topics
First message walkthrough
Structured media
Multiple recipients
Building chat
Last updated