WebPush for DexieCloud Feature Request
Since DexieCloud is now in production and running outstanding well the last missing piece for feature complete PWA apps will be support for WebPush. Given the fact that Safari for Mac and iOS does and will not support SW periodic and background sync, WebPush will be the only solution for a wide range of applications. One of the greatest benefits of using DexieCloud is getting rid of maintaining your own server, therefore an implementation of WebPush will be a natural fit.
A rough sketch could can be something like this.
- On enable WebPush in configuration, creation of ->
- Server only table for Vapid keys
- Server only table for Subscriptions
- Synced? table for notifications
- on UserLogin and WebPush enabled, create Vapid Key pair if not exist and store on server only 'VapidTable'[User].
- DexieCloud function to get public Vapid key (applicationServerKey) for current user
- SW PushSubscription.subscribe(options(applicationServerKey)) -> subscription
- store subscription in 'SubscriptionTable'[User/Subscription], the may be multiple subscriptions for same user when PWA is running on multiple devices, not sure about this…
- Send notification ->
- store payload in 'NotificationTable'[User] with some options: immediate, scheduled
- Cloud server will push notification according to options to all subscriptions
- SW handle push in the usual way
- Unsubscribe
- PushSubscription.getSubscription() -> subscription
- remove subscription from 'SubscriptionTable'
- SW PushSubscription.unsubscribe(subscription)
Meanwhile I have implemented my own solution DexieCloudNETPushServer.
While the Dexie Cloud part was pretty easy to implement using the Rest API and the great Quartz scheduler library, the on-device part for WebPush gives many headaches. On the desktop, Chrome and Safari work fine most of the time, but mobile Safari has many quirks. There are some open WebKit issues, but I have little faith that they will be resolved soon.
On iOS, my solution now works most of the time, but I suspect the service worker sometimes crashes or duplicates. Also, from time to time some syncs fail with WebSocket connection to 'wss://xxxxxx.dexie.cloud//changes?...failed: The operation couldn’t be completed. Operation timed out, but this happens rarely.
I now have a kind of deeper insight into the problem, which might help to develop something for DexieCloud. With my architecture I couldn't succeed in having one database for synchronization between sw and DOM, so I added a small helper DB that adds notifications on sw side and has liveQueries on DOM side.
Replacing the PushServer with something native to DexieCloud would remove some pulling stress. I didn't want to send some messages from the client to the PushServer, which means I have to pull from my databases on a regular and small interval to check if some new push triggers have been added.
The PushServer runs inside a Docker container on my Synology and uses a 1 minute polling interval. No problems so far.
By the way. It would be very helpful for my solution having a Rest API call returning the timestamp of the last change for a given url and table name.
By the way. It would be very helpful for my solution having a Rest API call returning the timestamp of the last change for a given url and table name.
I'll do my best to fix it, it should be pretty easy. Please send me a reminder if I forget about it.
I'll do my best to fix it, it should be pretty easy. Please send me a reminder if I forget about it.
Back from holidays 🏖️. Here the requested friendly reminder to implement the API if you find some time.
Thanks for the reminder. It's in the current backlog. Currently much focus on Yjs support to be finalized first.
Any timeframe for this request?
Any news?