Skip to content

Repository files navigation

Pushbots

Ruby Wrapper for Pushbots Rest API made with love by Kandiie

Pushbots is a Light SDK for mobile push notifications and now you can use this gem on your favorite Ruby on Rails Projects.

Table of Contents

Installation

Add this line to your application's Gemfile:

gem'pushbots'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pushbots

Configuration

# config/initializers/pushbots.rbPushbots.configuredo |config|
config.application_id='Application ID'config.application_secret='Application Secret'end

How to use:

Device management

Register a device

# token and platform are required to add a devicedevice=Pushbots::Device.new(token,platform)# register the device to pushbots returns true/false# an attempt to register a device# that has been already registered returns falsedevice.register

Register multiple devices

tokens=['8js62lsod8','71882jksu2']platform=:iostags=['vip','cool_people']# tokens and platform are required to add multiple devices# tags is an optional parameterdevices=Pushbots::Devices.new(tokens,platform,tags)# register the devices to pushbots returns true/false# an attempt to register a device# that has been already registered returns falsedevices.register

Delete a device

token='k2iwp29271'platform=:ios# token and platform are required to delete a devicedevice=Pushbots::Device.new(token,platform)# remove the device from pushbots# returns true if no errors occurreddevice.delete

Device information

# token is required to get device informationtoken='182ksiwl29'# platform is an optional parameterdevice=Pushbots::Device.new(token)# Get device informationdevice.info# Device tokendevice.token# Device statusdevice.platform# Device tagsdevice.tags

Notifications

Single device notification

# Device tokentoken='82ksh62j1a'# platform is :ios or :android# (Any other value will return a RuntimeError)platform=:ios# Notification messagemessage='Hello World!!!'# Build up the notification# platform, message, token and sound (required parameters).# options (custom fields) (optional parameter)push=Pushbots::One.new(platform,token,message,sound,options)push.send# Delivers the notification

Multiple device notification

# platform is an array of valid plataforms (ios or android)# (Any other value will return a RuntimeError)platforms=[:ios,:android]# Notification messagemessage='Hello World!!!'# Notification schedule (Delivery time)schedule=DateTime.now# Build up the notification# platform, message, schedule (required parameters).# options (custom fields) (optional parameter)push=Pushbots::All.new(platforms,message,schedule,options={})push.send# Delivers the notification
Read pushbots response
# Your notification responsepush.response# Your notification response HTTP codepush.response.code# Your notification response messagepush.response.message# Response as stringpush.response.to_s

Read more about HTTP codes here

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Kandiie/pushbots. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

About

A Ruby interface to the PushBots API

Resources

Code of conduct

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages