我正在尝试使用 PhoneGap 制作一个非常简单的 Android/iPhone 应用程序。
即使应用没有在用户设备上运行,向应用发送推送通知的最简单方法是什么?
最佳答案
使用push notification phonegap插件:
onNotificationGCM: function(e) {
switch (e.event) {
case 'registered':
if (e.regid.length > 0) {
console.log("Regid " + e.regid);
alert('registration id = ' + e.regid);
}
break;
case 'message':
// this is the actual push notification. its format depends on the data model from the push server
alert('message = ' + e.message + ' msgcnt = ' + e.msgcnt);
break;
case 'error':
alert('GCM error = ' + e.msg);
break;
default:
alert('An unknown GCM event has occurred');
break;
}
}
完整的使用指南可以在这里找到:http://devgirl.org/2013/07/17/tutorial-implement-push-notifications-in-your-phonegap-application/
关于javascript - PhoneGap 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27524792/