Firebase身份验证导致错误代码"auth/network-request-failed"

ill*_*ate 6 authentication firebase react-native firebase-authentication react-redux

我正在开发一个使用Firebase进行身份验证的本机应用程序.

当我启动身份验证请求时,会导致以下错误:

N {code: "auth/network-request-failed", message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred."}
Run Code Online (Sandbox Code Playgroud)

这是我用来验证/创建用户的代码.注意:我正在使用redux来维护状态.

firebase.auth().signInWithEmailAndPassword(email, password)
        .then(user => authenticateUserSuccess(dispatch, user))
        .catch((error) => {
            console.log(error);
            firebase.auth().createUserWithEmailAndPassword(email, password)
                .then(user => authenticateUserSuccess(dispatch, user))
                .catch(() => authenticateUserFail(dispatch));
        });
Run Code Online (Sandbox Code Playgroud)

以下是我在项目中使用的依赖项:

"dependencies": {
    "axios": "^0.15.3",
    "firebase": "^3.7.2",
    "lodash": "^4.17.4",
    "react": "15.4.2",
    "react-native": "0.42.0",
    "react-native-router-flux": "^3.38.0",
    "react-native-vector-icons": "^4.0.0",
    "react-redux": "^5.0.3",
    "redux": "^3.6.0",
    "redux-thunk": "^2.2.0"
}
Run Code Online (Sandbox Code Playgroud)

小智 1

检查您的手机/设备。确保谷歌服务正在运行。只需打开 playstore 即可查看。如果它没有运行,请重新启动您的设备并再次检查。如果它正在运行,请再次登录/创建用户 firebase。我用这种方式解决我的问题