Coder Social home page Coder Social logo

zero_push's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.