简体   繁体   English

iPhone:重复后台任务

[英]iPhone: repeating background task

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. 如果发现新消息,我可以使用本地通知来通知用户,但据我所知,Apple不喜欢在后台运行的应用程序。

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. (对于那些了解Android的人,我正在寻找像BroadcastReciever和Service这样的东西)如果我能做到这一点,它将解决我所有的问题。

TIA! TIA!

PS: we are developing for iOS 4+ PS:我们正在为iOS 4+开发

There isn't a good mechanism in iOS to do this unfortunately. 不幸的是,iOS中没有一个很好的机制来实现这一点。 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. 您唯一的两个选择是使用位置服务(significantLocationChange)在设备移动时在后台获得通知,或者假装是VOIP应用程序,在这种情况下您可以按指定的时间间隔请求处理时间。 The second method won't get your app approved for the App Store though. 第二种方法不会让您的应用程序获得App Store批准。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM