Git Product home page Git Product logo

rapns's Introduction

Build Status Code Climate

Rapns - Professional grade APNs and GCM for Ruby.

  • 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.
  • Run as a daemon or inside an existing process.
  • Use in a scheduler for low-workload deployments (Push API).
  • Reflection API for fine-grained instrumentation (Reflection API).
  • Works with MRI, JRuby, Rubinius 1.8 and 1.9.
  • Airbrake integration.
  • Built with love.

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

Create an App

APNs

If this is your first time using the APNs, you will need to generate SSL certificates. See Generating Certificates for instructions.

app = Rapns::Apns::App.new
app.name = "ios_app"
app.certificate = File.read("/path/to/sandbox.pem")
app.environment = "sandbox" # APNs environment.
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!

GCM also requires you to respond to Canonical IDs.

Starting Rapns

As a daemon:

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

Inside an existing process (see Embedding API):

Rapns.embed

Please note that only ever a single instance of Rapns should be running.

In a scheduler (see Push API):

Rapns.push
Rapns.apns_feedback

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:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.