웹사이트 회원 연동 푸시알림 이용안내 입니다.
<script language="javascript">
// 페이지 로딩 직후 앱에서 자동 호출 합니다.
function callFromApp() {
if (typeof app_login_complete === 'function') {
app_login_complete('회원아이디');
}
}
</script>function login() {
...
$.ajax({
type: "POST",
url: action,
data: form_data,
success: function(response) {
// 로그인 성공시
if (response == 'success') {
if (typeof app_login_complete === 'function') {
app_login_complete('회원아이디');
}
}
...
}
});
}| 구분 | 내용 |
|---|---|
| 자바스크립트 위치 | https://www.appmake.co.kr/asset/js/appmake_sendpush.js |
| 요청함수 | sendPush(no, app_srno, send_id, receive_id, title, contents, push_type=1, save_yn='Y', image='', link='') |
| 파라미터 값 | · no -> 발송요청번호, 이 번호를 이용하여 결과를 확인 · app_srno -> 앱 고유번호 (앱메이크에서 만드신 앱의 고유번호) · send_id -> 발송자 회원아이디 · receive_id -> 수신자 회원아이디 (여러명에게 전송할 경우 '|'를 이용) · title -> 푸시알림 제목 · contents -> 푸시알림 내용 · push_type -> 1 : 상단 노티 + 팝업 (기본값), 2 : 상단 노티만 · save_yn -> Y : 알림정보 저장 (기본값), N : 저장 안함 · image -> 이미지 위치 URL, 없는 경우 "" · link -> 클릭시 이동할 URL, 없는 경우 "" |
| 구분 | 내용 |
|---|---|
| 자바스크립트 위치 | 해당 페이지에 선언 |
| 요청함수 | function sendPush_result(data) {
alert(data.no + ':' + data.result + ":" + data.msg);
} |
| 파라미터 값 | · data.no -> 발송요청번호 · data.result -> Y : 발송성공, N : 발송실패 · data.msg -> 발송결과에 따른 메시지 |
| 오류메시지 정보 | · 발송자 정보가 등록되어 있지 않습니다. · 수신자 정보가 등록되어 있지 않습니다. · 등록된 도메인 정보와 맞지 않습니다. |
<script src="https://www.appmake.co.kr/asset/js/appmake_sendpush.js"></script>
<script>
// Case 1: 팝업푸시 + 상단 노티 표시
function clickButton1() {
if (typeof sendPush === 'function') {
sendPush(101, 1234, send_id, receive_id, title, contents);
}
}
// Case 2: 상단 노티에만 표시
function clickButton2() {
if (typeof sendPush === 'function') {
sendPush(102, 1234, send_id, receive_id, title, contents, 2);
}
}
// Case 3: 이미지 포함 노티
function clickButton3() {
if (typeof sendPush === 'function') {
image = 'https://www.website.co.kr/images/push_image_sample.jpg';
sendPush(103, 1234, send_id, receive_id, title, contents, 2, 'N', image);
}
}
// Case 4: 이미지 + 링크 URL
function clickButton4() {
if (typeof sendPush === 'function') {
image = 'https://www.website.co.kr/images/push_image_sample.jpg';
link = 'https://sports.v.daum.net/v/20181011170226585?f=m';
sendPush(104, 1234, send_id, receive_id, title, contents, 1, 'Y', image, link);
}
}
// 발송 결과
function sendPush_result(data) {
alert(data.no + ':' + data.result + ":" + data.msg);
}
</script><?php
$url = 'https://www.appmake.co.kr/PushClient/sendPush4ExtServer';
$post_data["no"] = 101;
$post_data["app_srno"] = 1234;
$post_data["send_id"] = "sender@gmail.com";
$post_data["receive_id"] = "receiver1@naver.com|receiver2@daum.net";
$post_data["title"] = "서버에서 푸시발송";
$post_data["contents"] = "서버에서 보내는 푸시발송 테스트 입니다.";
$post_data["push_type"] = 1;
$post_data["save_yn"] = "Y";
$post_data["image"] = "";
$post_data["link"] = "https://sports.v.daum.net/v/20181011170226585?f=m";
$post_data["key"] = "e9Vc0SiPFp9XoMrREnBD79ijmnJTHanmyghABRGm72o=";
$post_data["from"] = 2;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_POSTFIELDSIZE, 0);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, []);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$body = substr($res, $header_size);
$body_json = json_decode($body, true);
print_r($body_json);
curl_close($ch);
?>