天天看點

java apns 推送消息到iphone裝置

java代碼比較簡單,可是使用開源的類庫 如https://github.com/notnoop/java-apns

估計卡住的人通常是和apns握手失敗。這原因主要是java、.net和mac的ssl連接配接差別.

java需要把下載下傳的檔案再次轉換才可以使用。

參考:

1、将aps_developer_identity.cer轉換成 aps_developer_identity.pem格式。

openssl x509 -in aps_developer_identity.cer -inform DER -out aps_developer_identity.pem -outform PEM

2、将p12格式的私鑰轉換成pem,需要設定4次密碼,這裡密碼都設定為:123456。

openssl pkcs12 -nocerts -out PushChat_Noenc.pem -in PushChat.p12

3、用certificate和the key 建立PKCS#12格式的檔案。

openssl pkcs12 -export -in aps_developer_identity.pem -inkey PushChat_Noenc.pem -certfile PushChat.certSigningRequest -name "aps_developer_identity" -out aps_developer_identity.p12

這樣我們就得到了在java、或者.net應用程式中使用的證書檔案:aps_developer_identity.p12

openssl 指令可以直接在mac終端執行