Hi all,
I am looking into using SSE to send push notifications to a reactive web client. It works perfectly if the user has the browser open, but I need to be able to send a push notification even if the browser is closed.
I can get this functionality by using firebase within a service worker, but I would like to move away from a third party if possible and since I need to only send simple messages from the server to the client, SSE seems like a great fit.
Is it possible to use the component or at least the concepts of SSE with a service worker so that I can receive push notifications in the background without the client browser open?
Kind regards
Stefan
Hi again Stefan,
Unfortunately, however cool the idea is, it does not play well together.
The thing is, Service workers have an intentional short lifespan and the browser will eventually kill the worker if its taking to long.
I will update the docs to be clear about the lack of support for background notifications on both mobile and pwa apps.
Some references:
https://stackoverflow.com/questions/35837967/increase-service-worker-life-time/48992309#48992309
https://github.com/casanet/casanet-server/issues/73
https://stackoverflow.com/questions/61041389/managing-server-side-events-with-a-service-worker
Thank you Nuno,
Yea I thought it might be a long shot but seemed like a cool possibility.
I will use firebase instead, but we will definitely be using the SSE event hub for some other functionality in our applications.
Hi Stefan!
I'm sorry I somehow missed this question,
Let me get back to you on this, I will have a look.
With hybrid(cordova) mobile apps its very tricky and only possible with a background service that is not guaranteed to be accepted by the stores. Its not even guaranteed to have 100% background service availability so I would definitely go with Apple's APN/ Google's FCM approach there.