我正在构建离子应用程序,对于推送通知,我使用了cordova-plugin-fcm以及fcm.js中的所有其他代码
但安装插件后 cordova-plugin-fcm 我再也无法构建android应用了,
在ionic build android命令中出错
无法解析配置':_debugApkCopy'的所有依赖项 . 找不到com.google.firebase:firebase-core:11.2.0 . 项目所需无法找到com.google.firebase:firebase-messeging:11.2.0 . 项目要求
FCM.js
angular.module("home")
.factory("FCM", function (APIService, userData, $state, $rootScope) {
function initFCM() {
if (typeof (FCMPlugin) !== "undefined") {
FCMPlugin.getToken(function (token) {
APIService.addFCMToken({
tokenid: token,
loginid: userData.login.login_id,
}).then(function () {
service.receivePush();
})
}, function (error) {
alert(error);
});
FCMPlugin.onTokenRefresh(function (token) {
APIService.addFCMToken({
tokenid: token,
loginid: userData.login.login_id,
}).then(function () {
service.receivePush();
})
});
} else {
//alert( 'admob plugin not ready' );
}
}
var service = {
initFCM: initFCM,
receivePush: function () {
FCMPlugin.onNotification(function (data) {
if (data.wasTapped === false || data.wasTapped == undefined) {
//Notification was received in foreground. Maybe the user needs to be notified.
if (data.event == "1")
$rootScope.$broadcast("new-post", data);
if (data.event == "4")
$rootScope.$broadcast("update-vote", data);
if (data.event == "2")
$rootScope.$broadcast("update-like", data);
if (data.event == "3")
$rootScope.$broadcast("update-comment", data);
if (data.event == "5")
$rootScope.$broadcast("comment-like", data);
} else {
//Notification was received on device tray and tapped by the user.
$state.go("single-post", { companyId: data.company_id, postId: data.post_id });
}
});
},
subscribe: function (topic) {
FCMPlugin.subscribeToTopic(topic);
},
unsubscribe: function (topic) {
FCMPlugin.unsubscribeToTopic(topic);
}
}
return service;
})
ionic info
输出 -
Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 7
Node Version: v8.1.4
Xcode version: Not installed
如果我删除cordova-plugin-fcm app正在运行,没有任何错误