本地描述firebase问题以获取推送令牌



我实现了nativescriptfirebase(https://github.com/EddyVerbruggen/nativescript-plugin-firebase)我的手机应用程序中的插件。它过去工作得很好,但由于我更新到11.1.3版本,我无法获得推送令牌。我试图回到10.6.3版本,但它说当我执行npm安装时,它不再可用。

以下是我在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"

我希望如果你重新安装插件,你可以回答提示,这样就可以为你设置了。

最新更新