【发布时间】:2016-10-25 14:20:47
【问题描述】:
我用推送消息构建了一个应用程序 我得到消息插件不再可用。
“此应用使用 PhoneGap Build 存储库中的插件。这些插件在 2016 年 11 月 15 日之后将无法访问”
pushplugin 的 config.xml:
这是我的代码:
try {
pushNotification = window.plugins.pushNotification;
if (device.platform == 'android' || device.platform == 'Android' || device.platform == 'amazon-fireos') {
pushNotification.register(pushsuccessHandler, pusherrorHandler, {
"senderID": "123456789",
"ecb": "onNotification"
});
} else {
pushNotification.register(tokenHandler, pusherrorHandler, { "badge": "true", "sound": "true", "alert": "true", "ecb": "onNotificationAPN" });
}
}
catch (err) {
txt = "There was an error on this page.\n\n";
txt += "Error: " + err.message + "\n\n";
console.log(txt);
}
// 处理 Android 的 GCM 通知 函数 onNotification(e) { 切换(e.event){
case 'registered':
alert(e.regid);
if (e.regid.length > 0) {
alert(e.regid);
var jsonText = {
userName: empId.value,
RegId: e.regid,
IsAndroid: 1,
}
$.ajax({
type: "Post",
url: basePath + "ExternalWebService.asmx/SaveRegId",
data: JSON.stringify(jsonText),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
alert("secccess saveRegId");
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.responseText + " " + xhr.error);
alert("error saveRegId");
}
});
}
break;
case 'message':
var snd = new Media("./audio/sound.mp3");
snd.play();
if (e.foreground) {//when the application is in the foreground (we can see it)
window.location.reload();
}
else { // otherwise we were launched because the user touched a notification in the notification tray.
if (e.coldstart) {//when the application is closed
window.location.reload();
}
else {//when the application is open but in the background (we can’t see it)
window.location.reload();
}
}
break;
case 'error':
console.log('ERROR -> MSG:' + e.msg + '');
break;
default:
console.log('Unknown, an event was received and we do not know what it is');
break;
}
}
// handle callback notifications
function pushsuccessHandler(result) {
alert('pushNotification register success:' + result + '');
}
function pusherrorHandler(error) {
alert('pushNotification register error:' + error + '');
}
function tokenHandler(result) {
console.log('token: ' + result + '');
var jsonText = {
userName: empId.value,
RegId: result,
IsAndroid: 0,
}
$.ajax({
type: "Post",
url: basePath + "ExternalWebService.asmx/SaveRegId",
data: JSON.stringify(jsonText),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
console.log("secccess saveRegId");
},
});
}
【问题讨论】:
-
正在寻找同样的东西,兄弟