If my React Native app fails to connect to its backend, I show an Alert with an OK button. If this happens, there's no point in the app continuing to run, so I'd like to shut it down when the button is clicked. How do I do this?
I suspect the key is in AppRegistry but the docs are a bit scant.
I am answering the question too late, but i thought the way i have chosen might help someone, so I am answering this question.
For Android, Use BackAndroid to exit the App:
This is how I've achieved:
There's no react-native specific way to do this today. You'd have to accomplish this from the native side of things.
Further, are you developing for iOS? Apple has stated that apps should not close themselves.
Write a native module that performs the following actions when called:
IOS:
ANDROID:
...EDIT...
Or just use the one I created: https://www.npmjs.com/package/react-native-exit-app