gpt4 book ai didi

javascript - Firebase 未在 iOS Ionic 上初始化

转载 作者:行者123 更新时间:2023-11-29 23:17:37 28 4
gpt4 key购买 nike

我的 Ionic、Angular 和 Firebase 应用遇到了问题。

我以前遇到过这个问题,但是好像自己解决了,现在又遇到了,不知道有没有人知道为什么。

我正在使用 Firebase FCM 存储用户的 token,然后向他们发送通知。在 android 上这完美地工作,而在 iOS 上它曾经工作..

我从 Firebase 生成了我的 GoogleService-Info.plist 文件并将其放在我的主文件夹中。

我有以下代码来获取 fcm token :

 getFCMToken() {
let token;
this.firebaseNative.getToken().then((tok) => {
token = tok;
if(this.platform.is('ios')) {
this.firebaseNative.grantPermission().then((tok) => {
return this.fcmToFirestore(token);
}).catch(error => this.showToast("There was an error: " + error));
} else {
return this.fcmToFirestore(token);
}
}).catch(error => {
this.showToast("There was an error: " + error)
});
}

fcmToFirestore(token) {
if (!token) return;

const devicesRef = this.afs.collection('devices')
const docData = {
token,
userId: this.userData.uid,
}
return devicesRef.doc(token).set(docData);
}

当我在 iPhone 上运行以下代码时,我收到消息:

There was an error: Firebase isn't initialised

我在 imports 中的 app.module.ts 中初始化应用程序,它一直有效,正如我所说,在 android 上运行良好。

知道为什么这在 iOS 上不起作用吗?谢谢!

最佳答案

This is an issue with the installed version of firebase plugin.

我通过降级到 1.0.5 减轻了这个错误

cordova plugin remove cordova-plugin-firebase
cordova plugin add cordova-plugin-firebase@1.0.5 --save

附言确保 config.xml 在所需版本中提到了 firebase。这有助于在所有开发系统中保持版本相同。

<plugin name="cordova-plugin-firebase" spec="~1.0.5" />

关于javascript - Firebase 未在 iOS Ionic 上初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52140850/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com