GoodDollar / GoodDAPP

GoodDollar.org Wallet is the simplest access point to Claim your daily G$. It Is based on web3 and React native web.
good-dapp.vercel.app
MIT License
108 stars 55 forks source link

Research: service workers / background fetch #3767

Open johnsmith-gooddollar opened 2 years ago

johnsmith-gooddollar commented 2 years ago

Currently we have service worker auto generated by the workbox. It manages web app caching and updating

alt-a1r commented 2 years ago
johnsmith-gooddollar commented 2 years ago

we already using RNBackgroundFetch. please check how it implemented does it working and will it be suitable for this task

please look how we could add custom code to the SW generated by the workbox

  • the only way to communicate with SW is by messaging, so we can emit messages on wallet events which we listen to and add the appropriate listener inside the worker itself, thus using it as something like a reducer with action types. To implement this, we can use Broadcast Channel API (https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API) or MessageChannel API. But not sure that solution will works correct with foreground state.

i've already done with this: #3766

  • possible solution for execute it in background can be next libraries: react-native-background-job react-native-background-task

should be service worker

sirpy commented 2 years ago

@johnsmith-gooddollar webworkers are irrelevant we need service worker in any case I suggest to first get Android/iOS working as we already have the boilerplate code for that then start with browser notifications

sirpy commented 2 years ago

@alt-a1r @johnsmith-gooddollar @patpedrosa

  1. for web notifications it is not possible to wakeup the service worker unless using "push notifications" or the new experimental "periodicsync" API
  2. on Safari browsers notifications are pretty new and only supported in the latest safari and macos 13

see: https://stackoverflow.com/a/29750936/6379521

and see https://whatwebcando.today/scheduler.html

My suggestion as mentioned elsewhere is to hold on with web notifications. And in the first phase for web support only claim reminder only for Chrome with the periodicsync api

johnsmith-gooddollar commented 2 years ago

@sirpy should we proceed with Chrome + periodicsync to implement claim notifications on web ?

sirpy commented 2 years ago

discuss with Pat. perhaps as part of goodswap.xyz

sirpy commented 1 year ago

no good solution for web at the moment.

johnsmith-gooddollar commented 1 year ago

@sirpy I've done MVP using Firebase messaging for deliver pushes some time ago. Have you looked onto it ?

https://github.com/GoodDollar/ScheduledNotifications