iPhone:重复后台任务
我正在寻找推送通知的替代方案。我希望我的应用程序定期连接到服务器并检查某种后台任务中的新消息。如果发现新消息,我可以使用本地通知来通知用户,但据我所知,Apple 不喜欢在后台运行的应用程序。
有没有某种方法可以安排代码以某个设定的时间间隔运行,即使应用程序处于后台或完全关闭? (对于那些了解 Android 的人来说,我正在寻找诸如 BroadcastReciever 和 Service 之类的东西)如果我能做到这一点,它将解决我所有的问题。
蒂亚!
PS:我们正在为 iOS 4+ 开发
I am looking for alternatives to push notifications. I would like my app to periodically connect to the server and check for new messages in some kind of background task. If new messages are found I can use Local Notifications to inform the user, but as far as I know Apple doesn't like apps running in the background.
Is there some way to schedule code to run at some set interval, even when the app is in the background, or shutdown completely? (for those of you who know Android, I'm looking for something like BroadcastReciever and Service) If I could do that it would solve all my problems.
TIA!
PS: we are developing for iOS 4+
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,iOS 中没有一个好的机制来做到这一点。您仅有的两个选择是使用位置服务 (significantLocationChange) 在设备移动时在后台收到通知,或者假装是 VOIP 应用程序,在这种情况下您可以按指定的时间间隔请求处理时间。不过,第二种方法不会让您的应用程序获得 App Store 批准。
There isn't a good mechanism in iOS to do this unfortunately. Your only two options are to use the location services (significantLocationChange) to get notified in the background when the device moved, or pretend to be a VOIP app in which case you can request processing time at a specified interval. The second method won't get your app approved for the App Store though.