안녕하세요 내 앱에서 푸시 알림을 만들려고합니다. 장치 토큰 및 PHP 스크립트를 가져 왔습니다. 자습서를보고 작성했지만 지금은 푸시 알림을받지 못하고 있습니다. 나는 저를 도와주세요 여기 잘못했을 경우 장치는 푸시 알림이 장치에서 작동하지 않습니다
<?php
if($_POST['message']){
$deviceToken ='here i have given my device token ';
$message = stripcslashes($_POST['message']);
$payload = '{
"aps" :
{
"alert" :"'.$message.'",
"badge" : 1,
"sound" : "bingbong.aiff"
}
}';
$ctx = stream_context_create();
stream_context_set_option($ctx,'ssl', 'local_cert','ck.pem');
stream_context_set_option($ctx,'ssl','passphrase', 'bali');
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195',$err,$errstr,60,STREAM_CLIENT_CONNECT,$ctx);
if(!fp){
print "Failed to connect $err $errstrn";
return;
}else{
print "notifications sent!";
}
$devArray = array();
$devArray[] = $deviceToken;
foreach($devArray as $deviceToken){
$msg = chr(0) . pack("n",32) . pack("H", str_replace(' ',' ',$deviceToken)).pack("n",strlen($payload)) . $payload;
print "sending message:" .$payload . "n";
fwrite($fp,$msg);
}
fclose($fp);
}
?>
내가이를 사용하여이 튜토리얼
here
를 사용하여이 스크립트를 worte ...
이 내 PHP 스크립트입니다 .. 안되지 내 로컬 호스트에서 실행하려하지만 작동하지 않는 PHP 스크립트 스크립트에서 메신저가 잘못된 부분을 알려줍니다.
감사합니다.
장치에 대한 응용 프로그램에 대한 푸시 알림을 허용 했습니까? –