greymass / unicove

Unicove 2.0
https://unicove.com
GNU Affero General Public License v3.0
2 stars 1 forks source link

Progressive web app #243

Open deansallinen opened 1 week ago

deansallinen commented 1 week ago

Using the Vite PWA plugin for SvelteKit, we can create a service worker and manifest.

We can then start using the service worker to run data synchronization in the background, off the main thread, to fetch updated network and account data on a regular interval, for example. Or to fetch account activity pre-emptively when landing on the account overview page.

We can also enable installing as an application, which will cache pre-rendered pages to the user's device and enable "offline" mode.

A service worker would also open up the Push API if we wanted to send notifications to the user (e.g. on new activity)

sandroguras commented 1 week ago

I looked into this PWA plugin, v0.1.0, which is currently in a very early stage. Its main benefit is that you can tweak the PWA setup from a single source. Without the plugin, it's straightforward to create a service worker, manifest, and set of icons, so I'm not sure we need another dependency for this task.

aaroncox commented 1 day ago

I know we talked about a couple of the challenges with this on slack already, but figured I'd just repeat some of them here as well.

Anchor on mobile is really the only wallet this would be compatible with as well, since most of the other mobile wallets use in-app/wallet browsers. A PWA installed Unicove wouldn't open in those other wallets and they'd always just be in the browser version.

Routing between Unicove and Anchor is also going to be difficult.

The reason is because we'd need to do something with the callback URLs from the ESR payloads that lets Anchor, once it completes a request from the Unicove PWA, to then route back to the PWA. The only way on iOS this is possible (I think) is by using a custom URI (like we have for anchorwallet:// or something) to launch another app, or by default we just swap back to whatever the users primary browser is.

I'd bet PWAs don't support registering URI handlers in the OS, so how would Anchor route back to the PWA?

You mentioned Push APIs, but I'm not sure if PWAs could listen in the background with them. If that's possible then maybe there's a way Anchor could somehow trigger a push call somewhere that just triggered the Unicove PWA again. Then it's how do we modify the mobile versions of Anchor to send out this push call? Does it use buoy, and we have some sort of translation layer that takes in that response, converts it to a push call, that notifies Uncove PWA to just open back up?

Ugh 😂