Simulating Background App Termination on iOS devices

Lee Kah Seng
2 min readJun 25, 2017

--

Recently I was helping my client to update their app so that some operation will be executed before the app is terminated. After few hours of coding, is time for testing… There will be 2 situations that we need to test:

  1. Force termination trigger by user.
  2. Background termination trigger by the system.

The 1st situation is pretty easy to test, just double tap the home button and swipe up to terminate the app.

Swipe up to terminate

But how do we test the 2nd situation? Can we ask Siri to do that for us? Obviously no… Can we run some resource heavy games and hope the system will trigger the app termination? Yes we can, but this method is not reliable and way too troublesome. 😭

After some Googling, apparently we can force the system to free up the RAM and indirectly triggering background app termination. Do note that this method can only work on a real iOS device and not the iOS simulator. Here’s what you need to do:

  1. Make sure your iOS device is at the home screen and unlocked.
  2. Long press the power button until you see “slide to power off”.
  3. Release the power button and long press the home button for about 5s (until you see your home screen reappeared).

That’s it! Try to run your app now, you will notice that your app has been terminated and relaunching.

This method really helped me when testing background termination on my client’s app. Hopefully this will be helpful to others iOS developer as well.

Please do not hesitate to hit the 👏 button if you like this article. 😄

--

--

Lee Kah Seng
Lee Kah Seng

Written by Lee Kah Seng

Support me by becoming a Medium member: https://leekahseng.medium.com/membership ⦿ 🇲🇾 Creator of https://swiftsenpai.com ⦿ iOS developer since 2011

Responses (7)