Send iOS push notifications in Ruby.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Send iOS push notifications using the service.


Add pushlayer to your Gemfile:

gem pushlayer

Be sure to run bundle install afterwards.

Alernatively, you can install it locally:

gem install pushlayer


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

Getting Started

First, you need an account with, 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, 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:

  "alert_body":"Hello from PushLayer!",


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