Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Send iOS push notifications in Ruby.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.yardopts
Gemfile
Gemfile.lock
MIT-LICENSE
README.md
Rakefile
pushlayer.gemspec

README.md

Pushlayer

Send iOS push notifications using the PushLayer.com service.

Installation

Add pushlayer to your Gemfile:

gem pushlayer

Be sure to run bundle install afterwards.

Alernatively, you can install it locally:

gem install pushlayer

Requirements

PushLayer depends on ruby 1.9+, rest-client, and multi_json.

Getting Started

First, you need an account with PushLayer.com, and an application. An application defines the certificate to use with Apple, and gives you a corresponding api_key to reference when sending push notifications. Lastly, each application has a unique ID, and can be found by clicking on your application name. The URL will look something like https://www.pushlayer.com/applications/123, where 123 is the application ID.

Second, you need to tell the Pushlayer library about your ID and api_key:

Pushlayer.api_id = 123
Pushlayer.api_key = 'my api key'

Third, you need to know the device token you wish to send a notification to. A device token is generated by iOS in response to the user agreeing to receive push notifications from your app. Check out the documentation on how to request this permission.

Sending a notification

To send a notification, simply:

Pushlayer.post_notification 'device_token', 'Hello iOS!'

This will tell PushLayer to construct a payload consisting of the alert message 'Hello iOS!' and send it to the specified device token. If everything goes well, your iOS app should receive the notification.

The result will be a Ruby hash of the PushLayer notification object, similar to:

{
  "action_loc_key":null,
  "alert_body":"Hello from PushLayer!",
  "application_id":1,
  "badge":null,
  "created_at":
  "2013-01-08T03:50:06Z",
  "custom_payload":null,
  "device_token":"123abc",
  "id":3,
  "launch_image":null,
  "loc_args":null,
  "loc_key":null,
  "sound":null,
  "state":"pending",
  "status_code":null,
  "updated_at":"2013-01-08T03:50:06Z"
}

Help

If you find a bug, open an Issue. Pull Requests are welcome. If you get stuck and need help, feel free to contact us at info@pushlayer.com.

Something went wrong with that request. Please try again.