No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Stefan Natchev aa79b39514 Merge pull request #9 from tbalthazar/module-methods
Add missing delegated method + tests
2015-07-21 15:00:06 -04:00
lib Add missing delegated method + tests 2015-07-20 11:39:54 +02:00
spec Add missing delegated method + tests 2015-07-20 11:39:54 +02:00
.gitignore add a rails generator for a zero_push initializer 2013-03-20 15:38:42 -04:00
.travis.yml fix syntax errors for ruby <2.1 add ruby 2.2.0 to travis 2015-01-29 18:08:29 -05:00
CHANGELOG.md Update CHANGELOG.md 2015-01-31 11:53:25 -05:00
Gemfile update gem to use bundler scaffold rather than hoe 2013-02-20 16:24:08 -05:00
Gemfile.lock version bump because of the wrong commit was tagged in previous release. 2015-01-31 11:44:21 -05:00
LICENSE.md move LICENSE into separate file as per standard Github repo initialization 2015-01-03 17:21:49 -05:00
Rakefile update gem to use bundler scaffold rather than hoe 2013-02-20 16:24:08 -05:00
README.md Update README.md 2015-01-31 14:02:55 -05:00
zero_push.gemspec Implement new endpoints. Use WebMock for request testing 2015-01-29 17:57:09 -05:00
zeropush-header.png update the reference to the header image 2013-08-08 17:25:27 -04:00

ZeroPush

Build Status Code Climate Gem Version

Installation

Add this line to your application's Gemfile:

gem 'zero_push'

And then execute:

$ bundle

Or install it yourself as:

$ gem install zero_push

Usage

Rails Generator

Generate the ZeroPush initializer if you are using Ruby on Rails.

$ rails g zero_push:install

API Client

The easiest way to use the API client is to set the server auth_token at the module level and call methods on the ZeroPush module. You can find the token on settings page for your app.

  ZeroPush.auth_token = 'iosprod_your-server-token'
  ZeroPush.notify(device_tokens: ['abcdef'], alert: 'hello, world', badge: '+1', info: {user_id: 1234})

If your web application supports must support multiple mobile apps, you may configure it like this:

  if Rails.env == 'development'  #or ENV['RACK_ENV']
    ZeroPush.auth_tokens = {
      apns: 'iosdev_XYZ',
      gcm: 'gcmdev_ABC',
    }
  else
    ZeroPush.auth_tokens = {
      apns: 'iosprod_XYZ',
      gcm: 'gcmprod_ABC',
    }
  end

You may then instantiate clients by calling the method that matches the auth token key:

  ZeroPush.apns.broadcast( ... )
  ZeroPush.gcm.broadcast( ... )

Lastly, if you have many apps you may instantiate clients API Clients

  client_1 = ZeroPush.client('iosprod_app-server-token-1')
  client_1.broadcast(alert: 'hello, app1')

  client_2 = ZeroPush.client('iosprod_app-server-token-2')
  client_1.broadcast(alert: 'hello, app2')

Methods supported by this gem and their parameters can be found in the API Reference

For more documentation, check our Getting Started Guide with ZeroPush

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Write tests for your feature
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request