Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
aklaiber committed Jun 26, 2014
2 parents 9a7e771 + cea208e commit 7b4fb19
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,62 @@ Or install it yourself as:

## Usage

TODO: Write usage instructions here
``` ruby
collapse_key = '_GCM_COLLAPS_KEY_'
data = { foo: 'bar' }

Rgcm::Message.new('_API_KEY_').post('_GCM_REGESTRATION_ID_', collapse_key, data) # => Rgcm::Response

Rgcm::Message.new('_API_KEY_').post(['_GCM_REGESTRATION_ID_1_', '_GCM_REGESTRATION_ID_2_'], collapse_key, data) # => Rgcm::Response
```

With rails YML config file:

``` yml
development:
api_key: '_API_KEY_'

test:
api_key: '_API_KEY_'

production:
api_key: '_API_KEY_'
```
``` ruby
collapse_key = '_GCM_COLLAPS_KEY_'
data = { foo: 'bar' }

Rgcm::Message.new.post('_GCM_REGESTRATION_ID_', collapse_key, data) # => Rgcm::Response

Rgcm::Message.new.post(['_GCM_REGESTRATION_ID_1_', '_GCM_REGESTRATION_ID_2_'], collapse_key, data) # => Rgcm::Response
```

Rgcm::Response methods:

```json
{
"multicast_id":5030383832068975557,
"success":1,
"failure":0,
"canonical_ids":0,
"results":[
{ "message_id":"0:1403425286258916%62dfd0f6e116c072" }
]
}
```

``` ruby
response = Rgcm::Message.new('_API_KEY_').post('_GCM_REGESTRATION_ID_', collapse_key, data)

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

## Contributing

Expand Down

0 comments on commit 7b4fb19

Please sign in to comment.