Search code examples
iosiphoneswiftterminate

programmatically force killing another app on iPhone device


I'm developing two iphone apps suppose - App A and App B and both apps need not run simultaneously due to some reason.

Now my question is - Is it possible for App A to kill App B in iOS programmatically using Swift ? If yes.. does apple allows it or not ?

As per below apple link...i'm not sure is it possible or not : https://developer.apple.com/library/ios/qa/qa1561/_index.html

Thanks,


Solution

  • You can kill an app by calling the private method terminateWithSuccess from UIApplication, like this:

    UIApplication.sharedApplication().performSelector("terminateWithSuccess")
    

    But please, don't do this.

    Also, this it's not allowed by Apple.

    Never quit an iOS app programmatically. People tend to interpret this as a crash. If something prevents your app from functioning as intended, you need to tell users about the situation and explain what they can do about it. 1

    Killing another app from an app that's currently in the background is not possible as far as I know.