如何退出/关闭React Native应用程序?
问题描述:
如果我的React Native应用程序无法连接到其后端,我会显示一个带有OK按钮的Alert.如果发生这种情况,则应用程序将无法继续运行,因此我想在单击按钮时将其关闭.我该怎么做?
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?
我怀疑密钥在AppRegistry中,但是文档有些不足.
I suspect the key is in AppRegistry but the docs are a bit scant.
答
今天,还没有特定于反应本机的方法.您必须从事物的本机方面完成此任务.
There's no react-native specific way to do this today. You'd have to accomplish this from the native side of things.
此外,您正在为iOS开发吗?苹果已经表示,应用程序不应自行关闭.
Further, are you developing for iOS? Apple has stated that apps should not close themselves.