angular - ionic firebase - TypeError : Object(. ..) 不是 Firebase.getToken 的函数

标签 angular firebase cordova ionic-framework

我正在按照一个小教程来安装和使用 firebase,

但我什至不能通过我必须做的部分
this.firebase.getToken().then(token => {...},error => {...});
因为我有这个错误:

TypeError: Object(...) is not a function at Firebase.getToken



模块是这样导入的:

import { AngularFirestore } from 'angularfire2/firestore';
import { Firebase } from '@ionic-native/firebase/ngx';


请注意,如果我不输入 /ngx在导入结束时,我收到一个提供程序错误...

我试图安装这个:npm i rxjs@6 rxjs-compat@6 promise-polyfill --save
但没有任何改变
ionic info :
Ionic:

   ionic (Ionic CLI)  : 4.9.0 (/.../.nvm/versions/node/v9.11.2/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.8

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.0.0, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 1.2.1, (and 21 other plugins)

System:

   Android SDK Tools : 25.1.7 (/.../Library/Android/SDK)
   ios-deploy        : 1.9.4
   ios-sim           : 5.0.13
   NodeJS            : v9.11.2 (/.../.nvm/versions/node/v9.11.2/bin/node)
   npm               : 5.6.0
   OS                : macOS Mojave
   Xcode             : Xcode 10.1 Build version 10B61

任何的想法 ?我在这里很迷茫

编辑 :
package.json :
    "angularfire2": "^5.1.1",
    "firebase": "^5.8.1",
    "@ionic-native/firebase": "^5.0.0",


最佳答案

我在这里回答了类似的问题 https://stackoverflow.com/a/54398403/6617276

在 ionic.config.json 文件中检查您的项目类型。

如果类型是 “ ionic Angular ” ,然后安装 4.x.x 版本。

npm i -s @ionic-native/firebase@4.20.0

如果类型是 “Angular ” ,然后安装 5.x.x-beta 版本
npm i -s @ionic-native/firebase@5.0.0-beta.24

备注 :

仅当您使用 时,才在导入末尾添加 ngx Angular 6
import { Firebase } from '@ionic-native/firebase/ngx';

如果不删除 ngx 来自 app.module.ts 和 app.component.ts 中的导入
import { Firebase } from '@ionic-native/firebase';

引用:https://github.com/ionic-team/ionic/issues/15225#issuecomment-414074074

关于angular - ionic firebase - TypeError : Object(. ..) 不是 Firebase.getToken 的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54378590/

相关文章:

javascript - 如何在 Cloud Functions for Firebase 上使用 express 执行 HTTP 文件上传(multer,busboy)

firebase - 如何刷新 Firebase streambuilder 并减少文档读取次数

java - Firebase - 远程配置应用程序更新

android - Ionic 推送通知自定义声音无法在 Android Oreo 及更高版本上播放

javascript - 如何确保一个函数在调用另一个函数之前已经完成 - Promise Chaining Angular JS?

javascript - Angular AngularFire2 简单连接

Angular 翻译插件未启动

javascript - indexOf() 在 Angular2 中的 *ngIf 语句内创建 "cannot read property"错误

html - Angular 键值管道 : argument type is not assignable to parameter type

javascript - Windows 应用商店 Cordova 应用 + WinJS : app crashes with a JavaScript runtime error on launch