1
푸시 알림을 보내려하지만 APNS에서 나에게이 응답을 보냅니다. 자원 ID # 3,이 항목은 누락 된 항목이므로 초 사과 문서, 맞죠? "주제"란 무엇입니까? 내가 도대체 뭘 잘못하고있는 겁니까? 인증서를 다시 작성하지만 문제가 아닌 것으로 생각합니다. 나는 "주제"가 무엇인지 모른다.푸시 알림을받을 수 없습니다. 응답 "리소스 ID # 3"을 수신합니다.
아래 내 서버의 PHP입니다 :
<?php
$deviceToken = $_POST["deviceToken"];
// Put your private key's passphrase here:
$passphrase = 'password';
// Put your alert message here:
$message = 'My first push notification!';
////////////////////////////////////////////////////////////////////////////////
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
// Open a connection to the APNS server
$fp = stream_socket_client(
'ssl://gateway.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
echo $fp;
echo 'Connected to APNS' . PHP_EOL;
// Create the payload body
$body['aps'] = array(
'alert' => $message,
'sound' => 'default'
);
// Encode the payload as JSON
$payload = json_encode($body);
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
{
echo 'Message not delivered' . PHP_EOL;
echo $fp;
}
else
{
echo 'Message successfully delivered' . PHP_EOL;
echo $fp;
}
// Close the connection to the server
fclose($fp);
?>
서버는 성공에 메시지를 보내지 만, 내가 전에 말했듯이 ... 내가 APNS의 응답을받을 : 3
자원을 식별 #.
무엇이 될 수 있습니까?
수정 됨수정했습니다. 문제는 URL입니다 ... 나는 gateway.sandbox.push.apple.com으로 변경했습니다. 그것이 개발의 URL입니다!
내가 제거하고 여전히 작동하지 않습니다. $ fp가 아무런 영향을 미치지 않는다는 것을 보여주십시오. APN이 내 요청을 받고이 메시지를 반환합니다. – holydev0tion