title: iOS how to detect when app was removed from process
body: <p>What is the delegate method for detecting when application was closed.</p>
  
  <p>I mean when user tap this button:</p>
  
  <p><img src="https://i.stack.imgur.com/Zlilt.png" alt="enter image description here"></p>
  
  <p>I know about method below:</p>
  
  <pre><code>- (void)applicationDidEnterBackground:(UIApplication *)application;
  
  - (void)applicationWillEnterForeground:(UIApplication *)application;
  </code></pre>
  
  <p>But they work not as I expected in my case. For example I have used my app and I have navigated to some screen. In case when I lock screen and go back to app the app calls applicationWillEnterForeground but I don't need this, because I am still on this view (for example Test Screen View)and I don't need to check any changes. But in case if my app closed I begin to navigate from start app for example Home Screen. So if my app was closed and I am on Home Screen I need to check if in previous time I had some actions (for example if I passed test on Test Screen View) and present this view controller (ONLY IN CASE IF I CLOSED APP NOT JUST LOCKED IT OR ENTER BACKGROUND).</p>
  
  <p>Thanks for help.</p>