推通知iPhone [英] Push Notify iPhone

查看:361
本文介绍了推通知iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个code推:

 推(XXXX,3);功能推($ deviceToken,$徽章){    $消息=C'è金正日文托IDEALE!
    $声音=默认;    //构造通知有效载荷
    $身体=阵列();
    $身体['APS'] =阵列(
        警戒=> $消息
    );    如果($徽章){
        $身体['APS'] ['徽章'] = $徽章;
    }    如果($音){
        $身体['APS'] ['音'] = $的声音;
    }    $ CTX = stream_context_create();
    stream_context_set_option($ CTX,SSL,的local_cert',​​'APNS-dev.pem');
    $计划生育=在stream_socket_client(SSL://gateway.sandbox.push.apple.com:2195,$犯错,$ errstr,60,STREAM_CLIENT_CONNECT,$ CTX);    如果(!$ FP){
    PRINT无法连接$犯错$ errstrn
        返回;
    }其他{
        打印连接OK \\ N的;
    }    $有效载荷= json_en code($体);
    $味精= CHR(0)。包('N',32)。包(H *',str_replace函数('','',$ deviceToken))。包('N',strlen的($有效载荷))。 $有效载荷;
    打印发送消息。 $有效载荷。 \\ n;
    FWRITE($ FP,$味精);
    FCLOSE($ FP);
}

但是,这是错误:


  

警告:在stream_socket_client()[function.stream插槽客户端]:SSL操作失败,code 1. OpenSSL的错误信息:错误:14094414:SSL例程:SSL3_READ_BYTES:在撤销的SSLv3警报证书/ XXXX /通知.PHP上线75


  
  

警告:在stream_socket_client()[function.stream插槽客户端]:失败,使上线75 /xxxx/notify.php加密


  
  

警告:在stream_socket_client()[function.stream插槽客户端]:无法连接到SSL:在/xxxxx/notify.php 2196(未知错误)上线://gateway.sandbox.push.apple.com 75
  无法连接0



解决方案

发出的信息是明确的:证书被吊销结果
您的证书无效,证书已过期或您点击'取消'在苹果门户网站的证书。搜索结果
您可能会生成此APPID新证书,并在服务器上安装它。

I use this code to push:

push("xxxx", 3);

function push($deviceToken, $badge) {

    $message = "C'è il vento ideale!!";
    $sound = "default";

    // Construct the notification payload
    $body = array();
    $body['aps'] = array(
        "alert" => $message
    );

    if ($badge) {
        $body['aps']['badge'] = $badge;
    }

    if ($sound) {
        $body['aps']['sound'] = $sound;
    }

    $ctx = stream_context_create();
    stream_context_set_option($ctx, 'ssl', 'local_cert', 'apns-dev.pem');
    $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);
}

But this is the error:

Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094414:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate revoked in /xxxx/notify.php on line 75

Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /xxxx/notify.php on line 75

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2196 (Unknown error) in /xxxxx/notify.php on line 75 Failed to connect 0

解决方案

The message is explicit : certificate revoked.
Your certificate is not valid, the certificate is expired or you have clicked on 'revoke' the certificate in the Apple portal.

You may generate a new certificate for this appId, and install it on your server.

这篇关于推通知iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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