Oddbean new post about | logout
 @brugeman what black magic did you use to make nsec.app so incredibly persistent in the background when installed as a PWA? Can you help me make cashu.me as persistent as nsec.app so I can make NWC zaps while the wallet is closed / in the background? 
 He is a dark lord of background tasks  
 It asks to enable push notifs, then sends the push endpoint to server along with pubkey and relay, server monitors the pubkey on relay for unanswered nip46 messages, when detected sends a push to wake up the service worker.

Nwc flow is quite similar, so it should be possible to have the same thing there.

Server side is https://github.com/nostrband/noauthd - not a beautiful piece of code, but can be an inspiration.

You'll also need strfry or other relay that stores ephemeral events for a while so that woken up service worker could fetch them.
 
 sadly I know too little about push notifications in PWAs. 
but on iOS I think this will be hard. There are no silent push notifications and the app has to be active I think.  
 I just tested some things and was surprised how far the PWA world has come. I could wake my Android phone (display turned off) through a push notification through a PWA. 🤯 Try it yourself: 

https://simple-push-demo.vercel.app/