./README.md in houston-0.0.1 vs ./README.md in houston-0.1.0

- old
+ new

@@ -1,41 +1,57 @@ # Houston **Apple Push Notifications. No Dirigible Required** > Houston, We Have Liftoff! -Push Notifications don't have to be difficult. And now they aren't. +Push Notifications don't have to be difficult. Houston is a simple gem for sending Apple Push Notifications. Pass your credentials, construct your message, and send it. In a production application, you will probably want to schedule or queue notifications into a background job. Whether you're using [queue_classic](https://github.com/ryandotsmith/queue_classic), [resque](https://github.com/defunkt/resque), or rolling you own infrastructure, integrating Houston couldn't be simpler. -Another caveat is that Houston doesn't manage device tokens for you. Since infrastructures can vary dramatically for these kinds of things, being agnostic and not forcing any conventions here is more a feature than a bug. That said, a simple web service adapter, similar to [Rack::CoreData](https://github.com/mattt/rack-core-data) may be in the cards. +Another caveat is that Houston doesn't manage device tokens for you. Infrastructures can vary dramatically for these kinds of things, so being agnostic and not forcing any conventions here is more a feature than a bug, perhaps. Treat it the same way as you would an e-mail address, associating one or many for each user account. +_That said, a simple web service adapter, similar to [Rack::CoreData](https://github.com/mattt/rack-core-data) may be in the cards._ + +## Installation + +``` +$ gem install houston +``` + ## Usage ```ruby - # Environment variables are automatically read, or can be overridden by any specified options - APN = Houston::Client.new - APN.certificate = File.read("/path/to/apple_push_notification.pem") - - # An example of the token sent back when a device registers for notifications - token = "<42e33061 9695b86b 59e5452b 061774c9 726eb8ec 22982c4b 558e34e2 784adee0>" - - # Create a notification that alerts a message to the user, plays a sound, and sets the badge on the app - notification = Houston::Notification.new(device: token) - notification.alert = "Hello, World!" +# Environment variables are automatically read, or can be overridden by any specified options +APN = Houston::Client.new +APN.certificate = File.read("/path/to/apple_push_notification.pem") - # Notifications can also change the badge count, have a custom sound, or pass along arbitrary data. - notification.badge = 57 - notification.sound = "sosumi.aiff" - notification.custom_data = {foo: "bar"} - - # And... sent! That's all it takes. - APN.push(notification) +# An example of the token sent back when a device registers for notifications +token = "<ce8be627 2e43e855 16033e24 b4c28922 0eeda487 9c477160 b2545e95 b68b5969>" + +# Create a notification that alerts a message to the user, plays a sound, and sets the badge on the app +notification = Houston::Notification.new(device: token) +notification.alert = "Hello, World!" + +# Notifications can also change the badge count, have a custom sound, or pass along arbitrary data. +notification.badge = 57 +notification.sound = "sosumi.aiff" +notification.custom_data = {foo: "bar"} + +# And... sent! That's all it takes. +APN.push(notification) ``` +## Command Line Tool + +Houston also comes with the `apn` binary, which provides a convenient way to test notifications from the command line. + +``` +$ apn push "<token>" -c /path/to/apple_push_notification.pem -m "Hello from the command line!" +``` + ## Converting Your Certificate > These instructions come from the [APN on Rails](https://github.com/PRX/apn_on_rails) project, which is another great option for sending push notifications. Once you have the certificate from Apple for your application, export your key @@ -46,15 +62,11 @@ 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 +$ openssl pkcs12 -in cert.p12 -out apple_push_notification.pem -nodes -clcerts ``` - -If you are using a development certificate, then change the name to apple_push_notification_development.pem instead. - -Store the contents of the certificate files on the app model for the app you want to send notifications to. ## Contact Mattt Thompson