ios – 应用程序在使用BKProcessAssertion进行远程推送时崩溃

前端之家收集整理的这篇文章主要介绍了ios – 应用程序在使用BKProcessAssertion进行远程推送时崩溃前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我整合了最新版本的Google AnalyticsSDK.我在我的应用程序中使用静默通知.
所以我需要一点时间来完成后台任务(大约30秒).
我看到许多崩溃与允许的时间有关.
  1. My App[3114] has active assertions beyond permitted time:
  2. {(
  3. <BKProcessAssertion: 0x15699c00> identifier: Background Content Fetching (15) process: MyApp [3114] permittedBackgroundDuration: 30.000000 reason: backgroundContentFetching owner
  4. pid:3101 preventSuspend preventThrottleDownUI preventIdleSleep preventSuspendOnSleep
  5. )}

我看到应用程序崩溃了[GAI threadMain]上的以下堆栈:

  1. Thread 2:
  2. 0 libsystem_kernel.dylib 0x3b47ca58 mach_msg_trap + 20
  3. 1 libsystem_kernel.dylib 0x3b47c854 mach_msg + 44
  4. 2 CoreFoundation 0x3074c896 __CFRunLoopServiceMachPort + 150
  5. 3 CoreFoundation 0x3074afbc __CFRunLoopRun + 780
  6. 4 CoreFoundation 0x306b5f0a CFRunLoopRunSpecific + 518
  7. 5 CoreFoundation 0x306b5cee CFRunLoopRunInMode + 102
  8. 6 Foundation 0x310a81e6 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250
  9. 7 Foundation 0x310f909c -[NSRunLoop(NSRunLoop) run] + 76
  10. 8 MyApp 0x0016df5c +[GAI threadMain:] + 60
  11. 9 Foundation 0x3116aa5a __NSThread__main__ + 1058
  12. 10 libsystem_pthread.dylib 0x3b4f8916 _pthread_body + 138
  13. 11 libsystem_pthread.dylib 0x3b4f8886 _pthread_start + 98
  14. 12 libsystem_pthread.dylib 0x3b4f6aa0 thread_start + 4

我认为崩溃与Google Analytics有关,我尝试在远程推送时关闭Google Analytics,如下所示:

  1. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
  2. fetchCompletionHandler:(BackgroundFetchResultBlock)completionHandler {
  3. ...
  4. [GAI sharedInstance].optOut = YES;

但它没有帮助.

解决方法

请参阅 this SO answer.简而言之,问题是您的后台任务的运行时间超过了允许的时间.自iOS6起,允许的后台时间显着缩短;您可能需要重新审视您的设计并进行调整.

猜你在找的iOS相关文章