I implemented the nativescript-firebase (https://github.com/EddyVerbruggen/nativescript-plugin-firebase) plugin in my mobile app. It used to work fine but since I updated to the 11.1.3 version I cannot get the push token. I tried to get back to the 10.6.3 version but it says it is not available anymore when I execute npm install.
Here is what I do in my main.js
import { messaging } from "@nativescript/firebase/messaging";
import { firebase } from "@nativescript/firebase"
firebase.init({
onMessageReceivedCallback: function(message) {
//do stuff
}
}).then(function () {
messaging.getCurrentPushToken().then(token => {
console.log(token)
}).catch(e => {
console.log(e);
})
},function (error) {
console.log("firebase.init error: " + error);
});
This does not log the token but goes into the catch and logs this
Uncomment firebase-messaging in the plugin's include.gradle first
Here is my package.json
{
"name": "*****",
"main": "./src/main.js",
"version": "4.4.0",
"description": "A native application built with NativeScript-Vue",
"author": "*****",
"license": "PropriƩtaire",
"dependencies": {
"@carployee/openapp": "^1.0.1",
"@nativescript-community/ui-material-bottomnavigationbar": "^6.2.4",
"@nativescript/appavailability": "^2.0.0",
"@nativescript/appversion": "^2.0.0",
"@nativescript/camera": "^5.0.10",
"@nativescript/core": "~8.1.5",
"@nativescript/datetimepicker": "^2.1.9",
"@nativescript/firebase": "^11.1.3",
"@nativescript/imagepicker": "^1.0.6",
"@nativescript/ios": "^8.1.0",
"@nativescript/iqkeyboardmanager": "^2.0.0",
"@nativescript/theme": "^3.0.2",
"@nstudio/nativescript-cardview": "^2.0.1",
"@nstudio/nativescript-loading-indicator": "^4.1.0",
"@nstudio/nativescript-pulltorefresh": "^3.0.1",
"@proplugins/nativescript-purchase": "git+https://gitlab.******",
"@vue/devtools": "^5.3.4",
"nativescript-dna-deviceinfo": "^3.7.3",
"nativescript-feedback": "^2.0.0",
"nativescript-google-maps-sdk": "^3.0.2",
"nativescript-inappbrowser": "^3.1.2",
"nativescript-open-app": "^0.3.0",
"nativescript-phone": "^3.0.2",
"nativescript-socketio": "^3.3.1",
"nativescript-toasty": "^3.0.0-alpha.2",
"nativescript-ui-dataform": "^8.0.1",
"nativescript-ui-listview": "^10.0.2",
"nativescript-ui-sidedrawer": "^10.0.2",
"nativescript-vue": "^2.9.0",
"nativescript-vue-devtools": "^1.5.1",
"nativescript-vue-fonticon": "^1.0.3",
"nativescript-websockets": "^2.0.0",
"npm-check": "^5.9.2",
"npm-check-updates": "^12.0.2"
},
"devDependencies": {
"@babel/core": "^7.16.0",
"@babel/preset-env": "^7.16.4",
"@nativescript/android": "~8.1.1",
"@nativescript/webpack": "~5.0.1",
"babel-loader": "^8.2.3",
"nativescript-vue-template-compiler": "^2.9.0",
"nativescript-worker-loader": "~0.12.1",
"sass": "^1.44.0",
"vue-loader": "^15.9.8"
}
}
The message points you to the plugin's include.gradle file, or more specifically,
<app name>/node_modules/@nativescript/firebase/platforms/android/include.gradle
where you want to uncomment the line as shown below:
// Cloud Messaging (FCM)
implementation "com.google.firebase:firebase-messaging:20.1.0"
// implementation "me.leolin:ShortcutBadger:1.1.22@aar"
I expect if you reinstall the plugin you can answer the prompts so that this will get set for you.