iphone - 推送通知 iPhone

标签 iphone apple-push-notifications php

我使用这段代码来推送:

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);
}

但这是错误的:

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

最佳答案

消息是明确的:certificate revoked
您的证书无效、证书已过期或您在 Apple 门户中单击了“撤销”证书。

您可以为此 appId 生成一个新证书,并将其安装到您的服务器上。

关于iphone - 推送通知 iPhone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7121922/

相关文章:

php 子字符串 'dot'

php mysql 使用 pdo 对同一个表进行联接查询

iPhone 核心数据示例产生异常

iphone - 在 Xcode 4.2 的 UIWebView 中加载网页——如何正确连接 IBOutlets 并确保网页加载?

ios - iPhone 4 英寸和 4.7 英寸屏幕的图像缩放

iOS通知开发环境: how do you properly set up APNS?

ios - 如何在 iOS 中为自定义键盘制作删除按钮?

c# - 当用户点击 ios/xamarin 通知中心的通知时触发什么事件

ios - Swift:从 AppDelegate 中的 UNTextInputNotificationAction 获取内容

PHP pcntl模块安装