react-native-exception-handler icon indicating copy to clipboard operation
react-native-exception-handler copied to clipboard

Not working in Samsung Galaxy S8

Open jonatasnardi opened this issue 5 years ago • 1 comments

Hello,

I implemented this lib in my app, and works fine on iOS and Android (Zenfone). It is showing the Alert as expected when the app crashes and show the white screen. But on Samsung Galaxy S8, when the app crashes, the white screen is not showing, and the app freezes and the Alert is not showing.

Here is my code in App.js:


const errorHandler = (e, isFatal) => {
    setTimeout(() => {
      showAlertExceptionRestart();  
    }, 0);
};

setJSExceptionHandler(errorHandler, true);

setNativeExceptionHandler(exceptionString => {
  errorHandler;
});

showAlertExceptionRestart = () => {
  Alert.alert(
    i18n.t('Generico.CrashTitulo'),
    i18n.t('Generico.CrashSubtitulo'),
    [{
      text: i18n.t('Generico.CrashReiniciar'),
      onPress: () => {
        RNRestart.Restart();
      }
    }]
  );
}

RN version: 0.58.1 react-native-exception-handler version: 2.10.8

Any idea to solve this?

jonatasnardi avatar Aug 13 '19 21:08 jonatasnardi

Hello,

You cannot show an alert when a native exception occure

From README.md:

  • In case of Native_Exceptions it becomes much worse. While you can catch these unhandled exceptions and perform tasks like cleanup or logout or even hit an API to inform the dev teams before closing the app, you CANNOT show a JS alert box or do any UI stuff via JS code. This has to be done via the native methods provided by this module in the respective NATIVE codebase for iOS and android. The module does provide default handlers though :P. So you will get default popups incase of errors. Obviously you can customise them. See CUSTOMIZATION section.

90dy avatar Sep 03 '19 15:09 90dy