I'm building an Android game which requires the user to be online while playing. I'd like to detect if a game was interrupted while playing ( the internet connection was lost \ the device was turned off, etc...),and if it was - this should be considered as a loss for the user, and be written in the database. The only thing I have in mind for now is to save this loss offline, and update it when the user goes back online.
I know I can detect app connection status like this, but it doesn't help be because I can only execute offline operations after this. I also know I can listen to writing events in the database like this, but it doesn't help me, because no child in being updated after the game is interrupted.
My question is: Is there a way to write a Cloud Function which can listen to specific app connection status? If there is no such a way, what are the other options I have?