Send App to Background process

笑着哭i 提交于 2019-12-02 17:32:26

问题


We do not want to use exit(0) to make the app close, we do however want to allow the app to go to background programmatically and process away, per users allowing this action. Is there a way to send the app to the background programmatically without exit? Simulating the click of the home button?

Thank in advance!


回答1:


Not possible. Home button clicks run into the private GSEvents framework. It's exit() or none unfortunately.




回答2:


Is there a way to send the app to the background programmatically without exit?

No. The user is supposed to be in control of the app -- the app shouldn't move to the background (or exit) of its own accord.




回答3:


The below code can be used to send iOS app to background programatically without exit

DispatchQueue.main.async {
        UIApplication.shared.performSelector(inBackground:NSSelectorFromString("suspend"), with: nil)
    }


来源:https://stackoverflow.com/questions/9970221/send-app-to-background-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!