How can I say that my application is going to become inactive / go to background?

I assume that I need to implement:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resignActive:) name:UIApplicationWillResignActiveNotification object:nil]; 

but I'm not sure if this is the correct notification to determine that my application is about to leave an active state.

Is this a good place to cancel network connections along with the termination of the application?

+7
objective-c iphone cocoa-touch nsnotifications multitasking
source share
1 answer

There are cases when the UIApplicationWillResignActiveNotification sent, but the application does not enter the background, for example, if the call is received, but the user does not answer it.

Use UIApplicationDidEnterBackgroundNotification for notification when entering background. Keep in mind that this will sometimes be sent after the UIApplicationWillEnterForegroundNotification if the application is quickly opened.

+11
source share

All Articles