得到警告消息,同时发送推送通知到多个iPhone设备 [英] getting warning messages while sending push notification to multiple iphone device

查看:307
本文介绍了得到警告消息,同时发送推送通知到多个iPhone设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我使用PHP Web服务我收到警告消息如发送推送通知到多个iPhone设备:

While i am sending push notifications to multiple iphone devices using php webservices i am getting warning messages like :

Warning: stream_socket_client() [function.stream-socket-client]: SSL: crypto enabling timeout in /home/sample_app/pushnotification.php on line 66

Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /home/sample_app/pushnotification.php on line 66

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /home/sample_app/pushnotification.php on line 66

Warning: fclose() expects parameter 1 to be resource, boolean given in /home/sample_app/pushnotification.php on line 79

这是我的code:

$message='testing';
$q1="select devicetoken from tbl_devicetokens";
$re1 = mysql_query($q1);
while($row1=mysql_fetch_row($re1))
{
    pushMessage($row1[0],$message,'myapp');
}


function pushMessage($deviceToken,$message,$app) {
    echo "Sending iPhone Push Notifications to " . $deviceToken . "<br /><br />";
    echo "Your Message: " . $message . "<br /><br />";
    $time = time();
    $apnsHost = 'gateway.push.apple.com';
    $apnsPort = 2195;
    $apnsCert = 'apns-myapp.pem';
    $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) {
            $payload = array();
            $payload['aps'] = array('alert' => $message, 'badge' => 0, 'sound' => 'default');
            $payload = json_encode($payload);
            $apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . $payload;
            fwrite($apns, $apnsMessage);
    } else { 
            echo "Connection Failed - iPhone Push Notifications Server";
            echo $errorString."<br />";
            echo $error."<br />";
    }
    //socket_close($apns);
    fclose($apns);
}

所以,任何一个可以告诉我怎么解决这个问题。

So, can any one tell me how to solve this problem

推荐答案

当你推一个通知到一台设备是否这仍然发生?

Does this still happen when you push a single notification to a single device?

如果它:


  • 你确定你有正确的路径证书?

  • 确保该证书文件名不包含除字母字符等。

如果不是:


  • 确保您使用正确的设备环境的正确证书(研发,生产)

  • 如果某个设备越狱它不会收到推送通知。

这篇关于得到警告消息,同时发送推送通知到多个iPhone设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆