当前位置: 首页 > 工具软件 > PushServer > 使用案例 >

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

鲜于致远
2023-12-01
  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
 类似资料: