开发者

iOS Killing my background task after 600 secs

I'm developing an app that needs background task updating location every 30 mins. I've tried to use a NStimer and updating every minute and it works (it spent 2 hours working). However, when I set it for 30 mins, iOS kills my app after 10 mins.

The log says:

Sun Oct 16 11:29:47 unknown SpringBoard[32] <Warning>: MyApp[315] has active assertions beyond permitted time: 
    {(
        <SBProcessAssertion: 0xbb34040> identifier: UIKitBackgroundCompletionTask process: MyApp[315] permittedBackgroundDuration: 600.000000 reason: finishTask owner pid:315 preventSuspend  preventIdleSleep 
    )}
Sun Oct 16 11:29:47 unknown SpringBoard[32] <Warning>: Forcing crash report of WhereAreYouReg[315]...
Sun Oct 16 11:29:48 unknown SpringBoard[32] <Warning>: Finished crash reporting.

My background task is started with this code:

backgroundTaskIdentifier = [[UIApplication sharedApplication]
                   beginBackgroundTaskWithExpirationHandler:^{
                       // If you're worried about exceeding 10 minutes, handle it here
                   }];
    theTimer=[NSTimer scheduledTimerWithTimeInterval:30*60.0
      开发者_运维知识库                                        target:self
                                            selector:@selector(updateLocation)
                                            userInfo:nil
                                             repeats:YES];

updateLocation starts updating location and when location is received, it stops updating location for saving battery.

How is supposed to do this background task? Any help for prevent killing my app after 600 secs?

Thank you very much!


You can't. There is no way to create a background task running longer than 10 minutes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜