TypeError: Cannot read property 'getToken' of undefined in Ionic3 project

Viewed 794

I tried to use the latest version of cordova-plugin-firebasex for my ionic3 app. I also did refer the ionic3 example for firebasex plugin. But after adding the code, I am getting the error as 'TypeError: Cannot read property 'getToken' of undefined'. Below is the code which I have used:

In my login.ts file:

if ( this.accessToken ) {
this.fireBaseService.getFirebaseXToken();
}

In my firebase-service.ts file===**====

export class FireBaseService {
protected token:any;
public firebasePlugin;

async getFirebaseXToken() {
let token;
this.firebasePlugin = (window).FirebasePlugin;
token = await this.firebasePlugin.getToken(token => {
console.log('Response from getToken===>>>>',token);
});
}
}

These are the specs for my ionic3 project: "cordova": "^9.0.0", "cordova-android": "8.1.0", "cordova-plugin-firebasex": "^8.1.1", "cordova-android-play-services-gradle-release": "3.0.0", "cordova-android-support-gradle-release": "^3.0.0", "cordova-plugin-androidx": "^1.0.2", "cordova-plugin-androidx-adapter": "1.1.0",

"devDependencies": { "@ionic/app-scripts": "^3.2.2", "typescript": "~2.6.2" }

If there are any changes to be done in my code, am I missing something, any kind of help will be helpful. Thanks.

0 Answers
Related