How to exit app and return to home screen in iOS 8 using Swift programming

后端 未结 6 1880
猫巷女王i
猫巷女王i 2020-12-16 12:30

I\'m trying to programmatically return to the home screen in an iOS8 App using Swift. I want to continue the application running in the background though. Any ideas on how

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-16 12:46

    To force your app into the background, you can legally launch another app, such as Safari, via a URL, into the foreground.

    See: how to open an URL in Swift3

    UIApplication.shared.open() (and the older openURL) are a documented public APIs.

    If you set the exits-on-suspend plist key, opening another app via URL will also kill your app. The use of this key is a documented legal use of app plist keys, available for any app to "legally" use.

    Also, if your app, for some impolite reason, continues to allocate and dirty large amounts of memory in the background, without responding to memory warnings, the OS will very likely kill it.

提交回复
热议问题