Firebase 从不从 iOS 上的 React Native 连接(模拟器)
Posted
技术标签:
【中文标题】Firebase 从不从 iOS 上的 React Native 连接(模拟器)【英文标题】:Firebase never connects from React Native on iOS (simulator) 【发布时间】:2015-10-22 11:30:37 【问题描述】:无法从 React Native 连接到 firebase。我可以看到它不断重试,但从未成功。有人从 React native 成功连接到 firebase 吗?这是在 ios 9 模拟器上。
Firebase 调试日志:
2015-10-22 12:58:31.018 [info][tid:com.facebook.React.javascript] 'p:0: Browser went online. '
2015-10-22 12:58:31.025 [info][tid:com.facebook.React.JavaScript] 'p:0: Listen called for /appversions default '
2015-10-22 12:58:31.026 [info][tid:com.facebook.React.JavaScript] 'p:0: Listen called for /systemstatus/message default '
2015-10-22 12:58:31.032 [info][tid:com.facebook.React.JavaScript] 'p:0: Making a connection attempt '
2015-10-22 12:58:31.033 [info][tid:com.facebook.React.JavaScript] 'c:0:0: Connection created '
2015-10-22 12:58:31.036 [info][tid:com.facebook.React.JavaScript] 'c:0:0:0 Websocket connecting to wss://<app-name>.firebaseio.com/.ws?v=5 '
2015-10-22 12:58:31.038 [info][tid:com.facebook.React.RCTWebSocketManagerQueue][RCTSRWebSocket.m:520] SocketRocket: In debug mode. Allowing connection to any root cert2015-10-22 12:58:31.815 [info][tid:com.facebook.React.JavaScript] 'c:0:0:0 Websocket connected. '
2015-10-22 12:58:31.816 [info][tid:com.facebook.React.JavaScript] 'c:0:0:0 Websocket connection was disconnected. '
2015-10-22 12:58:31.816 [info][tid:com.facebook.React.JavaScript] 'c:0:0:0 WebSocket is closing itself '
2015-10-22 12:58:31.817 [info][tid:com.facebook.React.JavaScript] 'c:0:0: Closing realtime connection. '
2015-10-22 12:58:31.817 [info][tid:com.facebook.React.JavaScript] 'c:0:0: Shutting down all connections '
2015-10-22 12:58:31.817 [info][tid:com.facebook.React.JavaScript] 'p:0: data client disconnected '
2015-10-22 12:58:31.818 [info][tid:com.facebook.React.JavaScript] 'p:0: Trying to reconnect in 112.12895049713552ms '
2015-10-22 12:58:31.819 [info][tid:com.facebook.React.JavaScript] '0: onDisconnectEvents '
2015-10-22 12:58:31.932 [info][tid:com.facebook.React.JavaScript] 'p:0: Making a connection attempt '
2015-10-22 12:58:31.933 [info][tid:com.facebook.React.JavaScript] 'c:0:1: Connection created '
2015-10-22 12:58:31.934 [info][tid:com.facebook.React.JavaScript] 'c:0:1:0 Websocket connecting to wss://<app-name>.firebaseio.com/.ws?v=5 '
2015-10-22 12:58:31.934 [info][tid:com.facebook.React.RCTWebSocketManagerQueue][RCTSRWebSocket.m:520] SocketRocket: In debug mode. Allowing connection to any root cert
2015-10-22 12:58:32.698 [info][tid:com.facebook.React.JavaScript] 'c:0:1:0 Websocket connected. '
2015-10-22 12:58:32.699 [info][tid:com.facebook.React.JavaScript] 'c:0:1:0 Websocket connection was disconnected. '
2015-10-22 12:58:32.699 [info][tid:com.facebook.React.JavaScript] 'c:0:1:0 WebSocket is closing itself '
2015-10-22 12:58:32.699 [info][tid:com.facebook.React.JavaScript] 'c:0:1: Closing realtime connection. '
2015-10-22 12:58:32.699 [info][tid:com.facebook.React.JavaScript] 'c:0:1: Shutting down all connections '
2015-10-22 12:58:32.700 [info][tid:com.facebook.React.JavaScript] 'p:0: data client disconnected '
2015-10-22 12:58:32.700 [info][tid:com.facebook.React.JavaScript] 'p:0: Trying to reconnect in 28.659726264886558ms '
2015-10-22 12:58:32.701 [info][tid:com.facebook.React.JavaScript] '0: onDisconnectEvents '
2015-10-22 12:58:32.732 [info][tid:com.facebook.React.JavaScript] 'p:0: Making a connection attempt '
2015-10-22 12:58:32.732 [info][tid:com.facebook.React.JavaScript] 'c:0:2: Connection created '
2015-10-22 12:58:32.733 [info][tid:com.facebook.React.JavaScript] 'c:0:2:0 Websocket connecting to wss://<app-name>.firebaseio.com/.ws?v=5 '
2015-10-22 12:58:32.733 [info][tid:com.facebook.React.RCTWebSocketManagerQueue][RCTSRWebSocket.m:520] SocketRocket: In debug mode. Allowing connection to any root cert
【问题讨论】:
我已经能够在我的 iOS 项目中包含来自模拟器和设备的 firebase。我没有遇到他的问题 你能试试最新的 react-native 吗?我相信这是由github.com/facebook/react-native/commit/… 修复的,但我不确定是什么版本使它成为... 【参考方案1】:只是日志中的一个想法:
Websocket connecting to wss://<app-name>.firebaseio.com/.ws?v=5
也许您需要配置 firebase 应用名称,还是无论如何都显示?
【讨论】:
我从日志中删除了实际名称 想得太明显了:p【参考方案2】:这是由于 react-native WebSocket polyfill 的一个错误,应该在最新的位中修复(https://github.com/facebook/react-native/commit/607527c0d4bf6d8197829f3523c4d937ac71ed07)。请尝试更新,看看问题是否消失!
【讨论】:
【参考方案3】:还要确保您已在 Firebase 数据库上启用公共读取访问权限。 Firebase Db setup
【讨论】:
以上是关于Firebase 从不从 iOS 上的 React Native 连接(模拟器)的主要内容,如果未能解决你的问题,请参考以下文章
如何从 iOS 中删除 react-native-firebase,同时将其保留在 Android 中?
嗨,我对 React Native Firebase 有疑问
在 iOS 上安装 react-native-firebase 的问题
iOS 上的 Firebase 邀请 - 如何从通用链接获得邀请?
firebase react-native 推送通知适用于 iOS 发布版本,但不适用于通过 App Store 发布的应用程序