Hans Terje Bakke
Hans Terje Bakke

Reputation: 1752

iOS detect app closed

I am looking for a state between background operation and termination.

My app needs to allow the user to turn off the screen by pressing the on/off/sleep/wake button. Audio and location detection should proceed in the background, while all visuals are inactive. (Pressing this button causes the DidEnterBackground and WillResignActive events.)

However, if the user actively presses the home button to go the the home screen, thus making a choice to actively leave the app, I would like to terminate it.

I can cause the app to terminate by turning off what is keeping it running in the background (ambient sound, etc.). But I need a way to detect that the user has "left" the app.

Is there a way to detect this?

Upvotes: 0

Views: 322

Answers (1)

beyerss
beyerss

Reputation: 1352

No - Apple does not provide a way to distinguish between turning the device screen off via the power button or leaving the app via the home button. The application life cycle (as you referred to with DidEnterBackground) is all we have.

Upvotes: 1

Related Questions