kongkong's Blog

No Silver Bullet --- Computer Language is just a tool.

使用ruby推送消息给IOS设备

| Comments

0 先在apple开发者网站上面做一个证书,通过xcode-window-organizer来安装

1 先导出Apple Development IOS Push Services/ com.vvlive.EasyInfoPro证书为p12格式

      钥匙串访问--证书--Apple Development IOS Push Services/ com.vvlive.EasyInfoPro--导出xx.p12

2 转化为pem格式

openssl pkcs12 -in CertificateName.p12 -out CertificateName.pem -nodes

3  ruby代码

require 'apns'
APNS.host='gateway.sandbox.push.apple.com'
APNS.pem='/Users/kj/Desktop/PushTest.pem'

APNS.port=2195
device_token='bc4f83fc b783cf4f 3b3efc1f bed66df6 1fde5523 c66649f0 efcf52bd 689979b5'
APNS.send_notification(device_token,'Hello iPhone')

参见:http://www.spritle.com/blogs/2012/03/21/iphone-push-notification-using-ruby/ruby如何推送消息)(详细介绍

https://parse.com/tutorials/ios-push-notifications(介绍如何生成推送相关的证书)

Comments

comments powered by Disqus