cordova - 无法连接到 Cordova 应用上的 Cloud Firestore 数据库
问题描述
我正在尝试使用 Cordova 构建一个应用程序,我想在其中连接 Google Cloud Firestore 数据库。
我使用Cordova Firestore 插件并遵循安装步骤(添加 google-services.json、安装依赖项等)。为了了解如何使用该插件,我构建了我的应用程序并将其与 Chrome DevTools 连接以使用控制台。
当我尝试通过控制台从 firestore 获取数据时,如插件示例中所述,我总是收到以下错误:
Attempt to invoke virtual method 'com.google.firebase.firestore.CollectionReference com.google.firebase.firestore.FirebaseFirestore.collection(java.lang.String)' on a null object reference
我在谷歌上搜索并找到了将版本更改com.google.gms:google-services
为 minimum的提示3.1.1
。
我能做些什么?
解决方案
实际上我遇到了同样的问题并在这里找到了解决方案:
https://github.com/ReallySmallSoftware/cordova-plugin-firestore/issues/11#issuecomment-453435050
通过注释掉 config{}: 这使得浏览器和 android 平台都可以工作(尚未在 iOS 上测试)
这里更新的例子:
https://github.com/ReallySmallSoftware/cordova-plugin-firestore/issues/13#issuecomment-467531402
var options = {
"datePrefix": '__DATE:',
"fieldValueDelete": "__DELETE",
"fieldValueServerTimestamp" : "__SERVERTIMESTAMP",
"persist": true,
// "config" : {}
};
推荐阅读
- python - 使用范围打印并使用分隔符 (end=)
- pdf - 谷歌表格脚本 - 另存为 PDF - 从单元格中获取名称
- ios - 动画 UISwitch 'onTintColor' 属性
- javascript - 需要调整预加载器脚本以不加载在 1 秒内加载的页面
- r - 曲线函数不画函数?
- javascript - 无法使用替换来重命名单元格
- angular - 来自 api 响应的 Angular 反应表单自定义异步验证
- android - 正确处理禁用/只读文本框以实现可访问性
- ios - 动态大小嵌套的 UIStackView
- c# - 有没有一种在 Visual Studio 之外编辑代码分析规则集的好方法