我可以使用[locationManager startUpdatingLocation]
在后台获得GPS位置,但我不知道如何安排它。我已经使用NSTimer进行调度,但其中许多人都说如果应用程序进入后台,NSTimer将会过期。我们可以用什么来代替nstimer?
我想知道如何调度方法,如果我们不使用NSTimers。
我可以使用[locationManager startUpdatingLocation]
在后台获得GPS位置,但我不知道如何安排它。我已经使用NSTimer进行调度,但其中许多人都说如果应用程序进入后台,NSTimer将会过期。我们可以用什么来代替nstimer?
我想知道如何调度方法,如果我们不使用NSTimers。
Apple提供5种应用程序任务在后台运行:
- 应用程式播放音频内容给用户,同时在后台运行,如音乐播放器应用程序
- 应用程序,使用户在任何时候,他们的位置的通知,如导航应用
- 应用程式支持互联网语音协议需要下载和处理新的内容,从外部附件接收定期更新
- 应用(VoIP)的
- 书报亭应用
Refer this link for location updates while app is in background
我们可以利用推送通知,而不是的NSTimer调度,如下所示: -
希望它helps.Thanks :)
我认为你可以这样做:
[self performSelector:@selector(_yourMethod) withObject:nil afterDelay:delay_in_milliseconds];
在背景中,方法不会工作 – DivineDesert 2012-04-16 11:38:45
检查了这一点-http://stackoverflow.com/questions/3388781/scheduling-task-in-iphone – rishi 2012-04-16 06:00:16
我不想去本地/远程推送通知,我想安排它。在那个用户提到使用scheduledTimerWithTimeInterval,我在我的应用程序中使用 theTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(Location)userInfo:nil repeats:YES]。计时器将不会过期?? – Perseus 2012-04-16 06:07:33
我没有得到答复:( – Perseus 2012-04-16 06:22:37