Is it possible to have my closed app run code in iOS?

天涯浪子 提交于 2020-01-11 05:44:05

问题


Let's say that my app in iOS is closed. Would it be possible to set it up so that it runs a piece of its code after a certain period of time?


回答1:


You can have your app schedule push notifications, but you can't schedule it to run specific code unless it's running.




回答2:


Short answer: no, you can not. At the most, your application will keep running in the background for 11 minutes, if you request the extra time (check the documentation for beginBackgroundTaskWithExpirationHandler on the UIApplication class). There are some things you can do: Schedule a local notification, which the user can use to launch the app, or use push notifications to remind the user of something he needs to know.




回答3:


iOS allows background processing for the following reasons: - location dependent functionality - background audio playback - voip

You can find out more from Apple's multitasking documentation



来源:https://stackoverflow.com/questions/8611921/is-it-possible-to-have-my-closed-app-run-code-in-ios

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