React Native Firebase 推送通知崩溃报告问题

Posted

技术标签:

【中文标题】React Native Firebase 推送通知崩溃报告问题【英文标题】:React Native Firebase Push Notification Crash Report Problem 【发布时间】:2021-06-10 09:02:23 【问题描述】:

我正在使用 React Native 构建一个应用程序。使用 React Native Firebase,我正在添加推送通知功能。当我从退出状态打开推送通知时,应用打开并在初始屏幕上挂起一段时间,然后崩溃。

这是来自设备的崩溃报告,符号化。老实说,我是编程新手,所以我在解释下面的报告时遇到了麻烦。我认为 RNSplashScreen 模块或 AppDelegate.m 有问题,但不能确定。

谁能帮我解释一下,并指出可能的根本原因/从哪里看?

谢谢!

    Exception Type:  EXC_CRASH (SIGKILL)
    Exception Codes: 0x0000000000000000, 0x0000000000000000
    Exception Note:  EXC_CORPSE_NOTIFY
    Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
    Termination Description: SPRINGBOARD, <RBSTerminateContext| domain:10 code:0x8BADF00D explanation:scene-create watchdog transgression: application<myapp.myapp>:2661 exhausted real (wall clock) time allowance of 59.91 seconds | ProcessVisibility: Foreground | ProcessState: Running | WatchdogEvent: scene-create | WatchdogVisibility: Background | WatchdogCPUStatistics: ( | "Elapsed total CPU time (seconds): 16.580 (user 16.580, system 0.000), 5% CPU", | "Elapsed application CPU time (seconds): 0.918, 0% CPU" | ) reportType:CrashLog maxTerminationResistance:Interactive>
    Triggered by Thread:  0

    Thread 0 name:  Dispatch queue: com.apple.main-thread
    Thread 0 Crashed:
    0   libsystem_kernel.dylib          0x00000001daebe2d0 mach_msg_trap + 8
    1   libsystem_kernel.dylib          0x00000001daebd660 mach_msg + 76
    2   CoreFoundation                  0x00000001acf08c30 __CFRunLoopServiceMachPort + 380
    3   CoreFoundation                  0x00000001acf02c14 __CFRunLoopRun + 1216
    4   CoreFoundation                  0x00000001acf0221c CFRunLoopRunSpecific + 600
    5   Foundation                      0x00000001ae1b1df0 -[NSRunLoop+ 36336 (NSRunLoop) runMode:beforeDate:] + 232
    6   Foundation                      0x00000001ae1b1cbc -[NSRunLoop+ 36028 (NSRunLoop) runUntilDate:] + 92
    7   myapp                           0x00000001005d15f0 +[RNSplashScreen show] (in myapp) (RNSplashScreen.m:31) + 5641712
    8   myapp                           0x0000000100075be4 -[AppDelegate application:didFinishLaunchingWithOptions:] (in myapp) (AppDelegate.m:53) + 23524
    9   UIKitCore                       0x00000001af93f228 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 360
    10  UIKitCore                       0x00000001af941290 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 5136
    11  UIKitCore                       0x00000001af946cec -[UIApplication _runWithMainScene:transitionContext:completion:] + 1244
    12  UIKitCore                       0x00000001aef9cc74 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 152
    13  UIKitCore                       0x00000001af50af9c _UIScenePerformActionsWithLifecycleActionMask + 112
    14  UIKitCore                       0x00000001aef9d80c __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 224
    15  UIKitCore                       0x00000001aef9d2cc -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 484
    16  UIKitCore                       0x00000001aef9d61c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 768
    17  UIKitCore                       0x00000001aef9ce58 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 340
    18  UIKitCore                       0x00000001aefa53a4 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 196
    19  UIKitCore                       0x00000001af41760c +[BSAnimationSettings+ 6936076 (UIKit) tryAnimatingWithSettings:actions:completion:] + 892
    20  UIKitCore                       0x00000001af5236c4 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 272
    21  UIKitCore                       0x00000001aefa509c -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 384
    22  UIKitCore                       0x00000001aedcc5a0 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 776
    23  UIKitCore                       0x00000001aedcaf14 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 256
    24  UIKitCore                       0x00000001aedcc1c8 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 248
    25  UIKitCore                       0x00000001af944e8c -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 572
    26  UIKitCore                       0x00000001af440e38 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 388
    27  FrontBoardServices              0x00000001bccf83bc -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 432
    28  FrontBoardServices              0x00000001bcd23d04 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.200 + 128
    29  FrontBoardServices              0x00000001bcd074a0 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 240
    30  FrontBoardServices              0x00000001bcd239c8 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 372
    31  libdispatch.dylib               0x00000001acb81db0 _dispatch_client_callout + 20
    32  libdispatch.dylib               0x00000001acb85738 _dispatch_block_invoke_direct + 268
    33  FrontBoardServices              0x00000001bcd4c250 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48
    34  FrontBoardServices              0x00000001bcd4bee0 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 448
    35  FrontBoardServices              0x00000001bcd4c434 -[FBSSerialQueue _performNextFromRunLoopSource] + 32
    36  CoreFoundation                  0x00000001acf0976c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
    37  CoreFoundation                  0x00000001acf09668 __CFRunLoopDoSource0 + 208
    38  CoreFoundation                  0x00000001acf08960 __CFRunLoopDoSources0 + 268
    39  CoreFoundation                  0x00000001acf02a8c __CFRunLoopRun + 824
    40  CoreFoundation                  0x00000001acf0221c CFRunLoopRunSpecific + 600
    41  GraphicsServices                0x00000001c4ace784 GSEventRunModal + 164
    42  UIKitCore                       0x00000001af942ee8 -[UIApplication _run] + 1072
    43  UIKitCore                       0x00000001af94875c UIApplicationMain + 168
    44  myapp                       0x0000000100075db4 main (in myapp) (main.m:7) + 23988
    45  libdyld.dylib                   0x00000001acbc26b0 start + 4

【问题讨论】:

终止原因有一些关键的,如果是神秘的信息。看看这个问题,它应该有助于澄清一点:***.com/questions/773442/… 【参考方案1】:

在我的项目中添加 React Native Firebase 后我遇到了同样的问题,并在这个问题中找到了答案:https://github.com/crazycodeboy/react-native-splash-screen/issues/397

真正的原因在于 react-native-splash-screen。 Firebase 需要在您的 App 的 Capabilities 中更改“背景模式”,这会导致 react-native-splash-screen 在 RNSplashScreen.m 中进入循环:

while (waiting) 
    NSDate* later = [NSDate dateWithTimeIntervalSinceNow:0.1];
    [[NSRunLoop mainRunLoop] runUntilDate:later];

你可以在回溯的这一部分找到它:

5   Foundation                      0x00000001ae1b1df0 -[NSRunLoop+ 36336 (NSRunLoop) runMode:beforeDate:] + 232
6   Foundation                      0x00000001ae1b1cbc -[NSRunLoop+ 36028 (NSRunLoop) runUntilDate:] + 92
7   myapp                           0x00000001005d15f0 +[RNSplashScreen show] (in myapp) (RNSplashScreen.m:31) + 5641712

解决问题需要修改你的AppDelegate.m,替换

[RNSplashScreen show]

[RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView];

但请注意,如果您的项目使用 LaunchScreen.storyboard 而不是 LaunchScreen.xib,您可能会遇到此错误:

*** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法在包中加载 NIB:'NSBundle /var/containers/Bundle/Application/D22A78C5-5733-4511-85BF-217A3BAEB6AB/ myapp.app>(已加载)',名称为'LaunchScreen''

在这种情况下,您需要创建名为“LaunchScreen”的新视图,并将 LaunchScreen.storyboard 中的启动视图复制粘贴到此处。

【讨论】:

很好的答案,为我节省了一天,这应该是一个有 100 次投票的精选答案,干得好

以上是关于React Native Firebase 推送通知崩溃报告问题的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 react-native-firebase 在 iOS 设备的推送通知中添加按钮?

React Native Firebase 推送通知崩溃报告问题

React Native Firebase 的 getInitialNotification 仅针对第一次推送通知返回通知对象

推送通知操作按钮不显示 - 背景和终止状态 - React Native

firebase react-native 推送通知适用于 iOS 发布版本,但不适用于通过 App Store 发布的应用程序

使用 react-native-firebase 在 React Native 上自定义通知