首页 > 解决方案 > Ionic Cordova 添加原生 Firebase:缺少命令错误

问题描述

Angular 7,Ionic 4.12.0,Cordova:9.0.0 (cordova-lib@9.0.1)。

https://ionicframework.com/docs/native/firebase添加Firebase和添加后, 我没有看到在我的 config.xml 中添加了这些插件。FirebaseAuthentication

当我尝试使用 FirebaseAuthentication 中的任何方法时,出现以下错误:

错误:找不到执行代理 :: FirebaseAuthentication :: createUserWithEmailAndPassword

编码:

export class FirebaseGeneralService {

    constructor(private _firebaseAuth: FirebaseAuthentication, private firebase: Firebase, private platform: Platform) {
        this.init();
    }

    private async init() {
        this.platform.ready().then(
            async () => {
                await this._firebaseAuth.createUserWithEmailAndPassword("test@test.com", "123456");
            }
        );
    }
}

在我的模块中我添加了providers: [..., Firebase, FirebaseAuthentication]

现在,当我将代码调试到 cordova.js 内部(第 1038 行)时,我遇到了这一行:

return (CommandProxyMap[service] ? CommandProxyMap[service][action] : null);

CommandProxyMap doesnt contain neither `Firebase` or `FirebaseAuthentication`. Ive attached an image showing the line and object content.

注意工具提示后面的 FirebaseAuthentication 服务

我尝试将插件手动添加到 config.xml 文件中:

<plugin name="cordova-plugin-firebase" spec="5.5.0" />
<plugin name="cordova-plugin-firebase-authentication" spec="5.5.1" />

(只是提醒一下,我已经从 CLI 正确安装了它们。Firebase 和 FirebaseAuthentication)。

这是一个运行时错误。

谢谢。

标签: angularfirebasecordovaionic-frameworkionic4

解决方案


你跑了吗

ionic cordova plugin add cordova-plugin-firebase?


推荐阅读