HTTPS clone URL
Subversion checkout URL
Apple Push Notifications on Rails
Fetching latest commit...
Cannot retrieve the latest commit at this time.
|Failed to load latest commit information.|
APN on Rails (Apple Push Notifications on Rails) ===================== Acknowledgements ---------------- This gem is a re-write of a plugin that was written by Fabien Penso and Sam Soffes. Their plugin was a great start, but it just didn't quite reach the level I hoped it would. I've re-written, as a gem, added a ton of tests, and I would like to think that I made it a little nicer and easier to use. Converting Your Certificate --------------------------- Once you have the certificate from Apple for your application, export your key and the apple certificate as p12 files. Here is a quick walkthrough on how to do this: 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`. Now covert the p12 file to a pem file: $ openssl pkcs12 -in cert.p12 -out apple_push_notification_production.pem -nodes -clcerts Put 'apple_push_notification_production.pem' in config/ If you are using a development certificate, then change the name to apple_push_notification_development.pem instead. Installing ---------- From RubyForge: $ sudo gem install apn_on_rails Or, if you like to live on the edge: $ sudo gem install markbates-apn_on_rails --source=http://gems.github.com Then you just add the following require, wherever it makes sense to you: require 'apn_on_rails' If you like to use the built in Rails gem management: config.gem 'apn_on_rails' Or, if you like to live on the edge: config.gem 'markbates-apn_on_rails', :lib => 'apn_on_rails', :source => 'http://gems.github.com' Setup ----- Once you have the gem installed you need to add the following to your Rakefile so you can use the Rake tasks that ship with APN on Rails: begin require 'apn_on_rails_tasks' rescue MissingSourceFile => e puts e.message end Now, to create the tables you need for APN on Rails, run the following task: $ rake apn:db:migrate That's it, now you're ready to start creating notifications. Example ------- *Note: the spaces in `device_token` are optional.* $ ./script/console >> a = ApplePushNotification.new >> a.device_token = "XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX" >> a.badge = 5 >> a.sound = true >> a.alert = "foobar" >> a.send_notification => nil Copyright (c) 2009 Fabien Penso. Released under the MIT license. Modified by [Sam Soffes](http://samsoff.es).