Repository navigation
Releases
Releases · Franklyn-R-Silva/supabase_realtime_push
v0.1.0
Breaking changes
- The default channel name and "connected" notification follow the phone's
language, in the same languages as Reply:start'schannelName,
connectedTitleandconnectedTextnow default to null, which means the
plugin's string resources. A string passed tostartstill wins. A config
saved by an older version keeps its English names until the app calls
startagain. - New
PushStatus.unregistered: this install has no device pair (never
started, restored from a backup, orstop(forgetDevice: true)).
stoppednow means only "turned off bystop()", so an app that restarts
the service on launch no longer undoes a user's off switch. Aswitchover
PushStatusneeds the new case. Register and start onunregisteredand
rejected, not onstopped. - Security: a device ends with the session it was registered in.
realtime_push_registerstores the JWT'ssession_id, and when Supabase
Auth deletes that session (a sign-out with scopeglobalorothers, a
password change, a revoked session) the device is deleted and signalled,
so a lost phone stops even if its app never runs again. A session that
already ended cannot register a device. Devices registered before have no
session and are left alone. Run the script again to get it. Register again
whenstatus()isrejected, as README step 3 says. - Security:
startrefuses a secret key (sb_secret_…) or aservice_role
JWT aspublishableKey, with anArgumentError(bad_argumentson the
Android side). Such a key bypasses RLS, and it was shipped in the APK,
backed up with the app's settings and sent in the WebSocket URL. Pass the
publishable key (sb_publishable_…) or the legacy anon key. - Security:
starttakes anhttp://URL only for local development
(localhost,127.0.0.1,::1,10.0.2.2). Over cleartext anyone on the
network read the device secret, every notification and the topic. Use
https://, or the new, insecureallowCleartext: true. A self-hosted
server on the LAN reached overhttpnow fails until one of the two.
Security
- Security: any app with notification access could rewrite the extras of the
Reply action's intent, which must be mutable, and make this app post a
notification with any title and body under its name and icon, or send the
reply to another conversation. The intent's extras are now sealed with an
HMAC keyed by a per-install secret, and a reply whose extras were changed is
ignored. Anyone using the Reply action on 0.0.1 is affected and should
update. - Security: a user keeps at most 10 devices.
realtime_push_register
deletes the caller's device seen least recently beyond that, and signals
it, so a script can no longer register thousands of pairs that every
notification to that user fans out to. Run the script again to get it. - Security: a
largeIconwhose host is a private, loopback or link-local IP
address is ignored, like a non-https one, so a snapshot cannot make the
phone send requests inside the network it is on. The README now says to
buildlargeIcononly from storage you control, never from a URL a user
typed, which lets its owner see when and from where each recipient got
the notification.
New features
- Lock screen privacy: a snapshot notification with
"lockScreen": "hidden"
stays off a secure lock screen;"redacted"shows only itspublicTitle
there ("New message") when the user hides sensitive content, and during
screen sharing on Android 15+. Any other value counts as"hidden". A
failed reply reposts it just as private. The inbox sets neither. lastError(): the service's latest failure (a snapshot that failed, a
connection refused before it joined, the foreground refused) and when it
happened, ornullonce a snapshot works. It tells an app why nothing
arrives whilestatus()saysrunning, withoutadb logcat.- The service reconnects as soon as the network comes back or changes (Wi-Fi
to mobile data), instead of waiting up to 30 s for the next retry. The
plugin now declaresACCESS_NETWORK_STATE. setFocus(id): while the app is on screen, the notification the user is
looking at (the open chat, for instance) leaves the shade and does not ring;
it comes back quietly if still unread once they leave.realtime_push.sql: deleting a device row (unregister, the user deleted)
signals that device, so the phone clears its notifications and stops at
once instead of at its next snapshot read. Run the script again to get it.- A channel removed from
start(channels: ...)is deleted from the app's
notification settings; listing it again brings back the user's settings. - The Reply action and the "Not sent" header come in Portuguese, Spanish,
French, German and Italian too. An app still overrides them, or adds another
language, with the same string names in its own resources. - After three refusals in a row (
socket failed HTTP 429, the Realtime
connection limit, orjoin refused, public channels turned off) the
service waits 5 minutes before reconnecting instead of up to 30 s, and the
periodic check reads the snapshot meanwhile. A fleet above the limit no
longer keeps the server full with retries in waves. The screen turning on
or a network change still reconnects at once. - A snapshot entry's optional
"time"(milliseconds since the epoch) shows
when the notification arrived, next to its title. The default
realtime_push_snapshot_forsends each row'screated_at; running the
script again keeps an existing one, so an install that never replaced it
gets the time by dropping it first:
drop function public.realtime_push_snapshot_for(uuid);, then the script. startwith anhttp://URL whose host Android blocks cleartext traffic to
(the default for apps targeting Android 9+) throwsbad_argumentswith how
to allow it, instead of starting a service that never connects.areNotificationsEnabled()tells whether the user turned off the app's
notifications or its messages channel, without prompting, and
openNotificationSettings()opens the app's notification settings.- "Mark as read" on the notification: a snapshot entry with
"markRead": truegets the action, which removes it at once, like a swipe,
and calls the newrealtime_push_read, which hands the id to your
realtime_push_read_for. The default reads the inbox rows of that key, so
it leaves every device, and the inbox snapshot offers the action. Run the
script again for the new functions; the inbox snapshot offers it once
realtime_push_snapshot_foris dropped and recreated, as for"time". - A failed snapshot, reply or mark as read logs PostgREST's error code next
to the HTTP status (snapshot failed: HTTP 404 (42P01)), never its
message; the README's Troubleshooting table says what each code means. The
device's calls sendContent-Profile: public, so they work whenpublic
is not the first schema the Data API exposes. realtime_push_mark_all_read()reads every unread inbox row of the
signed-in user in one call, for a "Mark all as read" button; one signal
clears every device. Run the script again to get it.realtime_push_send_test(p_title, p_body)lets a signed-in user send
themselves a test notification, under the keyrealtime_push:test; a new
one replaces the last, and one within 10 s of the last does nothing and
returns null. Run the script again to get it.- A snapshot's optional
moreis the number of notifications it left out:
the device shows one quiet "+15 more" (translated like Reply) that opens the
app, and removes it at 0. The default inbox sets it to the unread keys past
the 20 it lists. Run the script again to get it, after
drop function public.realtime_push_snapshot_for(uuid);if you never
replaced the default: the script keeps an existing one, as for"time". - A channel in
start(channels: ...)can be quieter than the default:
PushChannel('Offers', importance: PushImportance.low)shows without a
sound,PushImportance.mediumrings without popping up. A plain name still
works and stays high. Android keeps a channel's importance once created, so
changing it later needs a new channel id.
Fixes
- The periodic check reads the snapshot with the screen on too, so a broadcast
Realtime dropped while the socket stayed up no longer leaves the shade stale. - The large icon cache holds a full default snapshot (20 icons at the largest
screen density). With more icons than it held, every snapshot downloaded
them all again, and some were posted without their picture. - A notification posted without its large icon (the download failed or ran
out of time) gets it with a later snapshot, quietly. A URL that failed is
tried again after 10 minutes instead of on every snapshot. - A failed reply keeps the launcher badge number on the "Not sent" repost.
- After Android killed the app in the background, opening it again from the
launcher no longer returns the old tap fromlaunchTap(), so the app does
not navigate to that notification a second time. - The reconnect backoff grows even when each attempt joins: a server that
accepted the join and dropped the socket soon after got a reconnect, a
join and a snapshot about every second while the screen was on. - A snapshot cut short when Android stops the service no longer rings again
for what it had already posted. - A notification pushed out of the snapshot by newer ones that comes back at
the same revision no longer rings again, nor returns after the user swiped
it away. - A late dismissal of an older revision (the old tap intent after Android
killed the app, or a swipe that lands after a newer revision was posted) no
longer removes the newer notification from the shade. - A tap that arrives while nothing listens to
taps(the app subscribes after
a sign-in screen, or the listening widget wa...
0.0.1
- Project scaffold and the Dart ↔ Android ↔ database contract.
- CI scans every PR for leaked secrets (gitleaks) and grades the repository
with OpenSSF Scorecard. - Dart API:
device,start,stop,status, battery exemption,
notification permission,launchTapand thetapsstream. - README from setup to the first notification, and an example app that signs
in, registers the device and starts the service. supabase/realtime_push.sql: device registration, the snapshot, the
"changed" signal and a ready-made inbox, tested on Postgres 17.- Android service that keeps the Realtime connection and shows the snapshot as notifications.
openConnectedNotificationSettings()opens the settings of the "connected"
notification alone, so the user can hide it while the service keeps running.- Needs Flutter 3.44 or later: the Android build relies on Flutter applying
the Kotlin plugin to apps without AGP 9's built-in Kotlin. - Reply from the notification: a snapshot entry with
"reply": truegets a
Reply action, the text goes to the newrealtime_push_reply, which hands it
to yourrealtime_push_reply_for, and a reply that fails says "Not sent" on
the notification and keeps the text. - Notification channels and pictures:
start(channels: {...})declares more
channels, a snapshot entry picks one with"channel", and"largeIcon"
shows an https picture, such as the sender's avatar, beside the text. start(foregroundService: false)never shows the "connected" notification:
without the battery exemption the connection is held while the app is open,
and with it closed a periodic check reads the snapshot. That check now also
runs after Android kills the service, so notifications keep arriving, late,
until the app opens again. The README and the example ask for the
exemption when notifications are turned on.