0

I need to show a push notification once a week, even when the user is not on the page. I know it is possible to use service workers to push a notification based on a "feed", but I don't know if it is possible to push a notification at a specific date.

If it is possible, how could it be done with PHP (, if needed, and JavaScript, of course)?

D. Pardal
  • 6,173
  • 1
  • 17
  • 37

1 Answers1

1

Assuming you're okay with using Firebase, one approach is to follow the general advice that came up in another question, and customize it for the web:

  • Use Firebase Cloud Messaging's JavaScript SDK to implement your service worker's push message handler in your web clients.

  • "Fake" a cron job by POSTing to a Firebase cloud function, following the example in this sample app. If you already have a PHP server running, that could be used to periodically trigger the Firebase cloud function. Alternatively, you could skip the Firebase cloud functions part entirely, and use your PHP server to trigger the push message directly.

Jeff Posnick
  • 53,580
  • 14
  • 141
  • 167
  • Thanks but I'm not really a fan of using libraries. I'm gonna take a look at it and wait for more answers. – D. Pardal Aug 24 '18 at 08:37