대강
할건 없고. 오픈소스 프로젝트의 프로젝트대로 소스 복붙하고
자기 자신의 regid 알아낸다음에 아래에 입력해주고
노티피케이션이 실행되는지만 하면 됨.
상용화될 게임에는 regid 등록해주는 부분에서 각 DB 에 regid 등록해주고
아래 php 구문을 DB에 접속해서 DB의 regid 를 모두 호출해주는 식으로 수정해주면 될거같음.
일단 확실히 되는 php 구문임..
<?php
// Replace with real server API key from Google APIs
// 서버api Key 입력
$apiKey = "";
// Replace with real client registration IDs
// 각 핸드폰 기계의 registraitionID 입력.
$registrationIDs = array(
" ",
" ",
);
// Message to be sent
// 입력하고 싶은 메시지 입력
$message = "Test Notificación PHP";
// 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_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode( $fields ));
// Execute post
$result = curl_exec($ch);
// Close connection
curl_close($ch);
echo $result;
?>
'잡다한것들전부 > 안드로이드' 카테고리의 다른 글
| MySQL SQLite 회원가입 및 로그인 설명 (0) | 2014.11.25 |
|---|---|
| 안드로이드 baas.io (0) | 2014.08.08 |
| 안드로이드 gcm 관련 php 통신. (0) | 2014.08.07 |
| 안드로이드 유효성 검사하기 AsyncTask.. (0) | 2014.08.05 |
| 애플리케이션 오류 (0) | 2014.01.13 |
| 구글 인앱 빌링 ver 3 item already owned 오류시 해결방법 (0) | 2014.01.13 |


