Randy Randy - 1 year ago 66
iOS Question

Is there a way to know when my app switches from Suspended to another state?

I'm having issues with my

s'cache being purged sometimes when a user hasn't been using my app for a while.

I guess, that's because iOS puts my app in
and then a low-memory condition occurs so my app is purged.

I read Apple's documentation about The App Life Cycle - Execution States for Apps

Especially the part describing the
state :

Suspended - The app is in the background but is not executing code. The system
moves apps to this state automatically and does not notify them before
doing so. While suspended, an app remains in memory but does not
execute any code. When a low-memory condition occurs, the system may
purge suspended apps without notice to make more space for the
foreground app

Two questions here :

1) What does "purge" mean exactly ? The app is killed ? Or does it still appear on the app selector ( when double-tapping the home button )

2) Here we can see that there is no way to know when an app is going to be suspended. All right. But if a user comes back to the app, is there a way to know, then, that the app has been suspended ? I can't find any
's method to do so, but there might be another solution ?

Answer Source

Purge - The purge command forces disk and memory caches to be emptied, offering a ‘cold disk buffer cache’ which is similar to the state of the operating system after a reboot.

Referenced from here

As per the documentation

applicationDidEnterBackground:—Lets you know that your app is now running in the background and may be suspended at any time.

This is the only method which will let you know that method may will enter in Suspended State


application:didFinishLaunchingWithOptions: will let you now that your app's launch process is almost done and the app is almost ready to run.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download