Hey , I am building a game with firebase and I want to run a coroutine when the player is not in focus or pause
the OnApplicationPause does work but I can’t run the coroutine
is there a way for me to run the coroutine a bit before the app paused on mobile
Realistically you will likely only get one frame to do anything in OnApplicationPause.
You might get more depending on operating system and the reason for the application exit (eg, some mobile phones MIGHT let you run a few frames), but you really cannot even guarantee you’ll even get the actual OnApplicationPause, such as if the operating system panics or crashes or otherwise has to eject your process suddenly.
Oh, right, this is on a mobile platform. I have limited experience here, but aren’t applications generally very restricted in what they can do when they put in the background?
I would check that OnApplicationPause is even getting called, though, by logging something after starting the coroutine.
Thank you, the thing is sometimes players will exit the game via the mobile buttons and not from the menu
when they do that I want to run this coroutine to let the other players know that the user is not there anymore
my second option is to run the coroutine for everything someone minimizes the game and then save it to a list
and run the things that I need with this list