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
19 20 21 |
# File 'lib/acts_as_pushable/active_record/device.rb', line 19 def android? platform == 'android' end |
#deactivate ⇒ Object
23 24 25 26 27 28 |
# File 'lib/acts_as_pushable/active_record/device.rb', line 23 def deactivate self.update_attributes({ active: false, deactivated_at: Time.now, }) end |
#ios? ⇒ Boolean
15 16 17 |
# File 'lib/acts_as_pushable/active_record/device.rb', line 15 def ios? platform == 'ios' end |
#send_push_notification(message:, **options) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/acts_as_pushable/active_record/device.rb', line 30 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 |