gpt4 book ai didi

PHP IOS 推送通知不适用于开发

转载 作者:行者123 更新时间:2023-11-28 21:47:09 25 4
gpt4 key购买 nike

我想在开发模式下发送推送通知。我已遵循本指南 http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1

我的代码是:

<?php

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck_dev.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', 'xxxxx');

$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195',
$err,
$errstr,
60,
STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT,
$ctx);

if($fp === FALSE){
exit('error message');
}

// Create the payload body
$body['aps'] = array(
'badge' => +1,
'alert' => 'test',
'sound' => 'default',
'content-available' => +1
);

$payload = json_encode($body);

// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', 'xxxxxxxxxxxxxxxxxxxxxx') . pack('n', strlen($payload)) . $payload;

// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
fflush($fp);
if (!$result)
echo 'Message not delivered' . PHP_EOL;
else
echo 'Message successfully delivered amar'.$msg. PHP_EOL;

// Close the connection to the server
fclose($fp);
?>

问题是,当 pem 文件的密码错误或不存在时,我也总是收到“消息已成功发送”。如何解决问题?我哪里错了?

非常感谢

最佳答案

你有错误报告吗?我刚刚尝试打开您的 $fp 连接,但遇到了很多错误。

添加

ini_set('display_errors', 1);

到您的 PHP 脚本的顶部。

请参阅此代码毒蛇 ( http://codepad.viper-7.com/PlsftP )

Warning: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /code/nyl94y on line 11

Warning: stream_socket_client(): Failed to enable crypto in /code/nyl94y on line 11

Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in /code/nyl94y on line 11 PHP Warning: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /code/nyl94y on line 11 PHP Warning: stream_socket_client(): Failed to enable crypto in /code/nyl94y on line 11 PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in /code/nyl94y on line 11

关于PHP IOS 推送通知不适用于开发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29684166/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com