Which event is called when iOS app is swiped from app switcher?

1.1k views Asked by At

I was wondering which event in my AppDelegate is called when I swipe out my running app from within the app switcher? My target iOS is >= 7.0 (i.e. with multitasking support).

Maybe I just don't understand the multitasking paradigm itself... When I swipe out my app from within the app switcher, the app is going to be terminated, right? Or does it continue running in the background?

EDIT-1: Why I am asking: During startup of the app, I connect to my Linux game server by plain sockets. I want to disconnect the socket when the app terminates.

EDIT-2: I am not sure if I am using background execution. I register my network socket within a run-loop object to asynchronously receive inputs from the server socket. Moreover I have a kind of network service installed that periodically tests for network connectivity. This service is using SCNetworkReachabilityScheduleWithRunLoop.

2

There are 2 answers

5
Vijay Tholpadi On BEST ANSWER

There are situations where applicationWillTerminate: will be called and sometimes not.

More can be read up from the Apple documentation here

Excerpt:

For apps that do not support background execution or are linked against iOS 3.x or earlier, this method is always called when the user quits the app. For apps that support background execution, this method is generally not called when the user quits the app because the app simply moves to the background in that case. However, this method may be called in situations where the app is running in the background (not suspended) and the system needs to terminate it for some reason.

What's interesting to note is that

After calling this method, the app also posts a UIApplicationWillTerminateNotification notification to give interested objects a chance to respond to the transition.

3
Ankit Sachan On

It is - (void)applicationWillTerminate:(UIApplication *)application