title: Is it possible to get an event when PWA is starting or being switching between apps in iOS safari
body: <p>The problem I am going to solve is when a fullscreen PWA is being brought to background and bring up again, e.g. switching to another app and then switch back or pressing home button and then switch back to the app again, in both case the PWA will be reloaded, previous state is lost. </p>
  
  <p>After googling a bit, the mostly suggested solution is to persist the whole state in localstorage and then load it back when the app being reloaded by safari.</p>
  
  <p>By using that solution, when user closed the app and start again, it will show the previous state when he exited instead of showing the initial state which I would expected.</p>
  
  <p>That's why I wonder if we can tell whether the app is "starting" or "being brought back from app switching". </p>
  
  <p>I tried <code>unload</code>, <code>visibilitychange</code>, <code>pagehide</code>/<code>pageshow</code>, but seems none of them can tell me this information.</p>