Class: ActsAsPushable::Device

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/acts_as_pushable/active_record/device.rb

Instance Method Summary collapse

Instance Method Details

#android?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/acts_as_pushable/active_record/device.rb', line 20

def android?
  platform == 'android'
end

#deactivateObject



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

Returns:

  • (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:, **options)
  case platform
  when 'ios'
    ActsAsPushable::APN::Notification.send(device: self, message: message, **options)
  when 'android'
    raise ArgumentError, 'missing keyword: title' unless options.key? :title
    ActsAsPushable::GCM::Notification.send(device: self, title: options[:title], message: message, **options)
  end
end