离子Firebase-TypeError:Object(...)不是Firebase.getToken上的函数 [英] ionic firebase - TypeError: Object(...) is not a function at Firebase.getToken

查看:58
本文介绍了离子Firebase-TypeError:Object(...)不是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 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

有什么主意吗?我在这里很迷路

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

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

Check your project type in ionic.config.json file.

如果类型为离子角" ,则安装4.x.x版本.

If the type is "ionic-angular", then install 4.x.x version.

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

如果类型为角度" ,则安装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

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/ionic/issues/15225#issuecomment-414074074

这篇关于离子Firebase-TypeError:Object(...)不是Firebase.getToken上的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆