ionic/cordova 中的 Firebase 离线功能 [英] Firebase offline capabilities in ionic / cordova

查看:53
本文介绍了ionic/cordova 中的 Firebase 离线功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人在 Android/iOS 中使用 Firebase 实现了具有完整离线功能的本机应用程序?

Has anybody implemented a native app with Firebase with full offline capabilities in Android/iOS?

这是否可以在 Cordova/Ionic 中使用使用原生 Firebase SDK 的插件完成?

Could this be done in Cordova/Ionic with a plugin that uses the native Firebase SDKs?

我们正在构建一个在下载和首次启动时具有连接的应用程序,但随后我们必须假设有一段时间没有更多的互联网连接,并且数据库中的所有内容都必须离线可用.Firebase 是否适合此要求,还是必须使用 CouchDB/PouchDB 或任何其他替代方案?

We are building an app that has connection at download and first start but then we have to assume there is no more internet connection for a while and all content from the database has to be available offline. Is Firebase suitable for this requirement or do we have to use CouchDB/PouchDB or any other alternative?

这个问题涉及到 firebase 实时数据库.我相信使用新的 Firebase Cloud Firestore 离线功能可以支持 ionic 开箱即用:

This question referred to the firebase realtime database. I believe that with the new firebase Cloud Firestore offline capabilities for ionic are supported out of the box:

https://firebase.google.com/docs/database/rtdb-vs-firestore

实时数据库:仅对 iOS 和 Android 上的移动客户端的离线支持.

Realtime Database: Offline support for mobile clients on iOS and Android only.

Cloud Firestore:对 iOS、Android 和 Web 客户端的离线支持.

Cloud Firestore: Offline support for iOS, Android, and web clients.

推荐答案

您可以使用以下项目 -AngularFire2-offline

You can use the following project - AngularFire2-offline

它的目的是为支持浏览器(支持服务工作者)启用离线数据访问 -支持服务工作者的浏览器(和匹配版本)列表

It's purpose is to enable offline data access for supporting browsers (that supports service workers) - List of browsers (and matching versions) that support service workers

它是这样工作的 -

  • 在线时,Firebase 数据存储在本地(随着数据更改,本地存储会更新)
  • 离线时,提供本地数据(如果可用),并在本地存储写入
  • 重新连接时,应用会使用新的 Firebase 数据进行更新,并将写入内容发送到 Firebase
  • 即使在线时,也会在可用时首先使用本地数据,从而加快加载速度

这篇关于ionic/cordova 中的 Firebase 离线功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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