我正在构建离子应用, 对于推送通知,我使用了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
UICollectionView
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-plugin-fcm app工作没有任何错误