Firebase可以与React Native脱机工作吗? [英] Can Firebase work offline with React Native?

查看:65
本文介绍了Firebase可以与React Native脱机工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的iOS应用,我想开始向其中添加一些React Native屏幕.该应用程序使用启用了持久性的Firebase,以便脱机工作.有没有办法在保持脱机功能的同时直接在React Native中使用Firebase?

I have an existing iOS app that I'd like to start adding some React Native screens to. The app uses Firebase with persistence enabled so that it works offline. Is there a way to also use Firebase directly within React Native while maintaining offline functionality?

如果答案为是",iOS和React Native是否共享相同的本地数据存储?这很重要,以便iOS屏幕上的脱机数据更改将反映从React Native屏幕上进行的数据更改,反之亦然.

If the answer is "Yes", do iOS and React Native share the same local data store? This would be important, so that offline data changes on iOS screens would reflect data changes made from React Native screens and vice versa.

感谢您分享有关此方面的见解!

Thanks for sharing your insight on this!

推荐答案

当您离线时,javascript SDK将保留新的写入请求,并且在您上网后将与服务器同步.但是,如果您希望显示一个包含以前从firebase提取的数据的列表,那么您对Javascript不走运. 答案之一是提及Firestack,但不再受支持.

The javascript SDK will persist new write requests when you are offline and will sync with the server once you go online. But if you were hoping to show a list with data that was previously fetched from firebase, then you are out of luck with Javascript. One of the answers mentions Firestack, but it is no longer supported.

在一个项目中,我最终安装了此软件包 https://github.com/invertase/react-native-firebase .这是通向本地ios&的桥梁用于Firebase的Android SDK,如果使用它,也可以使用持久性.

On a project I just ended up installing this package https://github.com/invertase/react-native-firebase. It is a bridge to the native ios & Android SDKs for firebase and if you use it you can also use persistence.

经过测试并验证.一切都很好! :)

Tested and verified. All works great! :)

这篇关于Firebase可以与React Native脱机工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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