In your AppDelegate.m file, this method will be called when the user clicks the "Home" button and the application goes into the background (here you can save your connection live, but you have to read the apple documentation regarding background tasks because your application does not can live forever if the application remains in the background, there are other ways to update your application, such as updating in a push notification, etc.):
- (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. }
and this method will be called when the application is completed (completely closed from multitasking).
- (void)applicationWillTerminate:(UIApplication *)application {
You can process your connections with these methods.
Nikos M.
source share