Update Passbook wallet failed to connect

旧城冷巷雨未停 提交于 2019-12-12 04:16:21

问题


i'm struck with update wallet push notiifcation,i used bellow code,server not connected error.

I missed any credentials.please help to me ,fix this issue.

I registered my passbook and get back pushtoken to server.

this key same as the passbook generate certificate key.

            $certifile = 'passbook/certificates/AppleWWDRCA.pem'; 
            $passphrase = 'xxxxxxxx';
            $trust ='';
            $url = 'ssl://gateway.push.apple.com:2195';
            $ctx = stream_context_create();
            stream_context_set_option($ctx, 'ssl', 'local_cert', $certifile);
            stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
            $fp = stream_socket_client($url, $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);

            if (!$fp)
                exit("Failed to connect: $err $errstr" . PHP_EOL);
            echo 'Connected to APNS' . PHP_EOL;
            $body['aps'] = array(
                'alert' => $message,
                'sound' => 'default',
                'pushToken'=>'xxxxxxxxxxxxxx',
                 'passTypeId'=>'xxxxxxxxx'

            );

            $payload = json_encode($body);

            $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;

            $result = fwrite($fp, $msg, strlen($msg));

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

Please help to me.


Connected to server.but i have error in sending push notifictaion.

$body['aps'] = array( );
$msg = chr(0) . pack('n', 32) . pack('H*', $pushToken) . pack('n', strlen($payload)) . $payload;

if (!$result)
            echo 'Message not delivered' . PHP_EOL;
        else
            echo 'Message successfully delivered' . PHP_EOL;

Message not delivered: 10053.

user booking time dynamically pass created and display to device.

if user modify the booking date .I need to update dynamically booking date and time to user pass via pushnotification.

any one please help to me update my passbook.


回答1:


check here for PHP code (first answer). It's work for me. PHP Apple Enhanced Push Notification read error response

You use the wrong certification. You have to make pem file from your pass certification (p12) by export from keychain.

How to make P12 and PEM file from cer file
1. move into save folder
2. open terminal and cd to that folder
openssl x509 -inform der -in aps_development.cer -out certificate.pem
openssl pkcs12 -nocerts -in Certiticates.p12 -out p12Certificates.pem
[type password for .p12 and password for .pem]
cat certificate.pem p12Certificates.pem > apns_cert.pem



来源:https://stackoverflow.com/questions/34784620/update-passbook-wallet-failed-to-connect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!