Register the token
Get the FCM registration token from the Firebase SDK. Then send it to the server.- After every sign-in.
- Every time
FirebaseMessaging.instance.onTokenRefreshgives a new token.
platform is ios or android. appVersion and locale are optional.
A student with no registered token gets no notification. The chat still works.
Unregister on sign-out
CallDELETE /api/devices with the same token before you discard it.
The server removes a token that FCM reports as dead. You do not need to clean up after a reinstall.
Test a registration
POST /api/devices/test sends a notification to the devices of the caller. Use it to prove that a
registration works.
results[].reason holds the message from FCM, word for word. The token in the
response is masked to its last 12 characters, so two devices stay easy to tell apart.
Send an empty body to reach every registered device. Send token to test one device alone.
What arrives
Every notification has the titleLala. The body is the message text, in Turkish, cut to 180
characters. The data object states the source:
Route every one of these to the chat screen. They are chat messages, not system alerts.
One turn from Lala can hold more than one message bubble. The server still sends one notification.
data.bubbles gives the number of bubbles, and data.messageId gives the first one.
The two proactive jobs
1
Scheduled messages, every minute
A job drains the due rows of
scheduled_messages. Each row is claimed with
FOR UPDATE SKIP LOCKED, so two server replicas cannot send the same message twice.2
Silence check-in, 07:00 Europe/Istanbul
A daily job finds students who were silent for 48 hours. It writes one short message for each,
and sends it one time.
The history is the source of truth
The server appends every delivered message to the conversation history with the rolelala.
The push is only the announcement. A push that fails to deliver does not remove the message.
Call GET /api/chat/messages when the student opens the notification, and when the application
returns to the foreground. Do not build the chat list from notification payloads.
Push delivery failures never break chat. The server logs a failed push and continues.
Times
Lala schedules in Turkey time (UTC+3). Timestamps in the API are UTC, ISO 8601. Convert toEurope/Istanbul for display.