如何退出/关闭 React Native 应用程序? [英] How do I exit/shut down a React Native app?

查看:103
本文介绍了如何退出/关闭 React Native 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的 React Native 应用程序无法连接到其后端,我会显示带有 OK 按钮的警报.如果发生这种情况,应用程序继续运行没有意义,因此我想在单击按钮时将其关闭.我该怎么做?

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.

推荐答案

今天没有 react-native 特定的方法来做到这一点.您必须从事物的本机方面完成此操作.

There's no react-native specific way to do this today. You'd have to accomplish this from the native side of things.

此外,您是为 iOS 开发的吗?Apple 已声明应用不应自行关闭.

Further, are you developing for iOS? Apple has stated that apps should not close themselves.

这篇关于如何退出/关闭 React Native 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆