无法连接到 Cordova 应用上的 Cloud Firestore 数据库

Can't connect to Cloud Firestore Database on Cordova app

我正在尝试使用 Cordova 构建一个应用程序,我想在其中连接一个 Google Cloud Firestore 数据库。

我使用 Cordova Firestore Plugin 并遵循安装步骤(添加 google-services.json、安装依赖项等)。为了了解插件的使用方式,我构建了我的应用程序并将其与 Chrome DevTools 连接以使用控制台。

当我尝试通过控制台从 firestore 获取数据时,如插件的 example 中所述,我总是收到以下错误:

Attempt to invoke virtual method 'com.google.firebase.firestore.CollectionReference com.google.firebase.firestore.FirebaseFirestore.collection(java.lang.String)' on a null object reference

我 googled 对此进行了研究,发现了将 com.google.gms:google-services 版本更改为最低 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" : {}
};