你好在后台吗?
我注意到 Pasteboard(iOS 的剪贴板应用程序)可以在后台运行 Bonjour 服务。我不知道他们是如何实现的,所以我在互联网上搜索,然后发现它在后台播放无声声音文件。但现在情况并非如此,因为我在 iPod 管理屏幕上看不到应用程序图标。他们怎么能这么做呢?有什么想法吗?先感谢您。
凯。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
理论上,您可以将您的应用程序标记为 需要在后台连续运行(用于 VoIP 或映射)。我在概念验证中做了一些事情,效果很好。
或者,此文档 似乎记录了如何在后台进行联网。
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.
在暂停之前取消任何 Bonjour 相关服务。当您的应用程序移至后台时,在挂起之前,它应该从 Bonjour 取消注册并关闭与任何网络服务关联的侦听套接字。无论如何,暂停的应用程序都无法响应传入的服务请求。关闭这些服务可以防止它们在实际上不可用时看起来可用。如果您没有自行关闭 Bonjour 服务,系统会在您的应用暂停时自动关闭这些服务。
https://developer.apple.com/库/archive/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
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