i'm in trouble with ionic firebase module (https://ionicframework.com/docs/native/firebase/) during the last 2 days.
I don't understand why my firebase token is alway NULL in the following code section in app.component.ts
:
this.platform.ready().then(() => {
this.firebase.getToken().then(firebaseTokenSuccess).catch(firebaseTokenFailure);
this.firebase.onTokenRefresh().subscribe(firebaseTokenRefresh);
function firebaseTokenRefresh(tkn) {
return alert("New token received: " + JSON.stringify(tkn));
}
function firebaseTokenSuccess(tkn) {
return alert("Token access success: " + JSON.stringify(tkn));
}
function firebaseTokenFailure(e) {
return alert("Token access failure: " + e.toString());
}
});
If i had grantPermission()
at the beggining of the ready block my token become an empty string
I ran the following command to install my plugin :
$ ionic plugin rm cordova-plugin-firebase
$ npm install @ionic-native/push --save
Here is the list of my plugins :
$ ionic plugins
com.googlemaps.ios 2.4.0 "Google Maps SDK for iOS"
cordova-android-play-services-gradle-release 1.1.1 "cordova-android-play-services-gradle-release"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-device 1.1.6 "Device"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-firebase 0.1.24 "Google Firebase Plugin"
cordova-plugin-googlemaps 1.4.5 "cordova-googlemaps-plugin"
cordova-plugin-inappbrowser 1.7.1 "InAppBrowser"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.3 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
And here is my project architecture :
$ tree -L 1
.
├── appli_dev.keystore
├── bower_components
├── build.gradle
├── config.xml
├── GoogleService-Info.plist
├── google-services.json
├── hooks
├── init.sh
├── ionic.config.json
├── node_modules
├── package.json
├── package-lock.json
├── platforms
├── plugins
├── README.md
├── resources
├── src
├── tsconfig.json
├── tslint.json
└── www
EDIT: Iadded the line alert(JSON.stringify(this.firebase))
which give me the following string {}
Thanks for reading :)
EDIT :
I found out that it was a recent but in firebase API. I had to update my package with git repo's HEAD