ios推送通知中的握手失败

时间:2017-04-10 12:29:12

标签: ios apple-push-notifications

我想向Ios设备发送推送通知,这是我的代码,

 $ctx = stream_context_create();
 stream_context_set_option($ctx, 'ssl', 'local_cert',
 ABSPATH.'apns-dev.pem');
 stream_context_set_option($ctx, 'ssl', 'passphrase', $password);


 $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 'Connected to APNS' . PHP_EOL;
 $payload = $message;
 foreach ($token as $deviceToken)
 {

 $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
 }
 $result = fwrite($fp, $msg, strlen($msg));
 if (!$result)
     echo 'Message not delivered' . PHP_EOL;
 else
     echo 'Message successfully delivered' . PHP_EOL;


 fclose($fp);

但我得到的错误如下:

  
      
  1. stream_socket_client():SSL操作失败,代码为1. OpenSSL错误消息:
      错误:14094410:SSL例程:ssl3_read_bytes:sslv3警报握手失败
  2.   
  3. stream_socket_client():无法连接到ssl://gateway.push.apple.com:2195(未知错误)
  4.   
  5. stream_socket_client():无法启用加密
  6.   

如何解决这个问题?

0 个答案:

没有答案