標籤:style blog http java color 使用
在配置 P12 認證檔案之前, 我們要準備三個檔案
1、PushChat.certSigningRequest 請求認證檔案
2、PushChatKey.p12 請求認證檔案後, 在認證秘鑰中產生了一個公開金鑰和私密金鑰, 通過私密金鑰匯出的p12檔案
3、aps_developer_identity.cer 使用請求認證檔案 產生的 推送認證
擷取到的deviceToken,我們可以通過webservice服務提交給.net應用程式,這裡我簡單處理,直接列印出來,拷貝到.net應用環境中使用。
發送通知的.net應用程式出來需要知道deviceToken之外,還需要一個與APNS串連的認證。
這個認證可以通過我們前面產生的兩個檔案中得到。
具體配置操作:
使用OpenSSL
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次密碼,密碼都設定為:abc123。
openssl pkcs12 -nocerts -out PushChat_Noenc.pem -in PushChatKey.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
這樣我們就得到了在.net應用程式中使用的認證檔案:aps_developer_identity.p12。
在.net應用程式中發送通知。
有個開源的類庫:apns-sharp。
地址是:http://code.google.com/p/apns-sharp/。
我們下載原始碼,對裡面的JdSoft.Apple.Apns.Notifications做相應的調整就能用了。
我們根據DeviceToken和p12File對JdSoft.Apple.Apns.Notifications.Test做相應的調整,如。
這樣就OK了。