Skip to content
/ rapns Public
forked from ileitch/rapns

Professional grade APNs and GCM daemon.

License

Notifications You must be signed in to change notification settings

ncoders/rapns

 
 

Repository files navigation

Build Status

Rapns - Professional grade APNs and GCM daemon

  • Supports both APNs (iOS) and GCM (Google Cloud Messaging, Android).
  • Seamless Rails integration.
  • Scalable - choose the number of threads each app spawns.
  • Designed for uptime - signal -HUP to add, update apps.
  • Stable - reconnects database and network connections when lost.
  • Works with MRI, JRuby, Rubinius 1.8 and 1.9.
  • Airbrake integration.

2.x users please read upgrading from 2.x to 3.0

Who uses Rapns?

GateGuru and Desk.com, among others!

I'd love to hear if you use Rapns - @ileitch on twitter.

Getting Started

Add Rapns to your Gemfile:

gem 'rapns'

Generate the migrations, rapns.yml and migrate:

rails g rapns
rake db:migrate

Generating Certificates (APNs only)

  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.
  3. Select both the certificate and private key.
  4. Right click and select Export 2 items....
  5. Save the file as cert.p12, make sure the File Format is Personal Information Exchange (p12).
  6. Convert the certificate to a .pem, where <environment> should be development or production, depending on the certificate you exported.

Without a password:

`openssl pkcs12 -nodes -clcerts -in cert.p12 -out <environment>.pem`

With a password:

`openssl pkcs12 -clcerts -in cert.p12 -out <environment>.pem`

Create an App

APNs

app = Rapns::Apns::App.new
app.name = "ios_app"
app.certificate = File.read("/path/to/development.pem")
app.environment = "development"
app.password = "certificate password"
app.connections = 1
app.save!

GCM

app = Rapns::Gcm::App.new
app.name = "android_app"
app.auth_key = "..."
app.connections = 1
app.save!

Create a Notification

APNs

n = Rapns::Apns::Notification.new
n.app = Rapns::Apns::App.find_by_name("ios_app")
n.device_token = "..."
n.alert = "hi mom!"
n.attributes_for_device = {:foo => :bar}
n.save!

GCM

n = Rapns::Gcm::Notification.new
n.app = Rapns::Gcm::App.find_by_name("android_app")
n.registration_ids = ["..."]
n.data = {:message => "hi mom!"}
n.save!

Starting Rapns

cd /path/to/rails/app
rapns <Rails environment> [options]

See Configuration for a list of options, or run rapns --help.

Updating Rapns

After updating you should run rails g rapns to check for any new migrations.

Wiki

General

APNs

GCM

Contributing

Fork as usual and go crazy!

When running specs, please note that the ActiveRecord adapter can be changed by setting the ADAPTER environment variable. For example: ADAPTER=postgresql rake.

Available adapters for testing are mysql, mysql2 and postgresql.

Note that the database username is changed at runtime to be the currently logged in user's name. So if you're testing with mysql and you're using a user named 'bob', you will need to grant a mysql user 'bob' access to the 'rapns_test' mysql database.

Contributors

Thank you to the following wonderful people for contributing:

About

Professional grade APNs and GCM daemon.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 97.6%
  • Java 2.4%