Project

Push0r

0.0
No commit activity in last 3 years
No release in over 3 years
Library to push messages using APNS and FCM
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

push0r

Gem Version

push0r is a ruby library that makes it easy to send push notifications to iOS, OSX and Android users.

Installation

Gemfile for Rails 3, Rails 4, Sinatra, and Merb:

gem 'Push0r', '~> 0.5.3'

Manual installation:

gem install Push0r

Usage

# create a new queue
queue = Push0r::Queue.new

# create the GcmService to push to Android devices and register it with our queue.
gcm_service = Push0r::GcmService.new("__gcm_api_token__")
queue.register_service(gcm_service)

# create ApnsService instances to push to iOS and OSX devices and register them with our queue.
apns_service_production = Push0r::ApnsService.new(File.read("aps_production.pem"), Push0r::ApnsEnvironment::PRODUCTION)
apns_service_sandbox = Push0r::ApnsService.new(File.read("aps_development.pem"), Push0r::ApnsEnvironment::SANDBOX)
queue.register_service(apns_service_production)
queue.register_service(apns_service_sandbox)

# create a GcmPushMessage and attach a dummy payload
gcm_message = Push0r::GcmPushMessage.new("__registration_id__")
gcm_message.attach({"data" => {"d" => "1"}})

# create a ApnsPushMessage to be sent via the Sandbox apns service and attach a dummy payload
apns_message = Push0r::ApnsPushMessage.new("__device_token__", Push0r::ApnsEnvironment::SANDBOX)
apns_message.attach({"data" => {"v" => "1"}}

# add both messages to the queue
queue.add(gcm_message)
queue.add(apns_message)

# flush the queue to actually transmit the messages
queue.flush

Documentation

Push0r API documentation can be found here.

Error handling

Queue#flush returns an instance of FlushResult which can be queried for failed_messages. This returns an array of FailedMessage instances which in turn offer various attributes like the error code for the failed notification.

Bugs

Please report bugs on GitHub.