Project

pushlayer

0.0
No commit activity in last 3 years
No release in over 3 years
PushLayer is a service for sending, managing, and debugging iOS push notifications. This gem adds a wrapper around the service, making it simple to send iOS push notifications from within your Ruby applications.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.2.2
~> 2.0
~> 1.9.0
~> 0.8.3

Runtime

~> 1.5.0
~> 1.6.7
 Project Readme

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.