Today Extension and background audio

a 夏天 提交于 2019-12-11 09:58:54

问题


I am trying to do a simple podcast-like widget for iOS 8. Things works fine, audio works... except that when the screen sleep, the audio stops.

Can Today Extension do background audio? Or multitasking in general?


回答1:


No. Today Widget is destroyed when it goes out of view (as evidenced by viewDidDisappear).. so sound can only be enabled when the widget is physically in view.

Edit: Nope it is linked to the host app that runs it. As detailed in Apple documentation, an extension is a specialized binary that is delivered through a containing app. The containing app is only used for delivery and the extension runs independently of it. This notwithstanding, an iOS containing app is required to effectively provide some functionality in addition to the extension. On OS X such requirement is relaxed and a containing app is not required to provide any additional functionality.

As mentioned, an extension life cycle is completely unrelated to its containing app's and it comprises 4 steps:

User chooses an app extension. System launches it. App extension runs. System kills app extension.

http://www.infoq.com/news/2014/07/apple-ios8-app-extensions




回答2:


As @ktzhang mentioned, background audio isn't available to extensions.

However, some limited multitasking is possible, the documentation says you "can set up a background URL upload or download task" in an extension.



来源:https://stackoverflow.com/questions/25095687/today-extension-and-background-audio

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