Summary from here.

The foreground app always has precedence over background apps when it comes to the use of system resources and hardware. Apps running in the background need to be prepared for this discrepancy and adjust their behavior when running in the background. Specifically, apps moving to the background should follow these guidelines:

  • Do not make any OpenGL ES calls from your code.
  • Cancel any Bonjour-related services before being suspended.
  • Be prepared to handle connection failures in your network-based sockets.
  • Save your app state before moving to the background.
  • Remove strong references to unneeded objects when moving to the background.
  • Stop using shared system resources before being suspended.
  • Avoid updating your windows and views.
  • Respond to connect and disconnect notifications for external accessories.
  • Clean up resources for active alerts when moving to the background.
  • Remove sensitive information from views before moving to the background.
  • Do minimal work while running in the background.

When the user presses the Home button to quit the app, the applicationWillTerminate: method of the app delegate is called and the app has approximately 5 seconds to clean up and exit before it is terminated and moved back to the not-running state.



评论需要翻墙 for disqus