I am assuming I need to implement:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(resignActive:)
name:UIApplicationWillResignActiveNotification
object:nil];
but am not sure if this is the right notification to determine my app is about to leave active state.
Is this a good place to cancel network connections, along with app termination?
There are cases where
UIApplicationWillResignActiveNotificationis sent but the application does not enter the background, for example if a call is received but the user chooses not to answer it.Use
UIApplicationDidEnterBackgroundNotificationto be notified when entering the background. Be aware that this will sometimes be sent afterUIApplicationWillEnterForegroundNotificationif the application is quickly opened again.