Detect Application States
I want to detect application states and send it to the server. In the new OS4, with multitasking there are some methods available to help detecting the states:
- application:didFinishLaunchingWithOptions:
- applicationDidBecomeActive:
- applicationWillResignActive:
- applicationDidEnterBackground:
- applicationWillEnterForeground:
- applicationWillTerminate:
I read that now, we have to use applicationDidEnterBackground instead of applicationWillTerminate. My problem is that i need them both.
When the user send the app to the background, it has the state sleep. But when the user close the app ( from the multitask bar ) the state is closed. So i need to detect both, when the user send the app to the backgr开发者_如何学运维ound and when the user ( or the system ) close it.
Is there anyway or workaround to make this?
I try subscribing to UIApplicationWillTerminateNotification but it doesn´t work.
Thanks in advice.
The application will quit notification is no longer fired on iOS 4 (as I am led to believe).
When the user hits the home button, the app is sent to the background, and you will get the did enter background notification. But when a user closes the app from the multitask bar, or if the system closes it, the app is sent a SIGKIL
message and quits immediately, firing no notifications or delegate methods.
精彩评论