Callkit 来电未在旧 iphone 的背景中显示 (Pushkit/Callkit)
Posted
技术标签:
【中文标题】Callkit 来电未在旧 iphone 的背景中显示 (Pushkit/Callkit)【英文标题】:Callkit incoming call not displayed in background on older iphones (Pushkit/Callkit) 【发布时间】:2020-05-08 18:33:12 【问题描述】:我正在尝试实现 Pushkit/CallKit,但在使用较旧的 iphone 时遇到了一些问题。它适用于 iPhone X 和 iphone XR (13.3)。我特别测试过的两款手机是 iPhone SE (13.3.1) 和 iPhone 7 (11.2.5)。
它们在应用程序处于前台时工作,但当它们处于后台时,即使收到 VOIP 通知并且呼叫正在注册到 callkit,也不会显示来电 UI。有什么想法吗?这是日志。您可以看到正在收到通知并且呼叫正在尝试注册
Date/Time: 2020-05-08 21:03:08.3666 -0400
Launch Time: 2020-05-08 21:02:47.8260 -0400
OS Version: iPhone OS 11.2.5 (15D60)
Baseband Version: 6.30.04
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
Termination Description: SPRINGBOARD, scene-create watchdog transgression: com.coachcare.coachcareionic exhausted real (wall clock) time allowance of 19.25 seconds | | ProcessVisibility: Foreground | ProcessState: Running | WatchdogEvent: scene-create | WatchdogVisibility: Foreground | WatchdogCPUStatistics: ( | "Elapsed total CPU time (seconds): 9.680 (user 9.680, system 0.000), 70% CPU", | "Elapsed application CPU time (seconds): 5.934, 43% CPU" | )
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000184cff568 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x0000000184cff3e0 mach_msg + 72
2 CoreFoundation 0x00000001851b3108 __CFRunLoopServiceMachPort + 196
3 CoreFoundation 0x00000001851b0cd4 __CFRunLoopRun + 1424
4 CoreFoundation 0x00000001850d0c58 CFRunLoopRunSpecific + 436
5 Foundation 0x0000000185b05594 -[NSRunLoop+ 50580 (NSRunLoop) runMode:beforeDate:] + 304
6 Foundation 0x0000000185b249ac -[NSRunLoop+ 178604 (NSRunLoop) runUntilDate:] + 96
7 CoachCare 0x00000001009a163c 0x100278000 + 7509564
8 CoachCare 0x000000010027d4b4 0x100278000 + 21684
9 UIKit 0x000000018e8342c4 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 384
10 UIKit 0x000000018ea25bc4 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3436
11 UIKit 0x000000018ea2aa14 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1712
12 UIKit 0x000000018ecc62a8 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 800
13 UIKit 0x000000018ef9e100 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 160
14 UIKit 0x000000018ecc5f0c -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 252
15 UIKit 0x000000018ecc676c -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 732
16 UIKit 0x000000018f44b7c0 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 260
17 UIKit 0x000000018f44b664 -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 448
18 UIKit 0x000000018f1b92cc __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 220
19 UIKit 0x000000018f3523cc _performActionsWithDelayForTransitionContext + 112
20 UIKit 0x000000018f1b917c -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 252
21 UIKit 0x000000018ef9d760 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 364
22 UIKit 0x000000018ea29158 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 540
23 UIKit 0x000000018ee3edbc -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 364
24 FrontBoardServices 0x00000001878ce1f0 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 364
25 FrontBoardServices 0x00000001878d6af8 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 224
26 libdispatch.dylib 0x0000000184b8aa14 _dispatch_client_callout + 16
27 libdispatch.dylib 0x0000000184b92200 _dispatch_block_invoke_direct$VARIANT$mp + 288
28 FrontBoardServices 0x00000001879027f8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36
29 FrontBoardServices 0x000000018790249c -[FBSSerialQueue _performNext] + 404
30 FrontBoardServices 0x0000000187902a38 -[FBSSerialQueue _performNextFromRunLoopSource] + 56
31 CoreFoundation 0x00000001851b377c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
32 CoreFoundation 0x00000001851b36fc __CFRunLoopDoSource0 + 88
33 CoreFoundation 0x00000001851b2f84 __CFRunLoopDoSources0 + 204
34 CoreFoundation 0x00000001851b0b5c __CFRunLoopRun + 1048
35 CoreFoundation 0x00000001850d0c58 CFRunLoopRunSpecific + 436
36 GraphicsServices 0x0000000186f7cf84 GSEventRunModal + 100
37 UIKit 0x000000018e8295c4 UIApplicationMain + 236
38 CoachCare 0x000000010027e3dc 0x100278000 + 25564
39 libdyld.dylib 0x0000000184bf056c start + 4
【问题讨论】:
【参考方案1】:代码0x8badf00d
的异常通常是在您使用不应该是阻塞同步操作的东西阻塞主线程时引起的。这会延迟应用程序响应系统事件的时间过长。因此,例如,在您对推送通知的响应中,您可能正在运行一些同步网络操作或其他任何会阻塞主线程的操作。在这种情况下,需要将阻塞同步操作移动到异步操作中。
您只在旧手机上看到这种行为对我来说是有意义的:就像典型的竞争条件一样,无论在您的主应用程序中延迟主线程的什么,大部分时间都可能在较新的手机上执行得足够快,所以您可以这样做根本没有注意到它们,或者比旧手机更罕见。也可能是旧手机的模式更像是一种巧合,相反,连接速度/信号强度等其他因素会延迟阻塞操作的时间足以导致 ios 仅在某些情况下杀死你的应用程序,因为主线程是被屏蔽太久了。
请记住,阻塞主线程的原因有时可能非常复杂,超出了您自己的代码(例如,它可能是某些库中的错误)。我发现这个Firebase bug description 显然是 Firebase iOS SDK 中的一个错误导致主线程阻塞。
有关代码0x8badf00d
,请参阅Apple's technical note。
【讨论】:
以上是关于Callkit 来电未在旧 iphone 的背景中显示 (Pushkit/Callkit)的主要内容,如果未能解决你的问题,请参考以下文章
是否可以在 iOS 模拟器中使用 CallKit 接听电话?
斯威夫特/CallKit。是不是可以通过自定义 UI 通知 CallKit 接受来电?