Bonjour in the Background?

老子叫甜甜 提交于 2019-12-06 07:19:58

问题


I noticed that Pasteboard, a clipboard app for iOS, can run Bonjour service in the background. I've no idea how they implement that, so I searched on the Internet and then found that it plays a silent sound file when in background. But it is not true now, because I can't see the app icon on the iPod management screen. How could they do that? Any ideas? Thank you in advance.

Kai.


回答1:


You could, in theory, mark your application as needing to run in the background continuously (for VoIP, or mapping). I've done something this in a proof of concept and it worked great.

Alternatively, this document seems to document how to do networking in the background.




回答2:


Cancel any Bonjour-related services before being suspended. When your app moves to the background, and before it is suspended, it should unregister from Bonjour and close listening sockets associated with any network services. A suspended app cannot respond to incoming service requests anyway. Closing out those services prevents them from appearing to be available when they actually are not. If you do not close out Bonjour services yourself, the system closes out those services automatically when your app is suspended. https://developer.apple.com/library/archive/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html



来源:https://stackoverflow.com/questions/6345554/bonjour-in-the-background

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