ios - react native ios : App crashes when it sent to the background

标签 ios crash react-native

我有一个 React Native ios 应用程序。我正在尝试解决一个问题,但我还无法解决它。

当我按两次主页按钮将应用程序发送到后台时,或者每当我传递到另一个应用程序时,应用程序就会崩溃。您可以观看下面的视频;

You can see error image with this link

http://sendvid.com/gwoqfybp

错误:

2016-11-08 20:51:58.874 NewsApp[33572:686315] -[RCTDeviceExtension orientationDidChange:]: unrecognized selector sent to instance 0x60000001d100
2016-11-08 20:51:58.884 NewsApp[33572:686315] WARNING: GoogleAnalytics 3.15 void GAIUncaughtExceptionHandler(NSException *) (GAIUncaughtExceptionHandler.m:48): Uncaught exception: -[RCTDeviceExtension orientationDidChange:]: unrecognized selector sent to instance 0x60000001d100
2016-11-08 20:51:59.018 NewsApp[33572:686315] invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
2016-11-08 20:51:59.961503 NewsApp[33572:689959] [] __nw_connection_get_connected_socket_block_invoke 210 Connection has no connected handler
2016-11-08 20:52:03.298381 NewsApp[33572:689437] [] __nw_connection_get_connected_socket_block_invoke 211 Connection has no connected handler
2016-11-08 20:52:04.005 NewsApp[33572:686315] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RCTDeviceExtension orientationDidChange:]: unrecognized selector sent to instance 0x60000001d100'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010789f34b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x0000000106ccb21e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010790ef34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x0000000107824c15 ___forwarding___ + 1013
    4   CoreFoundation                      0x0000000107824798 _CF_forwarding_prep_0 + 120
    5   CoreFoundation                      0x000000010783d19c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    6   CoreFoundation                      0x000000010783d09b _CFXRegistrationPost + 427
    7   CoreFoundation                      0x000000010783ce02 ___CFXNotificationPost_block_invoke + 50
    8   CoreFoundation                      0x00000001077ffea2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 2018
    9   CoreFoundation                      0x00000001077fef3b _CFXNotificationPost + 667
    10  Foundation                          0x00000001067930ab -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
    11  UIKit                               0x0000000108d24e3e -[UIApplication _stopDeactivatingForReason:] + 633
    12  UIKit                               0x0000000108d2c712 __62-[UIApplication _sceneSettingsPostLifecycleEventDiffInspector]_block_invoke.1251 + 107
    13  FrontBoardServices                  0x000000010bc1a7f5 __52-[FBSSettingsDiffInspector inspectDiff:withContext:]_block_invoke.27 + 231
    14  Foundation                          0x00000001067f7199 __NSIndexSetEnumerate + 1027
    15  BaseBoard                           0x000000010be05acb -[BSSettingsDiff inspectChangesWithBlock:] + 116
    16  FrontBoardServices                  0x000000010bc14354 -[FBSSettingsDiff inspectOtherChangesWithBlock:] + 92
    17  FrontBoardServices                  0x000000010bc1a598 -[FBSSettingsDiffInspector inspectDiff:withContext:] + 332
    18  UIKit                               0x0000000108d2d1a8 __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 201
    19  UIKit                               0x0000000108d2cdea -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 1060
    20  UIKit                               0x0000000109258676 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 492
    21  FrontBoardServices                  0x000000010bc0302e __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke.376 + 204
    22  FrontBoardServices                  0x000000010bc31723 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
    23  FrontBoardServices                  0x000000010bc3159c -[FBSSerialQueue _performNext] + 189
    24  FrontBoardServices                  0x000000010bc31925 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
    25  CoreFoundation                      0x0000000107844311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    26  CoreFoundation                      0x000000010782959c __CFRunLoopDoSources0 + 556
    27  CoreFoundation                      0x0000000107828a86 __CFRunLoopRun + 918
    28  CoreFoundation                      0x0000000107828494 CFRunLoopRunSpecific + 420
    29  GraphicsServices                    0x000000010b819a6f GSEventRunModal + 161
    30  UIKit                               0x0000000108d2f964 UIApplicationMain + 159
    31  NewsApp                             0x0000000102822dcf main + 111
    32  libdyld.dylib                       0x000000010a70668d start + 1
    33  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

解决方案

基本上是由 Google Analytics 插件引起的问题。我切换到 Fribase Analytics 并解决了问题!

最佳答案

您需要更改应用程序状态并确保没有正在运行的进程,例如不会在后台运行的推送通知。尝试发布正在运行的代码,我会尝试更改我的答案。

getInitialState: function() {
  return {
    currentAppState: AppState.currentState,
  };
},
componentDidMount: function() {
  AppState.addEventListener('change', this._handleAppStateChange);
},
componentWillUnmount: function() {
  AppState.removeEventListener('change', this._handleAppStateChange);
},
_handleAppStateChange: function(currentAppState) {
  this.setState({ currentAppState, });
},
render: function() {
  return (
    <Text>Current state is: {this.state.currentAppState}</Text>
  );
},

在此处阅读更多内容以获取完整示例和文档 https://facebook.github.io/react-native/docs/appstate.html

关于ios - react native ios : App crashes when it sent to the background,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40493621/

相关文章:

ios - 在 isKindOfClass : 中未检测到从 UIButton 继承的自定义类

objective-c - 带有 ARC 的 main() 中的 EXC_BAD_ACCESS 但没有提示错误

react-native - React Native WebView App 不会在按下后退按钮时退出

javascript - React-Native - 通过嵌套对象崩溃递归

javascript - 不同的应用程序如何从共享组件文件夹导入? react / react native

ios - UI分段控制ui修改

ios - 如何使用 Swift 中的 Cognito 用户池注册用户并验证他们的电话号码?

ios - 将 sqlite 文件从一个项目复制到另一个项目

iphone - Zooz Secure In App Payment运行时错误

java - NotifyDatasetchanged 不起作用。单击按钮后应用程序崩溃