Skip to content

house-of-code/acts_as_hoc_pushable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published