Project

rgcm

0.0
No commit activity in last 3 years
No release in over 3 years
Google Cloud Messaging
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 0
~> 3.0.0

Runtime

 Project Readme

Rgcm

Build Status Gem Version Code Climate Dependencies Status

Ruby mapper for Google Cloud Messaging

Installation

Add this line to your application's Gemfile:

gem 'rgcm'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rgcm

Usage

Rgcm::Message.new('_API_KEY_').post('_GCM_REGESTRATION_ID_', { foo: 'bar' }) # => Rgcm::Response

Rgcm::Message.new('_API_KEY_').post(['_GCM_REGESTRATION_ID_1_', '_GCM_REGESTRATION_ID_2_'], { foo: 'bar' }) # => Rgcm::Response

With collapse_key:

Rgcm::Message.new('_API_KEY_').post('_GCM_REGESTRATION_ID_', { foo: 'bar' }, {collapse_key: 'collapse_key'}) # => Rgcm::Response

With time_to_live:

Rgcm::Message.new('_API_KEY_').post('_GCM_REGESTRATION_ID_', { foo: 'bar' }, {time_to_live: 3}) # => Rgcm::Response

With rails YML config file:

development:
  api_key: '_API_KEY_'

test:
  api_key: '_API_KEY_'

production:
  api_key: '_API_KEY_'
Rgcm::Message.new.post('_GCM_REGESTRATION_ID_', { foo: 'bar' }) # => Rgcm::Response

Rgcm::Message.new.post(['_GCM_REGESTRATION_ID_1_', '_GCM_REGESTRATION_ID_2_'], { foo: 'bar' }) # => Rgcm::Response

Rgcm::Response methods:

{
    "multicast_id":5030383832068975557,
    "success":1,
    "failure":0,
    "canonical_ids":0,
    "results":[
        { "message_id":"0:1403425286258916%62dfd0f6e116c072" }
    ]
}
response = Rgcm::Message.new('_API_KEY_').post('_GCM_REGESTRATION_ID_', { foo: 'bar' })

response.count_successes # => 1
response.count_failures # => 0
response.has_successes? # => true
response.has_failures? # => false
response.results # => '{ "message_id":"0:1403425286258916%62dfd0f6e116c072" }' 
response.results_with_successes # => '{ "message_id":"0:1403425286258916%62dfd0f6e116c072" }' 
response.results_with_errors # => nil
response.results_with_canonical_ids # => nil

Contributing

  1. Fork it ( http://github.com//rgcm/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request