푸시 알림 및 Android 애플리케이션 개발을 위해 Adobe phonegap 플러그인을 사용하고 있습니다. 푸시 알림을 보낼 수PhoneGap Adobe 플러그인을 사용하는 Android 푸시 알림
http://www.adobe.com/devnet/phonegap/articles/android-push-notifications-with-phonegap.html
서버는 컴파일 안드로이드 코드 내가 REGID에 등록 성공을 얻고 후
<?php
// Replace with real BROWSER API key from Google APIs
$apiKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
// Replace with real client registration IDs
$registrationIDs = array("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
// Message to be sent
$message = "there is an update, waiting for you to install...";
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array("message" => $message),
);
$headers = array(
'Authorization: key=' . $apiKey,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
// Close connection
curl_close($ch);
echo $result;
로 PHP입니다.
알림을 전송 한 후 응답이
{
multicast_id: 5022434288122138000,
success: 1,
failure: 0,
canonical_ids: 0,
results: [
{
message_id: "0:1361774232591520%8eab850df9fd7ecd"
}
]
}
로 성공하지만 여전히 내 휴대 전화에 알림을 얻을 수 없습니다입니다.
잘 모르겠습니다.
편집 :
내가 푸시 알림 메시지가 표시되었지만 표시되지 않은죄송합니다.
죄송합니다. 푸시 알림 메시지가 표시되었지만 표시되지 않았습니다. – Pawan
bcoz에게 알림을 보낼 수 없습니다. 작성한 것과 동일한 코드를 작성한 후 내 서버에이 페이지를 업로드 한 후 실행하면 "Unauthorized Error 401"과 같은 오류가 발생했습니다. 이 내 URL http://stackoverflow.com/questions/23677313/android-phonegap-send-push-notification-using-google-cloud-messaging-using-php –