当我的应用程序关闭时是否可以运行后台线程
我希望当我的应用程序关闭时在后台执行一些操作。 ios上可以吗
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我希望当我的应用程序关闭时在后台执行一些操作。 ios上可以吗
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
简短回答; 是可以让应用程序在后台运行。
如果您通过按主页按钮关闭应用程序,则应用程序将被“冻结”,除非您指定它应在后台运行。但有一些限制,请参阅下面我的解释。
如果您终止该应用程序,它就不可能在后台运行。当你杀死它时,任何应用程序都不会生存。杀戮是这样进行的;双击主页按钮,然后长按该应用程序。最后按下应用程序。这将终止该应用程序。
最大的限制是您的应用程序需要是某种类型,否则不允许在后台执行。这是在 Info.plist 文件中指定的。具体来说,您需要在 Info.plist 文件中添加 UIBackgroundModes。如果它是另一种类型的应用程序并尝试在后台运行,则该应用程序将被拒绝在Appstore中发布。
以下是允许在后台执行的应用程序类型:
然后,应用程序需要遵循某些规则。一切都有解释此处。
Short answer; YES it is possible to have an application running in the background.
If you close the application by pressing the home button, the application is "freezed" unless you specify it should run in the background. But there are some limitations, see my explanation below.
If you kill the application, it is not possible for it to run in the background. No application will survive when you kill it. Killing is done like this; double-click the home button and then long press the application. Finally you press the application. This will kill the application.
The biggest limitation is that your application needs to be of certain type, otherwise it is not allowed to execute in the background. This is specified in the Info.plist file. Specifically you need to add the UIBackgroundModes in the Info.plist file. If it another type of application and try to run in the background, the application will be rejected for publishing in Appstore.
These are the types of applications that are allowed to execute in the background:
Then there are certain rules that the application needs to follow certain rules. Everything is explained here.