objective-cnsurlconnectionhome-button

What happens when the user hits the home button?


I have an app which can currently communicate with an server. Imagine the following case:

  1. User hits some buttons which triggers an server request.
  2. The request is send to the server and is processed.
  3. The user hits the home button (and maybe removes the app from the memory by hitting the home button two times).
  4. The script is done processing and returns it result.

Question: Will the device from the user gets this response (I am pretty sure it will not when removing from memory, but what when just closing the app)?


Solution

  • There are 5 active states in iOS:

    On your third scenario where the user hits the home button, the app will be sent into the Background state, #4, and can still receive data and allow your script to run. If the user kills the app, (state #1) your script will not complete running.

    So, to answer your question, yes your app will continue executing code if the user places it in the Background state, but not if they close the app because that will put your app in the Not Running state.