2014-03-27 36 views
3

崩溃报告细节:iOS7:后台任务( “MYAPP” 已经超出允许的时间积极断言)

Hardware Model:  iPhone5,2 
Exception Type: 00000020 
Exception Codes: 0x000000008badf00d 
Highlighted Thread: 3 

Application Specific Information: 
MyApp[1369] has active assertions beyond permitted time: 
{(
<BKProcessAssertion: 0x175ca7d0> identifier: Called by MyApp, from -[AppDelegate applicationDidEnterBackground:] process: MyApp[1369] permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:1369 preventSuspend preventIdleSleep  preventSuspendOnSleep 
)} 

线3:

Thread 3 name: com.apple.NSURLConnectionLoader 
Thread 3: 
0 libsystem_kernel.dylib   0x3937ea50 mach_msg_trap + 20 
1 libsystem_kernel.dylib   0x3937e848 mach_msg + 36 
2 CoreFoundation     0x2e61261c __CFRunLoopServiceMachPort + 152 
3 CoreFoundation     0x2e610d3c __CFRunLoopRun + 788 
4 CoreFoundation     0x2e57b7a4 CFRunLoopRunSpecific + 520 
5 CoreFoundation     0x2e57b586 CFRunLoopRunInMode + 102 
6 Foundation      0x2efbb23c +[NSURLConnection(Loader)  _resourceLoadLoop:] + 316 
7 Foundation      0x2f030a0a __NSThread__main__ + 1058 
8 libsystem_pthread.dylib   0x393f8956 _pthread_body + 138 
9 libsystem_pthread.dylib   0x393f88c6 _pthread_start + 98 
10 libsystem_pthread.dylib   0x393f6ae4 thread_start + 4 

使用后台任务与“applicationDidEnterBackground这个代码我的应用程序“:

// 10min background task 
UIBackgroundTaskIdentifier myLongTask; 
myLongTask = [[UIApplication sharedApplication] 
       beginBackgroundTaskWithExpirationHandler:^{ 
        [locationMgrInstance timerSet]; 
       }]; 
// cell change 
[locationMgrInstance startMonitoringSignificantLocationChanges]; 

它适用于iOS 6 ...但是! 180秒后iOS 7抛出断言。 帮助!

回答

11

此消息表明您的后台任务运行时间过长。 iOS7改变了后台处理的某些方面。特别是后台任务应该在很短的时间内完成,如果它没有终止你的应用程序。你需要看看你的后台任务是如何运作的。特别是,您需要确保您及时致电[[UIApplication sharedApplication] endBackgroundTask:task];。您还应该在您的到期处理程序中调用此方法。

查看 Apple iOS App Programming Guide Background Execution Guide中的后台执行和多任务部分。

此外,你可以检查[[UIApplication sharedApplication]backgroundTimeRemaining] - 在iOS 6上,这从10分钟开始。在iOS 7中,它从3分钟开始 - 这就是为什么你在180秒后超时。您需要重新评估您的后台策略以处理新的限制。

+0

谢谢,但我仍然怀疑...当我使用该代码(beginBackgroundTaskWithExpirationHandler),应用程序每分钟调用直到10分钟。 – jake85

+0

但是你的代码在哪里调用了endBackgroundTask? – Paulw11

+0

哦!我不是那种方法......这是否意味着我的情况? – jake85

相关问题