iOS苹果推送功能实现步骤

时间:2023-03-09 19:08:12
iOS苹果推送功能实现步骤

1.在钥匙串里 导出推送证书Apple Push notification Services 的 certificate, 命名为cer.p12,放在电脑桌面 ,期间密码设为123456

2.在钥匙串里 导出推送私钥 Apple Push notification Services 的 private key, 命名为key.p12,放在电脑桌面,期间密码设为123456

3.打开控制台程序,使用openssl 将cer.p12及key.p12转成cer.pem和key.pem

命令如下:

cd desktop

openssl pkcs12 -clcerts -nokeys -out cer.pem -in cer.p12  生成 cer.pem文件

openssl pkcs12 -nocerts -out key.pem -in key.p12 生成 key.pem文件

将cer.pem文件和key.pem文件给后台即可

4.执行命令

cat cer.pem key.pem > ck.pem

生成ck.pem文件

5.测试sandbox环境, 执行

openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert cer.pem -key key.pem

测试Production环境, 执行

openssl s_client -connect gateway.push.apple.com:2195 -cert cer.pem -key key.pem

切记发布需要注意的地方,服务器要修改的内容

  • pem文件名

  • 生成pem文件的密码

  • 使用 Production 的地址 (gateway.push.apple.com)

[参考链接]

http://jingyan.baidu.com/article/c275f6ba25e94fe33d756719.html