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.
Add this line to your application's Gemfile:
gem'pushbots'And then execute:
$ bundle
Or install it yourself as:
$ gem install pushbots
# config/initializers/pushbots.rbPushbots.configuredo |config|
config.application_id='Application ID'config.application_secret='Application Secret'end# 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.registertokens=['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.registertoken='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# 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# 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# 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# Your notification responsepush.response# Your notification response HTTP codepush.response.code# Your notification response messagepush.response.message# Response as stringpush.response.to_sRead more about HTTP codes here
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.
The gem is available as open source under the terms of the MIT License.