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
JavaScript
x
16
16
1
import { messaging } from "@nativescript/firebase/messaging";
2
import { firebase } from "@nativescript/firebase"
3
firebase.init({
4
onMessageReceivedCallback: function(message) {
5
//do stuff
6
}
7
}).then(function () {
8
messaging.getCurrentPushToken().then(token => {
9
console.log(token)
10
}).catch(e => {
11
console.log(e);
12
})
13
},function (error) {
14
console.log("firebase.init error: " + error);
15
});
16
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
JavaScript
1
56
56
1
{
2
"name": "*****",
3
"main": "./src/main.js",
4
"version": "4.4.0",
5
"description": "A native application built with NativeScript-Vue",
6
"author": "*****",
7
"license": "Propriétaire",
8
"dependencies": {
9
"@carployee/openapp": "^1.0.1",
10
"@nativescript-community/ui-material-bottomnavigationbar": "^6.2.4",
11
"@nativescript/appavailability": "^2.0.0",
12
"@nativescript/appversion": "^2.0.0",
13
"@nativescript/camera": "^5.0.10",
14
"@nativescript/core": "~8.1.5",
15
"@nativescript/datetimepicker": "^2.1.9",
16
"@nativescript/firebase": "^11.1.3",
17
"@nativescript/imagepicker": "^1.0.6",
18
"@nativescript/ios": "^8.1.0",
19
"@nativescript/iqkeyboardmanager": "^2.0.0",
20
"@nativescript/theme": "^3.0.2",
21
"@nstudio/nativescript-cardview": "^2.0.1",
22
"@nstudio/nativescript-loading-indicator": "^4.1.0",
23
"@nstudio/nativescript-pulltorefresh": "^3.0.1",
24
"@proplugins/nativescript-purchase": "git+https://gitlab.******",
25
"@vue/devtools": "^5.3.4",
26
"nativescript-dna-deviceinfo": "^3.7.3",
27
"nativescript-feedback": "^2.0.0",
28
"nativescript-google-maps-sdk": "^3.0.2",
29
"nativescript-inappbrowser": "^3.1.2",
30
"nativescript-open-app": "^0.3.0",
31
"nativescript-phone": "^3.0.2",
32
"nativescript-socketio": "^3.3.1",
33
"nativescript-toasty": "^3.0.0-alpha.2",
34
"nativescript-ui-dataform": "^8.0.1",
35
"nativescript-ui-listview": "^10.0.2",
36
"nativescript-ui-sidedrawer": "^10.0.2",
37
"nativescript-vue": "^2.9.0",
38
"nativescript-vue-devtools": "^1.5.1",
39
"nativescript-vue-fonticon": "^1.0.3",
40
"nativescript-websockets": "^2.0.0",
41
"npm-check": "^5.9.2",
42
"npm-check-updates": "^12.0.2"
43
},
44
"devDependencies": {
45
"@babel/core": "^7.16.0",
46
"@babel/preset-env": "^7.16.4",
47
"@nativescript/android": "~8.1.1",
48
"@nativescript/webpack": "~5.0.1",
49
"babel-loader": "^8.2.3",
50
"nativescript-vue-template-compiler": "^2.9.0",
51
"nativescript-worker-loader": "~0.12.1",
52
"sass": "^1.44.0",
53
"vue-loader": "^15.9.8"
54
}
55
}
56
Advertisement
Answer
The message points you to the plugin’s include.gradle file, or more specifically,
JavaScript
1
2
1
<app name>/node_modules/@nativescript/firebase/platforms/android/include.gradle
2
where you want to uncomment the line as shown below:
JavaScript
1
4
1
// Cloud Messaging (FCM)
2
implementation "com.google.firebase:firebase-messaging:20.1.0"
3
// implementation "me.leolin:ShortcutBadger:1.1.22@aar"
4
I expect if you reinstall the plugin you can answer the prompts so that this will get set for you.