nativescript-firebase 获取推送令牌的问题
nativescript-firebase issue to get push token
我在我的移动应用程序中实现了 nativescript-firebase (https://github.com/EddyVerbruggen/nativescript-plugin-firebase) 插件。它曾经工作正常,但自从我更新到 11.1.3 版本后,我无法获得推送令牌。我试图回到 10.6.3 版本,但是当我执行 npm install 时它说它不再可用。
这是我在 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);
});
这不会记录令牌,但会进入捕获并记录此
Uncomment firebase-messaging in the plugin's include.gradle first
这是我的 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"
}
}
该消息将您指向插件的 include.gradle 文件,或更具体地说,
<app name>/node_modules/@nativescript/firebase/platforms/android/include.gradle
您要取消注释行的位置,如下所示:
// Cloud Messaging (FCM)
implementation "com.google.firebase:firebase-messaging:20.1.0"
// implementation "me.leolin:ShortcutBadger:1.1.22@aar"
我希望如果您重新安装插件,您可以回答提示,以便为您设置。
我在我的移动应用程序中实现了 nativescript-firebase (https://github.com/EddyVerbruggen/nativescript-plugin-firebase) 插件。它曾经工作正常,但自从我更新到 11.1.3 版本后,我无法获得推送令牌。我试图回到 10.6.3 版本,但是当我执行 npm install 时它说它不再可用。
这是我在 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);
});
这不会记录令牌,但会进入捕获并记录此
Uncomment firebase-messaging in the plugin's include.gradle first
这是我的 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"
}
}
该消息将您指向插件的 include.gradle 文件,或更具体地说,
<app name>/node_modules/@nativescript/firebase/platforms/android/include.gradle
您要取消注释行的位置,如下所示:
// Cloud Messaging (FCM)
implementation "com.google.firebase:firebase-messaging:20.1.0"
// implementation "me.leolin:ShortcutBadger:1.1.22@aar"
我希望如果您重新安装插件,您可以回答提示,以便为您设置。