Real-time push notifications via WebSocket for the Aoba messaging platform.
The notification WebSocket provides real-time push notifications for events that require immediate user attention, such as group invitations. This channel is server-to-client only - clients receive notifications but do not send messages.
/api/v1/notificationsauth_token cookie or ?token= query parameterSame-origin (cookie-based):
const ws = new WebSocket('wss://api.example.com/api/v1/notifications');
Cross-origin (token parameter):
const ws = new WebSocket(`wss://api.example.com/api/v1/notifications?token=${jwtToken}`);
| Parameter | Value | Description |
|---|---|---|
| Write timeout | 10s | Time allowed to write a message |
| Pong timeout | 60s | Time allowed for client to respond to ping |
| Ping interval | 54s | Server sends ping frames at this interval |
When a user connects from multiple devices:
Production notification server
JWT token stored in HTTP-only cookie named auth_token.
For cross-origin WebSocket connections, the token can also be
passed as a ?token= query parameter.
Development notification server
JWT token stored in HTTP-only cookie named auth_token.
For cross-origin WebSocket connections, the token can also be
passed as a ?token= query parameter.
WebSocket channel for receiving real-time push notifications.
This is a receive-only channel - clients subscribe to receive notifications but do not publish messages.
Receive push notifications from the server
Subscribe to this channel to receive real-time notifications.
Currently supported notification types:
invitation_received - Sent to invitee when invited to a groupinvitation_accepted - Sent to inviter when their invitation is acceptedinvitation_denied - Sent to inviter when their invitation is deniedconst ws = new WebSocket('wss://api.example.com/api/v1/notifications');
ws.onmessage = (event) => {
const notification = JSON.parse(event.data);
switch (notification.type) {
case 'invitation_received':
showInvitationPopup(notification.data);
break;
case 'invitation_accepted':
showSuccessToast(`${notification.data.acceptedByUsername} joined the group`);
break;
case 'invitation_denied':
showInfoToast(`Invitation was declined`);
break;
}
};
ws.onclose = () => {
// Implement reconnection logic
};
Available only on servers:
Accepts one of the following messages:
Notification when user receives a group invitation
Sent to the invitee when another user invites them to join a group.
The invitee should display this notification to allow accepting or declining.
User receives invitation to join "Project Alpha" group
{
"type": "invitation_received",
"timestamp": 1733644800000,
"data": {
"invitationId": "550e8400-e29b-41d4-a716-446655440000",
"groupId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"groupName": "Project Alpha",
"inviterUsername": "alice"
}
}
Notification when an invitation is accepted
Sent to the inviter when the invitee accepts their group invitation.
The inviter can update their UI to show the new member has joined.
Bob accepts Alice's invitation to join "Project Alpha"
{
"type": "invitation_accepted",
"timestamp": 1733645000000,
"data": {
"invitationId": "550e8400-e29b-41d4-a716-446655440000",
"groupId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"groupName": "Project Alpha",
"acceptedByUsername": "bob"
}
}
Notification when an invitation is denied
Sent to the inviter when the invitee declines their group invitation.
The inviter can optionally show a notification or remove the pending invitation from their UI.
Carol declines Alice's invitation
{
"type": "invitation_denied",
"timestamp": 1733645200000,
"data": {
"invitationId": "660e8400-e29b-41d4-a716-446655440001",
"groupId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"deniedByUsername": "carol"
}
}
Notification when user receives a group invitation
Sent to the invitee when another user invites them to join a group.
The invitee should display this notification to allow accepting or declining.
Notification when an invitation is accepted
Sent to the inviter when the invitee accepts their group invitation.
The inviter can update their UI to show the new member has joined.
Notification when an invitation is denied
Sent to the inviter when the invitee declines their group invitation.
The inviter can optionally show a notification or remove the pending invitation from their UI.
The type of notification event
Base structure for all notification events
Data payload for invitation_received notification
Data payload for invitation_accepted notification
Data payload for invitation_denied notification