谷歌已经创建了火力地堡的推送通知。 Google强烈建议使用FCM而不是旧的GCM。
在目前的FCM科尔多瓦推送通知插件,您不需要“发件人ID”。
您对您的应用程序提供您的应用程序的名字和一些细节后注册您的应用程序在http://www.console.firebase.google.com
然后,谷歌将为您提供两个文件。
1)谷歌services.json
2)GoogleService-Info.plist中
如果您正在开发Android应用,那么你需要保持以.json文件在android的根目录。
或者如果您正在开发IOS应用程序,那么您需要将.plist文件保存在android根目录中。
然后在onDeviceReady功能index.js文件中使用此代码
FCMPlugin.getToken(
function(token){
//alert(token);
$.post("http://example.com/api/addToken",{tok:token},function(data){
if(data)
{
// DO some function here if the token is added to the database
}
});
},
function(err){
console.log('error retrieving token: ' + err);
alert('error retrieving token: ' + err);
}
)
这就是全部。检查这是否适用于你或至少不为我工作.. :)