2011-05-06 5 views
2

푸시 알림을 사용하는 Iphone 앱에서 일하고 있습니다. 이전에 제대로 작동했기 때문에 갑자기 작동이 중지되었습니다. 내 PHP 코드는 내가 연결 확인 메시지를 보내는 무엇입니까푸시 알림 APNS가 갑자기 작동을 멈췄습니다. 샌드 박스 - ph

<?php 

$deviceToken = ''; // masked for security reason 
// Passphrase for the private key (ck.pem file) 
$pass = 'appendit'; 
// Get the parameters from http get or from command line 
$message = $_GET['message'] or $message = $argv[1] or $message = 'Test Message'; 
$badge = (int)$_GET['badge'] or $badge = (int)$argv[2]; 
$sound = $_GET['sound'] or $sound = $argv[3]; 
// Construct the notification payload 
$body = array(); 
$body['aps'] = array('alert' => $message); 
if ($badge) 
$body['aps']['badge'] = $badge; 
if ($sound) 
$body['aps']['sound'] = $sound; 
/* End of Configurable Items */ 
$ctx = stream_context_create(); 
stream_context_set_option($ctx, 'ssl', 'local_cert', 'apns-dev.pem'); 
// assume the private key passphase was removed. 
stream_context_set_option($ctx, 'ssl', 'passphrase', $pass); 
$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 "Connection OK \n"; 
} 
$payload = json_encode($body); 
$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); 
?> 

입니다 : { "APS": { "경고": "테스트 메시지"}} 브라우저에서 실행하는 동안. 어떤 생각이 거기에 잘못 될 수 있습니까?

감사합니다.

답변

0

내 인증서는 만료되었습니다. 나는 만료 된 개발 인증서를 가지고 있었고 Apple은 도착하지는 않았지만 불만없이 메시지를 받아 들였습니다. 인증서를 업데이트하면 메시지 도착이 시작되었습니다.

관련 문제