안드로이드 개발 질문/답변
(글 수 45,052)
일단 테스트겸
registration id랑 권한 얻는 것 까지 성공하고
동일 단말기로 보내기 위해 제 단말기 registration id로 메시지를 보내게 만들었습니다
그런데 이 과정에서 브로드캐스트리시버가 아무런 인텐트도 받지 않습니다..
예를들어 send라는 메소드로 https://android.apis.google.com/c2dm/send 프로토콜을 수행하여 메시지를 보낸다고 하면
어떤 에러도 발견되지 않고 다만 리시버가 아무 반응이 없습니다
메니페스트 파일에서 추가해야 하는 퍼미션 설정 모두 이상이 없고 소스에도 문제가 없는데
단순 구글 서버의 문제일까요?




소스에 문제가 있는것 같습니다.
기존에 c2dm 송수신이 되던게 안되는거면 서버겠지만 그게 아닌경우 소스 문제지요.
php로 c2dm 보내는 샘플 첨부합니다.
<? $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = array('accountType' => 'HOSTED_OR_GOOGLE', 'Email' => '메일주소', 'Passwd' => '패스워드', 'source'=>'test-1.0', 'service'=>'ac2dm'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $result = curl_exec($ch); $auth = substr(strstr($result, "Auth="), 5); $auth = substr($auth, 0, strlen($auth)-1); curl_setopt($ch, CURLOPT_URL, "https://android.apis.google.com/c2dm/send"); $data = "레지 ID"."&collapse_key=1"."&data.msg=TEST할 전송내용"; curl_setopt($ch, CURLOPT_POSTFIELDS, $data);$headers = array( "Content-Type: application/x-www-form-urlencoded", "Content-Length: ".strlen($data), "Authorization: GoogleLogin auth=$auth" ); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); echo $result."\n"; curl_close($ch); ?>