iOS 13 接收推送通知时崩溃?

iOS 13 crash when receiving push notification?

我们在 iOS 13 遇到了很多以下崩溃:

Crashed: com.twitter.crashlytics.ios.exception
0  MyApp                         0x1029626ac CLSProcessRecordAllThreads + 376 (CLSProcess.c:376)
1  MyApp                         0x102962a94 CLSProcessRecordAllThreads + 407 (CLSProcess.c:407)
2  MyApp                         0x102952798 CLSHandler + 26 (CLSHandler.m:26)
3  MyApp                         0x102960cc0 __CLSExceptionRecord_block_invoke + 199 (CLSException.mm:199)
4  libdispatch.dylib              0x1994911cc _dispatch_client_callout + 16
5  libdispatch.dylib              0x199443d04 _dispatch_lane_barrier_sync_invoke_and_complete + 56
6  MyApp                         0x102960768 CLSExceptionRecord + 206 (CLSException.mm:206)
7  MyApp                         0x10296059c CLSExceptionRecordNSException + 102 (CLSException.mm:102)
8  MyApp                         0x1029601c0 CLSTerminateHandler() + 259 (CLSException.mm:259)
9  libc++abi.dylib                0x199591304 std::__terminate(void (*)()) + 16
10 libc++abi.dylib                0x19959129c std::terminate() + 44
11 libobjc.A.dylib                0x1994ec2dc _objc_terminate() + 10
12 libdispatch.dylib              0x1994911e0 _dispatch_client_callout + 36
13 libdispatch.dylib              0x199443d04 _dispatch_lane_barrier_sync_invoke_and_complete + 56
14 BaseBoard                      0x19c307ccc -[BSAction sendResponse:withCompletion:] + 116
15 UIKitCore                      0x19d341558 -[UIHandleRemoteNotificationAction sendResponse:] + 128
16 UIKitCore                      0x19d7bb250 __91-[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:completion:]_block_invoke_3.2661 + 72
17 UIKitCore                      0x19d7af014 _runAfterCACommitDeferredBlocks + 316
18 UIKitCore                      0x19d79f064 _cleanUpAfterCAFlushAndRunDeferredBlocks + 232
19 UIKitCore                      0x19d7ce80c _afterCACommitHandler + 76
20 CoreFoundation                 0x1997404f8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
21 CoreFoundation                 0x19973b3e4 __CFRunLoopDoObservers + 416
22 CoreFoundation                 0x19973b9b0 __CFRunLoopRun + 1308
23 CoreFoundation                 0x19973b16c CFRunLoopRunSpecific + 464
24 GraphicsServices               0x1a3573328 GSEventRunModal + 104
25 UIKitCore                      0x19d7a5d0c UIApplicationMain + 1936
26 MyApp                         0x1021fa41c main + 22 (main.m:22)
27 libdyld.dylib                  0x1995c6424 start + 4

带有以下消息:

Fatal Exception: NSInternalInconsistencyException this request has been neutered - you can't call -sendResponse: twice nor after encoding it +[_CFXNotificationTokenRegistration keyCallbacks]

有谁知道是什么导致了这次崩溃?下面的行 15 UIKitCore 0x19d341558 -[UIHandleRemoteNotificationAction sendResponse:] + 128 表明这是在收到远程通知时发生的,我猜,但不确定。这是否与收到远程通知时未正确调用 fetchCompletionHandler 回调有关?感谢您的任何建议,thx :)

虽然我不知道 Crashlytics 的实施细节,但以前众所周知的使用 Data 对象注册远程通知的模式在 iOS 13 上不再受支持,并且可能会有所贡献为了你的崩溃。

区别在这个答案中解释:

我认为您应该实施 fetchCompletionHandler,即使它是一个可选方法。 正如 Apple 提到的 in the documentation

If you do not call the completion handler in time, your app is terminated

快速修复:正确实施此委托...iOS13 应该让你离开。

旁注:iOS 13 对所有历史背景资料都非常挑剔,Apple 添加了那种看门狗,如果你看起来不在学术上使用背景功能,就会杀了你......同样的悲伤故事很多带有 VoIP 推送的应用程序 ;-)