Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 => {...});

because I have this error :

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

the module is imported like this :


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

note that if I dont put /ngx at the end of the import, I get an provider error ...

I tried to install this : npm i rxjs@6 rxjs-compat@6 promise-polyfill --save

but nothing changed

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 ([email protected])
   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

EDIT :

package.json :

    "angularfire2": "^5.1.1",
    "firebase": "^5.8.1",
    "@ionic-native/firebase": "^5.0.0",


like image 414
F4Ke Avatar asked Jul 01 '26 14:07

F4Ke


1 Answers

I have answered a similar question here https://stackoverflow.com/a/54398403/6617276

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

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

npm i -s @ionic-native/[email protected]

If the type is "angular", then install 5.x.x-beta version

npm i -s @ionic-native/[email protected]

Note:

Add ngx at the end of import only if you are using Angular 6

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

if not remove ngx from the import both in app.module.ts and app.component.ts

import { Firebase } from '@ionic-native/firebase';

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

like image 155
Rathnakara S Avatar answered Jul 03 '26 08:07

Rathnakara S



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!