iPhone应用程序后台网络通信
是否有可能有一个 iPhone 应用程序,当用户将数据发送到后台时,该应用程序会继续监听端口上的数据,并且如果有任何数据到来,该应用程序可以显示本地通知并提醒用户?我知道多任务处理是故意限制的,但它允许这样做吗?
Is it possible to have an iPhone app which carries on listening for data on a port when it is sent to background by the user and if any data comes the app can show a local notification and alert the user? I know the multitasking is deliberately limited but wof it allow for that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它可以,但有一些重要的警告:
因此,虽然您可以在后台绑定和侦听套接字,但出于几乎所有实际目的,这是不值得做的,您应该重新考虑您的设计。
It can but with major caveats:
So, while you could bind and listen on a socket in the background, for almost all practical purposes, it's not worth doing and you should rethink your design.
这正是推送通知的用途。您的应用程序不会监听您的服务器,您的服务器会告诉 Apple 任何通知,而 Apple 的服务器会将这些通知传送给用户和您的应用程序(如果用户需要)。
This is exactly what push notifications are for. Your application doesn't listen to your server, your server tells Apple's about any notifications, and Apple's server delivers them to the user and your application if the user wants them.