2016-09-08 27 views
2

我正在使用expiredate參數傳遞php。我想使用Apple推送通知更新通行證。根據Passbook文檔,您需要使用Apple推送通知服務從iOS設備觸發提款以更新存摺。如何使用PHP中的推送通知更新Apple Wallet通行證

+0

如果您正在尋找複製/粘貼代碼,那麼你來錯了地方。這些文件非常清晰,我建議你自己嘗試一下,如果遇到困難,請回到特定的編程問題。 – PassKit

+0

你在問什麼?您的聲明「根據Passbook文檔,您需要使用Apple推送通知服務觸發iOS設備的拉取操作,以便更新Passbook。」是正確的。 – PassKit

+0

也有很多解決你的問題的答案。 http://stackoverflow.com/questions/15877496/how-to-make-a-push-notification-for-a-pass,http://stackoverflow.com/questions/34310956/update-passes-of-passbook。 – PassKit

回答

0

這是我的PHP代碼推送通知給APNS。你可以參考。

$apnsHost = 'gateway.push.apple.com'; 
$apnsPort = 2195; 
$apnsCert = base_path('certificates.pem'); 
$push_token = 'device token'; 
$passIdentify = 'pass indentify'; 

$payload = '{}'; 
$msg = chr(0) . pack('n', 32) . pack('H*', $push_token) . pack('n', strlen($payload)) . $payload . pack('n', strlen($passIdentify)) . $passIdentify; 

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

fwrite($apns, $msg); 

@socket_close($apns); 
fclose($apns); 

的certificates.pem是您用來登錄您的傳中擴展名爲.p12相同的證書。所以,你需要使用下面的代碼

$ cd ~/Desktop 
$ openssl pkcs12 -in WenderCastPush.p12 -out WenderCastPush.pem -nodes -clcerts 

根據本教程https://www.raywenderlich.com/123862/push-notifications-tutorial#comments來導出爲.pem。

+0

它目前是否在您的服務器上運行並通過推送更新傳遞?因爲我已經嘗試了這一點,並沒有在我身邊工作。有什麼建議麼? –

+0

@tahirwaseer對不起,這不是正確的答案。請試試這個http://stackoverflow.com/questions/39849883/cant-push-notification-to-apns-to-update-my-pass-in-apple-wallet?noredirect=1#comment66998009_39849883 –

+0

謝謝@Hoang Trung 。我會嘗試的。 –