您的位置:首页 > 移动开发

rails开发利器:如何给苹果PushServer发送消息rails for apple_push_notification

2011-11-25 16:55 429 查看
Purpose: 为苹果的app - push message . 使用苹果的 push 服务器

rails 的插件:apple_push_notification

URL: https://github.com/samsoffes/apple_push_notification
install plugin apple_push_notification

script/plugin install git://github.com/samsoffes/apple_push_notification.git
一般都以插件安装

download certificate file

下载方法,参考: http://www.cnblogs.com/zhw511006/archive/2010/09/01/1815089.html

Click the disclosure arrow next to your certificate in Keychain Access and select the certificate and the key.
Right click and choose
Export 2 items...
.
Choose the p12 format from the drop down and name it
cert.p12
.

转换文件:

openssl pkcs12 -in cert.p12 -out apn_development.pem -nodes -clcerts && rm -f cert.p12
是需要输入密码的

将apn_development.pem文件发到config/certs/文件夹中

mkdir config/certs
mv apn_development.pem config/certs

#config/enviroment.rb

ApplePushNotification.apn_enviroment = Rails.env.to_sym


ruby script/console

>> token = "XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX"
>> d = Object.new
>> d.extend ApplePushNotification
>> d.device_token = token
>> d.send_notification :alert => "So flexible"
>> nil
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: