ios - firebase 3 我们可以在 firebase.database().goOffline() 之后登录吗?

标签 ios firebase react-native offline firebase-authentication

我的 react-native 应用在线时运行良好,现在我正在尝试离线行为。

我尝试过离线(firebase.database().goOffline() 然后关闭 wifi 并运行)。

我收到以下代码的 firebase 错误“auth/network-request-failed”:

import Firebase from 'firebase'
config = {
  apiKey:  `${ Config.firebase.apiKey }`,
  authDomain: `${ Config.firebase.authDomain }`,
  databaseURL: `${ Config.firebase.databaseURL }`,
  storageBucket: `${ Config.firebase.storageBucket }`
}

firebase = Firebase.initializeApp(config)
firebase.database().goOffline()
const credentials = Firebase.auth.EmailAuthProvider.credential(email, password)

firebase.auth().signInWithCredential(credentials)
.then((user) => {
  console.log('signin ok', user)
})
.catch((error) => {
  console.log('signin error', error)
})

最佳答案

登录 Firebase 身份验证需要有效的网络连接。没有事件的网络连接时无法登录。

毕竟,如果无法访问服务器,firebase.auth().signInWithCredential 会将电子邮件+密码与什么进行比较?

关于ios - firebase 3 我们可以在 firebase.database().goOffline() 之后登录吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38973837/

相关文章:

ios - 我有两个 Xcode 项目,找出其中两个文件不同的最简单方法是什么?

ios - 在 iOS 中使用添加的变量刷新 UIView 函数

swift - Firebase 存储 downloadUrl 完成处理程序总是返回错误

node.js - Firebase 消息传递 send() 错误与 UnhandledPromiseRejectionWarning

javascript - for...of 循环在远程调试器被禁用时不起作用

reactjs - 如何在 mapStateToProps 方法中使用 React 组件本地状态?

ios - UILocalNotification 延迟 1 小时

ios - 如何在 Swift 中列出所有符合协议(protocol)的类?

firebase - 不能使用cypress来使用Firestore本地模拟器来测试应用

android - W/未知 :ViewManagerPropertyUpdater: Could not find generated setter for class com. facebook.react.*