ionic firebase - TypeError: Object(...) 不是 Firebase.getToken 的函数 [英] ionic firebase - TypeError: Object(...) is not a function at Firebase.getToken
问题描述
我正在学习安装和使用 firebase 的小教程,
I am following a little tutorial to install and use firebase,
但我什至无法通过我必须做的部分
But I can't even pass the part where I have to do
this.firebase.getToken().then(token => {...},error => {...});
因为我有这个错误:
TypeError: Object(...) 不是函数在 Firebase.getToken
TypeError: Object(...) is not a function at Firebase.getToken
模块是这样导入的:
import { AngularFirestore } from 'angularfire2/firestore';
import { Firebase } from '@ionic-native/firebase/ngx';
请注意,如果我不将 /ngx
放在导入的末尾,则会出现提供程序错误...
note that if I dont put /ngx
at the end of the import, I get an provider error ...
我尝试安装这个:npm i rxjs@6 rxjs-compat@6 promise-polyfill --save
但没有改变
离子信息
:
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
有什么想法吗?我在这里迷路了
any idea ? I quite lost here
package.json
:
"angularfire2": "^5.1.1",
"firebase": "^5.8.1",
"@ionic-native/firebase": "^5.0.0",
推荐答案
我在这里回答了一个类似的问题 https://stackoverflow.com/a/54398403/6617276
I have answered a similar question here https://stackoverflow.com/a/54398403/6617276
在 ionic.config.json 文件中检查您的项目类型.
Check your project type in ionic.config.json file.
如果类型是ionic-angular",则安装4.x.x版本.
If the type is "ionic-angular", then install 4.x.x version.
npm i -s @ionic-native/firebase@4.20.0
如果类型是angular",则安装5.x.x-beta版
If the type is "angular", then install 5.x.x-beta version
npm i -s @ionic-native/firebase@5.0.0-beta.24
注意:
仅当您使用 Angular 6
import { Firebase } from '@ionic-native/firebase/ngx';
如果没有从 app.module.ts 和 app.component.ts 中的导入中删除 ngx
if not remove ngx from the import both in app.module.ts and app.component.ts
import { Firebase } from '@ionic-native/firebase';
参考:https://github.com/ionic-team/离子/问题/15225#issuecomment-414074074
这篇关于ionic firebase - TypeError: Object(...) 不是 Firebase.getToken 的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!