cinny icon indicating copy to clipboard operation
cinny copied to clipboard

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

Open GigiaJ opened this issue 7 months ago • 4 comments

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

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

Checklist:

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

GigiaJ avatar Jun 09 '25 14:06 GigiaJ

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 avatar Jun 09 '25 14:06 GigiaJ

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.

williamkray avatar Jun 30 '25 16:06 williamkray

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.

GigiaJ avatar Jun 30 '25 17:06 GigiaJ

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 avatar Sep 26 '25 03:09 krishukr