Permalink
Browse files

Update README.md

  • Loading branch information...
1 parent 12ec0ba commit e2af05624d76e3fa5a8af8b5b4965c1b9d71055c @tompesman committed Jul 22, 2012
Showing with 61 additions and 30 deletions.
  1. +61 −30 README.md
View
@@ -2,6 +2,14 @@
Please note this gem not yet used in production. If you want to help, please contact me.
+## Features
+
+* Multi-App
+* Multi-Provider (APNS, GCM, C2DM)
+* Integrated feedback processing
+* Rake task to cleanup the database
+* Database for storage (no external dependencies)
+
## Installation
Add to your `GemFile`
@@ -14,7 +22,7 @@ For __APNS__ (iOS: Apple Push Notification Services):
gem push-apns
-For __C2DM__ (Android: Cloud to Device Messaging, deprecated):
+For __C2DM__ (Android: Cloud to Device Messaging, deprecated by Google, not this gem):
gem push-c2dm
@@ -33,25 +41,38 @@ To generate the migration and the configuration files run:
The configuration is in the database and you add the configuration per push provider with the console (`rails c`):
-APNS:
+APNS ([see](https://github.com/tompesman/push-core#generating-certificates)):
```ruby
-Push::ConfigurationApns.create(:app => 'app_name', :connections => 2, :certificate => File.read("certificate.pem"), :feedback_poll => 60, :enabled => true).save
+Push::ConfigurationApns.create(
+ app: 'app_name',
+ connections: 2,
+ certificate: File.read('certificate.pem'),
+ feedback_poll: 60,
+ enabled: true).save
```
-C2DM
+C2DM ([see](https://developers.google.com/android/c2dm/)):
```ruby
-Push::ConfigurationC2dm.create(:app => 'app_name', :connections => 2, :email => "<email address here>", :password => "<password here>", :enabled => true).save
+Push::ConfigurationC2dm.create(
+ app: 'app_name',
+ connections: 2,
+ email: '<email address here>',
+ password: '<password here>',
+ enabled: true).save
```
-GCM
+GCM ([see](http://developer.android.com/guide/google/gcm/gs.html)):
```ruby
-Push::ConfigurationGcm.create(:app => 'app_name', :connections => 2, :key => '<api key here>').save
+Push::ConfigurationGcm.create(
+ app: 'app_name',
+ connections: 2,
+ key: '<api key here>',
+ enabled: true).save
```
-You can have each provider per app_name and you can have more than one app_name. Use the instructions below to generate the certificate for the APNS provider.
+You can have each provider per app_name and you can have more than one app_name. Use the instructions below to generate the certificate for the APNS provider. If you only want to prepare the database with the configurations, you can set the `enabled` switch to `false`. Only enabled configurations will be uesed by the daemon.
-
-### Generating Certificates
+### Generating Certificates for APNS
1. Open up Keychain Access and select the `Certificates` category in the sidebar.
2. Expand the disclosure arrow next to the iOS Push Services certificate you want to export.
@@ -63,8 +84,7 @@ You can have each provider per app_name and you can have more than one app_name.
`openssl pkcs12 -nodes -clcerts -in cert.p12 -out <environment>.pem`
-8. Move the .pem file into your Rails application under `config/push`.
-
+8. Move the .pem file somewhere where you can use the `File.read` to load the file in the database.
## Daemon
@@ -74,48 +94,59 @@ To start the daemon:
Where `<environment>` is your Rails environment and `<options>` can be:
- -f, --foreground Run in the foreground.
- -p, --pid-file PATH Path to write PID file. Relative to Rails root unless absolute.
- -P, --push-poll N Frequency in seconds to check for new notifications. Default: 2.
- -n, --airbrake-notify Enables error notifications via Airbrake.
- -F, --feedback-poll N Frequency in seconds to check for feedback for the feedback processor. Default: 60. Use 0 to disable.
- -b, --feedback-processor PATH Path to the feedback processor. Default: lib/push/feedback_processor.
- -v, --version Print this version of push.
- -h, --help You're looking at it.
+ -f, --foreground Run in the foreground.
+ -p, --pid-file PATH Path to write PID file. Relative to Rails root unless absolute.
+ -P, --push-poll N Frequency in seconds to check for new notifications. Default: 2.
+ -n, --airbrake-notify Enables error notifications via Airbrake.
+ -F, --feedback-poll N Frequency in seconds to check for feedback for the feedback processor. Default: 60. Use 0 to disable.
+ -b, --feedback-processor PATH Path to the feedback processor. Default: lib/push/feedback_processor.
+ -v, --version Print this version of push.
+ -h, --help You're looking at it.
## Sending notifications
APNS:
```ruby
-Push::MessageApns.new(:app => 'app_name', device: '<APNS device_token here>', alert: 'Hello World', expiry: 1.day.to_i, attributes_for_device: {key: 'MSG'}).save
+Push::MessageApns.new(
+ app: 'app_name',
+ device: '<APNS device_token here>',
+ alert: 'Hello World',
+ expiry: 1.day.to_i,
+ attributes_for_device: {key: 'MSG'}).save
```
C2DM:
```ruby
-Push::MessageC2dm.new(:app => 'app_name', device: '<C2DM registration_id here>', payload: { message: 'Hello World' }, collapse_key: 'MSG').save
+Push::MessageC2dm.new(
+ app: 'app_name',
+ device: '<C2DM registration_id here>',
+ payload: { message: 'Hello World' },
+ collapse_key: 'MSG').save
```
GCM:
```ruby
-Push::MessageGcm.new(:app => 'app_name', device: '<GCM registration_id here>', payload: { message: 'Hello World' }, collapse_key: 'MSG').save
+Push::MessageGcm.new(
+ app: 'app_name',
+ device: '<GCM registration_id here>',
+ payload: { message: 'Hello World' },
+ collapse_key: 'MSG').save
```
## Feedback processing
The push providers return feedback in various ways and these are captured and stored in the `push_feedback` table. The installer installs the `lib/push/feedback_processor.rb` file which is by default called every 60 seconds. In this file you can process the feedback which is different for every application.
-## Rake Task
+## Maintenance
-The push-core also comes with a rake task to delete all the messages and feedback of the last 7 days or by the DAYS parameter.
+The push-core comes with a rake task to delete all the messages and feedback of the last 7 days or by the DAYS parameter.
- bundle exec rake push:clean DAYS=2
+ bundle exec rake push:clean DAYS=2
## Prerequisites
-* Rails 3.2 +
-* Ruby 1.9
-
+* Rails 3.2.x
+* Ruby 1.9.x
## Thanks
This project started as a fork of Ian Leitch [RAPNS](https://github.com/ileitch/rapns) project. The differences between this project and RAPNS is the support for C2DM and the modularity of the push providers.
-

0 comments on commit e2af056

Please sign in to comment.