No commit activity in last 3 years
No release in over 3 years
Add push tokens to model
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16.a
~> 10.0

Runtime

>= 0
 Project Readme

ActsAsHocPushable

Installation

Add this line to your application's Gemfile:

gem 'acts_as_hoc_pushable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install acts_as_hoc_pushable

Usage

Make application ready for acts_as_hoc_pushable

Install by running:

$ rails generate acts_as_hoc_pushable:install

This will create, models, migrations and initializer

Extend model

Add the acts_as_hoc_pushable to the model you want to be extended with push functionallity - eg. user.

#app/models/user.rb
class User < ApplicationRecord
  acts_as_hoc_pushable
end

now you have the following functionallity added to the model

  • Add a device to an user user.add_device(token:, platform:, platform_version:, push_environment:) user.add_device(params) user.add_device!(params)
  • Get active devices user.active_devices
  • Get platform specific devices user.ios_devices user.android_devices
  • Send push notification user.send_push_notification(title:, message:, **data)
  • Send silent push notification send_silent_push_notification(**data)

Other functions

Send to topic:

You can send push notifications to a topic with:

  ActsAsHocPushable::PushNotification.send_push_notification_to_topic(topic:, title: nil, message: nil, **data)

or for silent notification:

  ActsAsHocPushable::PushNotification.send_silent_push_notification_to_topic(topic:, **data)

Send to many devices:

  ActsAsHocPushable::PushNotification.send_push_notification(devices:, title: nil, message: nil, **data)

or for silent notification:

  ActsAsHocPushable::PushNotification.send_silent_push_notification(devices:, **data)

License

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