Skip to content

Add true push notification support (particularly iOS and Android) and simple service worker <-> client communication#2356

Closed
GigiaJ wants to merge 85 commits intocinnyapp:devfrom
GigiaJ:add-push-notifs
Closed

Add true push notification support (particularly iOS and Android) and simple service worker <-> client communication#2356
GigiaJ wants to merge 85 commits intocinnyapp:devfrom
GigiaJ:add-push-notifs

Conversation

@GigiaJ
Copy link
Contributor

@GigiaJ GigiaJ commented Jun 9, 2025

Description

Adds true push notification support alongside a Sygnal server to target. This provides a straightforward push notification implementation for iOS users as well as Android.

Redesigns the current service worker implementation and provides a simplistic message system between the client and service worker. Adds a toggle to enable webpush notifs in addition to the current in app notif toggle in the settings menu. Adds config options for a push gateway to be set.
Provides an easy future avenue for just adding the app APN info and FCM info to the Sygnal instance should the release move from PWA on mobile to a full app release.

Currently I'm hosting a stock Sygnal instance in a docker container and a caddy instance in a docker container on a Vultr IPv6 only VPS. It is proxied through Cloudflare so no egress or ingress fees (should make the price extremely stable for bandwidth billing). Can read more here: https://blogs.vultr.com/vultr--cloudflare-bandwidth-alliance--win-win
https://www.cloudflare.com/bandwidth-alliance/
Currently happy to pay for the hosting fees for the domain included (cinny.cc) and the VPS which comes out to $3.50/mo.

I'm also happy to work some sort of transfer or change in ownership out as well if that is preferred.

I'll be including docs to reproduce for those who want to privately host instead. (I'd also be willing to write some Pulumi IaC for it at some point.)

Fixes #
#17 (Partially)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@GigiaJ GigiaJ marked this pull request as draft June 9, 2025 14:52
@GigiaJ
Copy link
Contributor Author

GigiaJ commented Jun 9, 2025

The internal update check will likely not live to the end, but is convenient to make sure the service workers are refreshed on mobile.

Left to do (not inclusive as I might be forgetting something):

  • Currently sending muted chat notifs while app is open because our code no longer filters them
  • Add a check to see if a pusher already exists for the device on start
  • Add a way for notifs badge to be cleared
  • Organize notes for Sygnal deployment and include them

@GigiaJ GigiaJ changed the title Add true push notification support (super nice on mobile) and simple service worker <-> client communication Add true push notification support (particularly mobile) and simple service worker <-> client communication Jun 9, 2025
@GigiaJ GigiaJ changed the title Add true push notification support (particularly mobile) and simple service worker <-> client communication Add true push notification support (particularly iOS/Android) and simple service worker <-> client communication Jun 9, 2025
@GigiaJ GigiaJ changed the title Add true push notification support (particularly iOS/Android) and simple service worker <-> client communication Add true push notification support (particularly iOS and Android) and simple service worker <-> client communication Jun 9, 2025
@GigiaJ GigiaJ marked this pull request as ready for review June 11, 2025 00:25
@GigiaJ GigiaJ marked this pull request as draft June 11, 2025 01:21
@GigiaJ GigiaJ force-pushed the add-push-notifs branch from 8f8b88f to 78a5dd1 Compare June 11, 2025 01:22
@GigiaJ GigiaJ marked this pull request as ready for review June 11, 2025 01:25
@GigiaJ GigiaJ force-pushed the add-push-notifs branch from 6c2ab1c to 9440e63 Compare June 30, 2025 05:43
@williamkray
Copy link

FYI there's currently an open issue to add support for Unified Push, which feels very related to this PR. not sure if it's something you would consider building into this, or if you'd prefer to keep it separate. This would enable more comprehensive push notifications.

@GigiaJ
Copy link
Contributor Author

GigiaJ commented Jun 30, 2025

FYI there's currently an open issue to add support for Unified Push, which feels very related to this PR. not sure if it's something you would consider building into this, or if you'd prefer to keep it separate. This would enable more comprehensive push notifications.

This change should support UnifiedPush provided you are the individual hosting Cinny.
You can set the pushNotificationDetails in config.json and point to your pushNotifyUrl, vapidPublicKey, and webPushAppId.
Right now it is implicitly designed with Sygnal in mind and I've provided docs on hosting your own instance of Sygnal too.
UnifiedPush or Sygnal, the flow is Homeserver -> Push Gateway -> Device. If the app is in background then our code toggles on the pusher which has been registered with the web push endpoint (so like fcm.googleapis.com, fcm.mozilla.com, apn.apple.com) and the stored push gateway endpoint. Sygnal facilitates the distribution of notifications.

The TLDR is that this is that change with the more Matrix centered implementation. In fact you likely can use ntfy (UnifiedPush) since it expects the pushkey, matrix gateway endpoint, and app_id in the same way even.

@krishukr
Copy link

Hi there, I recently made some changes to your PR to make webpush usable. My PWA on iPhone has been getting push notifications for months even after system reboot. I'd love to continue this PR and merge it into the upstream with you. I'd really appreciate it if you could review my code and give me your thoughts. It would be even better if we could solve any issues together. Please do contact me on Matrix at @kris:krishu.moe.

krishukr and others added 19 commits February 15, 2026 19:01
if event_id is not available, jump to inbox

i haven't check app notification, this is for push notification for now
still need to handle invitation notification
currenttly all browser requrire a `push` produces a notification, if
not, push subscription may be revoked.

see:
firebase/firebase-js-sdk#8010 (comment)

in this case, sygnal, the push gateway will send unread count, and
create a `push` event, when messages are read on other clients.
Therefore we have no choice but to stop sygnal from pushing data that
won't be presented as notifications

see:
https://github.com/element-hq/sygnal/blob/da48ba7457409391c1d12140ce2ea3d49d377ff3/sygnal/webpushpushkin.py#L142-L145
so that a notification will always be generated from a push event,
avoiding being killed for privacy policies from browser and os
Sygnal already adds `mailto:` by itself. When added manually, apple will error out with `403: BadJwtToken`. Hence the mailto should be removed :)

(cherry picked from commit 0d66762)
Signed-off-by: Kris Hu <i@krishu.moe>
@github-actions
Copy link

github-actions bot commented Feb 16, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@OE1KHZ
Copy link

OE1KHZ commented Feb 16, 2026

I have read the CLA Document and I hereby sign the CLA

ajbura added a commit to cinnyapp/cla that referenced this pull request Feb 16, 2026
@kfiven
Copy link
Collaborator

kfiven commented Mar 14, 2026

We do not have this in roadmap yet. Will revisit once we move over to new SDK.

@kfiven kfiven closed this Mar 14, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Mar 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants