<gap:plugin name="com.phonegap.plugins.pushplugin" />
config.xml에 추가했습니다. 앱을 실행하면 전화가 인터넷에 연결되어 있지 않아도 "콜백 성공! 결과 = OK"라는 경고가 표시되고 확인을 누르면 아무런 반응이 없습니다.PushPlugin 등록 기능이 regid를 제공하지 않습니다
onNotificationGCM 이벤트가 발생하지 않으며 regid를 반환하지 않습니다.
function showAlert(message, title) {
if (navigator.notification) {
navigator.notification.alert(message, null, title, 'OK');
} else {
alert(title ? (title + ": " + message) : message);
}
}
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
$(document).ready(function() {navigator.splashscreen.hide();});
try {
var pushNotification = window.plugins.pushNotification;
pushNotification.register(successHandler, errorHandler, {"senderID":"659859389520","ecb":"onNotificationGCM"});
} catch (ex) {
showAlert(ex, 'push error');
}
setTimeout(function() {
navigator.splashscreen.hide();
}, 3000);
}
function successHandler(result) {
showAlert('Callback Success! Result = '+result, "Success");
}
function errorHandler(error) {
showAlert(error, "Error");
}
function onNotificationGCM(e) {
switch(e.event)
{
case 'registered':
if (e.regid.length > 0)
{
console.log("Regid " + e.regid);
showAlert('registration id = '+e.regid);
}
break;
case 'message':
showAlert('message = '+e.message+' msgcnt = '+e.msgcnt, "Message");
break;
case 'error':
showAlert('GCM error = '+e.msg, "Error");
break;
default:
showAlert('An unknown GCM event has occurred', "Unknown Event");
break;
}
}
ADB 로그에서 GCM은 정상적으로 작동합니다. 그것은 regid를 완벽하게 반환하지만 sendJavascript는 내 onNotificationGCM 함수를 호출하지 않습니다. 따라서 작동하지 않습니다. 왜? 내가 여기서 뭘 잘못하고 있니?
05-22 01:28:27.407: V/PushPlugin(21372): sendJavascript: javascript:onNotificationGCM({"regid":"APb91bG...Sqg4YP","event":"registered"})