dexie / Dexie.js

A Minimalistic Wrapper for IndexedDB
https://dexie.org
Apache License 2.0
11.37k stars 640 forks source link

WebPush for DexieCloud Feature Request #1986

Open b-straub opened 4 months ago

b-straub commented 4 months ago

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.

b-straub commented 1 month ago

Meanwhile I have implemented my own solution DexieCloudNETPushServer.

ServiceWorker

DOM

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.

b-straub commented 1 month ago

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.

dfahlander commented 1 month ago

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.

b-straub commented 2 weeks ago

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.

dfahlander commented 1 week ago

Thanks for the reminder. It's in the current backlog. Currently much focus on Yjs support to be finalized first.