./README.md in houston-0.1.0 vs ./README.md in houston-0.1.1
- old
+ new
@@ -9,23 +9,24 @@
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. 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._
+_That said, a simple web service adapter, similar to [Rack::CoreData](https://github.com/mattt/rack-core-data) is 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
+# Environment variables are automatically read, or can be overridden by any specified options. You can also
+# conveniently use `Houston::Client.development` or `Houston::Client.production`.
+APN = Houston::Client.development
APN.certificate = File.read("/path/to/apple_push_notification.pem")
# An example of the token sent back when a device registers for notifications
token = "<ce8be627 2e43e855 16033e24 b4c28922 0eeda487 9c477160 b2545e95 b68b5969>"
@@ -46,9 +47,35 @@
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!"
+```
+
+## Enabling Push Notifications on iOS
+
+### AppDelegate.m
+
+```objective-c
+- (void)applicationDidFinishLaunching:(UIApplication *)application {
+ // ...
+
+ [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
+}
+
+- (void)application:(UIApplication *)application
+didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
+{
+ NSLog(@"application:didRegisterForRemoteNotificationsWithDeviceToken: %@", deviceToken);
+
+ // Register the device token with a webservice
+}
+
+- (void)application:(UIApplication *)application
+didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
+{
+ NSLog(@"Error: %@", error);
+}
```
## 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.