cybergeeeek
cybergeeeek

Reputation: 430

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,

Upvotes: 0

Views: 1737

Answers (2)

fdiaz
fdiaz

Reputation: 2600

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.

Upvotes: 0

hotpaw2
hotpaw2

Reputation: 70693

If both apps have the documented UIApplicationExitsOnSuspend key set in their app plist, then only one can be running at a time, since neither can run in the background. If a user launches one app, the OS will kill the other app.

Upvotes: 5

Related Questions