-2

In my app I am having a continuous communication with TCP server , now if
server sends a command to close the app, i want to close the app completely
and when user taps the app again, it should start with Application launch method itself.

I have tried using exit(0) in the code, using this application goes into background.But it doesn't kill the app. How can i do that?

Nitya
  • 449
  • 1
  • 8
  • 24
  • Why do you think that calling `exit` sends the app to the background? `exit` will definitely kill the app. But you are not supposed to call `exit` anyway. Your app may not be accepted by Apple if you do. – rmaddy Jan 10 '14 at 17:19
  • Note that Apple specifically disallows your app to kill itself/exit, and you will be rejected from the app store for this. – Linuxios Jan 10 '14 at 17:19
  • Per Apple "There is no API provided for gracefully terminating an iOS application." https://developer.apple.com/library/ios/qa/qa1561/_index.html – Marco Jan 10 '14 at 17:26
  • This app is not for apple store. It will be used internal to my company. – Nitya Jan 10 '14 at 17:36
  • I think the app remains in background because if i double click the home button, it shows me my app there. If its killed, it should not be there – Nitya Jan 10 '14 at 17:37
  • @Nitya That's not true. The list of apps shown when you double-click the home button is a list of "recently-used-apps", not a "currently running list". Believe me, calling `exit` definitely terminates your app. – rmaddy Jan 10 '14 at 17:38
  • 1
    Did you actually try clicking on the app to launch it again to see if you saw your launch image or not? – Gavin Jan 10 '14 at 17:48

1 Answers1

4

There isn't a way. Apple doesn't allow it. The solution is: Just accept the fact that you are unable to do this and work around that fact.

Gavin
  • 8,204
  • 3
  • 32
  • 42
  • While this is true this doesn't address the question. The question claims that calling `exit(0)` puts the app in the background. – rmaddy Jan 10 '14 at 17:37
  • @rmaddy You are right. It actually kills the application. – Nitya Jan 10 '14 at 20:33