Answer the question
In order to leave comments, you need to log in
How to track PWA closures?
There is a PWA application. Is there any way to track the fact of its closure? Ie PWA exchanges with the server. Since the channel between the PWA application and the server is not stable (mobile Internet), you have to hold the "session". That is, when the Internet actually disappears, the server thinks that everything is OK and continues to hold the session. When the Internet appears, the client connects to the same session and everything continues. BUT!!
If the user simply CLOSE PWA (literally like an applicuhu ... shoot), then the session will hang in vain for a long time. What is not good ..... Is there any mechanism for detecting PWA closure??
Or, at the very least, is it possible, somehow, with the help of service workers, to exchange with the snake server when the PWA is closed?
Answer the question
In order to leave comments, you need to log in
In the event of a kill, PWA will not have time to do anything. With the same success, you can literally shoot the phone with a firearm or throw it in acid.
Just find a balanced figure for how long to keep a session. Depends on the cost of creating and maintaining a session.
A slightly smarter option, if creating a session is expensive, is to make a cache on the server side specifically for sessions, so as not to delete them immediately, but also not to fully support them. And if the user returns, then with minimal cost to restore the session.
And an even smarter option is to somehow track the (conditionally) "character" of the user. For example, if you log in and close, then the session is deleted pretty quickly. And if he returned in an hour, or the next day, then transfer the user to the "active" status, and for him, in general, a timeout can be set for a couple of days. Well, again, in the case of a high cost of creating a session. To be honest, it's hard for me to imagine a task where the price is so high as to bother like that.
You can track the application's hit by a separate service running in the background (attention - battery), it can also report this fact with a separate connection (a simple http get request).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question