Search Unity

Question Event for app resume when Run In Background = false?

Discussion in 'Web' started by Gordon_G, Feb 16, 2023.

  1. Gordon_G

    Gordon_G

    Joined:
    Jun 4, 2013
    Posts:
    372
    Hey all, is there a way to determine when an app starts running again after it has been suspended/paused because the browser or page became inactive? Is there an event message sent when an app starts running again?

    There is no reliable way to do this in javascript - you can test if a browser tab has become visible, but there no way to discover other types of deactivations/activations (eg. the browser is put into the background and then made the foreground task again).

    We need to determine if the user has left the webpage open for more than 24 hours, at which time we want to refresh some of our WebGL app's data. If we could get some kind of event message when the app starts running again then we can go to work immediately to determine the elapsed time since the last refresh.

    Without some kind of notification that the app has paused and started up again, I envision we can do something with a coroutine running at a regular interval but that strategy is less desirable... (Or do you see a better way?)

    Thanks for your input in advance!