发送推送到IOS时出错

发送推送到IOS时出错,ios,push-notification,apple-push-notifications,Ios,Push Notification,Apple Push Notifications,错误: 警告:流\u套接字\u客户端():无法在中启用加密 /home/########################/testpushnotification.php,第28行 警告:流\u套接字\u客户端():无法连接到 ssl://gateway.push.apple.com:2195 中的(未知错误) /第28行的home/##################/public#html/###### 要连接:0 这是我的代码: $apnsPort = 2195; $badgecount

错误:

警告:流\u套接字\u客户端():无法在中启用加密 /home/########################/testpushnotification.php,第28行

警告:流\u套接字\u客户端():无法连接到 ssl://gateway.push.apple.com:2195 中的(未知错误) /第28行的home/##################/public#html/###### 要连接:0

这是我的代码:

$apnsPort = 2195;
$badgecount = 1;

  $streamContext = stream_context_create();
  stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
  $apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
   if (!$apns)
   {

  exit("Failed to connect: $error $errorString" . PHP_EOL);
} else
{
    $payload['aps'] = array('alert' => $message,'badge' => $count, 'sound' => 'default');
    $output = json_encode($payload);

   $token = pack('H*', str_replace(' ', '', $deviceToken));

   $apnsMessage = chr(0) . chr(0) . chr(32) . $token . chr(0) . chr(strlen($output)) . $output;
   fwrite($apns, $apnsMessage);
您可以参考教程了解推送通知。检查证书,您可以检查或使用一个参考php代码文件来检查推送通知