Class: ActsAsPushable::Device
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActsAsPushable::Device
- Defined in:
- lib/acts_as_pushable/active_record/device.rb
Instance Method Summary collapse
- #android? ⇒ Boolean
- #deactivate ⇒ Object
- #ios? ⇒ Boolean
- #send_push_notification(message:, **options) ⇒ Object
Instance Method Details
#android? ⇒ Boolean
20 21 22 |
# File 'lib/acts_as_pushable/active_record/device.rb', line 20 def android? platform == 'android' end |
#deactivate ⇒ Object
24 25 26 27 28 29 |
# File 'lib/acts_as_pushable/active_record/device.rb', line 24 def deactivate self.update_attributes({ active: false, deactivated_at: Time.current, }) end |
#ios? ⇒ Boolean
16 17 18 |
# File 'lib/acts_as_pushable/active_record/device.rb', line 16 def ios? platform == 'ios' end |
#send_push_notification(message:, **options) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/acts_as_pushable/active_record/device.rb', line 31 def send_push_notification(message:, **) case platform when 'ios' ActsAsPushable::APN::Notification.send(device: self, message: , **) when 'android' raise ArgumentError, 'missing keyword: title' unless .key? :title ActsAsPushable::GCM::Notification.send(device: self, title: [:title], message: , **) end end |