Ionic-native: Ionic-native/firebase-x plugin reference issue

Created on 9 Feb 2020  路  1Comment  路  Source: ionic-team/ionic-native

I am trying to use cordova-plugin-firebasex in my IONIC 4 project. I have added the cordova plugin and native plugin.
When I call the getToken() method, getting bellow error. Please help to find out what is the issue.

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

Declared as provider in app.module.ts

import { FirebaseX } from '@ionic-native/firebase-x/';
...
providers: [
    FirebaseX

  ]

Import in app.componenent.ts

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

constructor( private firebasex: FirebaseX ) {}

Call inside a this._platform.ready()

this.firebaseX.getToken()
      .then(token => console.log("PushToken "+  token)) // save the token server-side and use it to push notifications to this device
      .catch(error => console.error('Error getting token', error));

    this.firebaseX.onMessageReceived()
      .subscribe(data => alert(data));

    this.firebaseX.onTokenRefresh()
      .subscribe((token: string) => console.log(`Got a new token ${token}`));

My versions

IONIC version 4.6.0
"cordova": "9.0.0",
"cordova-android": "8.0.0",
"cordova-clipboard": "^1.3.0",
"cordova-ios": "5.1.1",

@ionic-native/firebase-x": "^5.21.0"
"cordova-plugin-firebasex": "7.0.2",

Most helpful comment

@smartsanja2013 are you using ionic/angular?

Then the import should look like this:
import { FirebaseX } from '@ionic-native/firebase-x/ngx';
(This is described here: https://github.com/ionic-team/ionic-native#ionicangular-apps)

However, I also see that you are using @ionic-native/firebase-x": "^5.21.0" . Note that currently this is not working. Use version 5.20.0 until a new version is released. See #3311

>All comments

@smartsanja2013 are you using ionic/angular?

Then the import should look like this:
import { FirebaseX } from '@ionic-native/firebase-x/ngx';
(This is described here: https://github.com/ionic-team/ionic-native#ionicangular-apps)

However, I also see that you are using @ionic-native/firebase-x": "^5.21.0" . Note that currently this is not working. Use version 5.20.0 until a new version is released. See #3311

Was this page helpful?
0 / 5 - 0 ratings