我可以使用[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