我是反应原生的新手。当我尝试从Android设备连接firebase时,我收到以下错误。它与模拟器完美配合。我正在使用设备进行开发 以下是我的代码。
firebaseconfig.js
import * as firebase from 'firebase';
let HAS_INITIALIZED = false
const initFirebase = () => {
if (!HAS_INITIALIZED) {
const config = {
apiKey: "***",
authDomain: "****",
databaseURL: "*****",
storageBucket: "****",
messagingSenderId: "****"
}
firebase.database.enableLogging(true)
firebase.initializeApp(config)
HAS_INITIALIZED = true
}
}
export const getDatabase = () => {
initFirebase()
return firebase.database()
}
Action.js代码
getDatabase().ref('app')
.once('value', async (snapshot) => {
console.log('connected...');
//it is not coming here
});
错误
p:0:Auth令牌刷新
D:\ app \ node_modules \ firebase \ database.js:50 getToken()已完成。创建连接。
D:\ app \ node_modules \ firebase \ database.js:50 c:0:0:连接已创建
D:\ app \ node_modules \ firebase \ database.js:50 c:0:0:0 Websocket连接到wss://react-native-examples.firebaseio.com/.ws?v = 5
D:\ app \ node_modules \ firebase \ database.js:50 c:0:0:超时后关闭不正常的连接。
D:\ app \ node_modules \ firebase \ database.js:50 c:0:0:关闭实时连接。
D:\ app \ node_modules \ firebase \ database.js:50 c:0:0:关闭所有连接
D:\ app \ node_modules \ firebase \ database.js:50 c:0:0:0 WebSocket正在关闭
D:\ app \ node_modules \ firebase \ database.js:50 p:0:数据客户端断开连接
D:\ app \ node_modules \ firebase \ database.js:50 p:0:尝试重新连接494.7817354676815ms
D:\ app \ node_modules \ firebase \ database.js:50 0:onDisconnectEvents
D:\ app \ node_modules \ firebase \ database.js:50 p:0:进行连接尝试
D:\ app \ node_modules \ firebase \ database.js:50 getToken()已完成。创建连接。
D:\ app \ node_modules \ firebase \ database.js:50 c:0:1:连接已创建
D:\ app \ node_modules \ firebase \ database.js:50 c:0:1:0 Websocket连接到wss://react-native-examples.firebaseio.com/.ws?v = 5
D:\ app \ node_modules \ firebase \ database.js:50 c:0:1:超时后关闭不正常的连接。
D:\ app \ node_modules \ firebase \ database.js:50 c:0:1:关闭实时连接。
D:\ app \ node_modules \ firebase \ database.js:50 c:0:1:关闭所有连接
D:\ app \ node_modules \ firebase \ database.js:50 c:0:1:0 WebSocket正在关闭
D:\ app \ node_modules \ firebase \ database.js:50 p:0:数据客户端断开连接
D:\ app \ node_modules \ firebase \ database.js:50 p:0:尝试重新连接851.244468933819ms
D:\ app \ node_modules \ firebase \ database.js:50 0:onDisconnectEvents
D:\ app \ node_modules \ firebase \ database.js:50 p:0:进行连接尝试
D:\ app \ node_modules \ firebase \ database.js:50 getToken()已完成。创建连接。
D:\ app \ node_modules \ firebase \ database.js:50 c:0:2:创建连接