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

13 篇文章 0 订阅
1 篇文章 0 订阅
  1.  Purpose: 为苹果的app - push message . 使用苹果的 push 服务器
  2. rails 的插件:apple_push_notification
    URL: https://github.com/samsoffes/apple_push_notification

  3. install plugin apple_push_notification
    script/plugin install git://github.com/samsoffes/apple_push_notification.git
    一般都以插件安装
  4. download certificate file
    下载方法,参考: http://www.cnblogs.com/zhw511006/archive/2010/09/01/1815089.html
    1. Click the disclosure arrow next to your certificate in Keychain Access and select the certificate and the key.
    2. Right click and choose Export 2 items....
    3. 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
    是需要输入密码的
  5. 将apn_development.pem文件发到config/certs/文件夹中
    mkdir config/certs
    mv apn_development.pem config/certs
  6. #config/enviroment.rb
    ApplePushNotification.apn_enviroment = Rails.env.to_sym
  7. 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值