1.開通註冊憑證 cert、p12、pem等等有的沒的...
2.在程序中加入程序拿到devicetoken
3.在push server上發送訊息
這邊主要講的是憑證的生成步驟:
假設拿到這兩個憑證檔:
adj_aps_production.cer
adj_aps_production_key.p12
最後需要生成一個 aps_production.pem
步驟如下:
# openssl x509 -in adj_aps_production.cer -inform DER -out adj_aps_production.pem -outform PEM}
# openssl pkcs12 -nocerts -out adj_aps_production_key.pem -in adj_aps_production_key.p12
# openssl rsa -out adj_aps_production_key_noenc.pem -in adj_aps_production_key.pem
# cat adj_aps_production.pem adj_aps_production_key_noenc.pem > aps_production.pem
最後你可以在osx底下這樣測試你的pem是否正常:
# openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert adj_aps_production.pem -key aps_production.pem
如果出現
QUOTE:
.....
.....
New, TLSv1/SSLv3, Cipher is AES256-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1
Cipher : AES256-SHA
Session-ID:
Session-ID-ctx:
Master-Key: 8AE6DEA7F4CD980532E118E0A5A6CC8B6DF1A07D7C1EF811874532AA1F67B9AC94ED732A129F3710965A3829FAA2BE23
Key-Arg : None
Start Time: 1435909777
Timeout : 300 (sec)
Verify return code: 0 (ok)
這樣就代表 ok 囉
參考文章: http://chapiplus.blogspot.tw/2014/10/ios-push-server.html