Project

pushbots

0.01
No commit activity in last 3 years
No release in over 3 years
Ruby Wrapper for PushBots Rest API. Includes push notification methods for single and multiple devices simplifying notification management and pushbots api usage in your ruby projects.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0
~> 1.24

Runtime

>= 1.0.2, ~> 1.0
 Project Readme

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

  • Configuration

  • How to use

    • Device management

      • Register a device
      • Register multiple devices
      • Delete a device
      • Device information
    • Notifications

      • Single device notification
      • Multiple device notifications
      • Read pushbots response

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.rb

Pushbots.configure do |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 device
device = 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 false
device.register

Register multiple devices

tokens = ['8js62lsod8',
          '71882jksu2']
platform = :ios
tags = ['vip', 'cool_people']
# tokens and platform are required to add multiple devices
# tags is an optional parameter
devices = 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 false
devices.register

Delete a device

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

Device information

# token is required to get device information
token = '182ksiwl29'
# platform is an optional parameter
device = Pushbots::Device.new(token)
# Get device information
device.info
# Device token
device.token
# Device status
device.platform
# Device tags
device.tags

Notifications

Single device notification

# Device token
token = '82ksh62j1a'
# platform is :ios or :android
# (Any other value will return a RuntimeError)
platform = :ios
# Notification message
message = '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 message
message = '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 response
push.response
# Your notification response HTTP code
push.response.code
# Your notification response message
push.response.message
# Response as string
push.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.