class Apnotic::Notification

Attributes

alert[RW]
badge[RW]
category[RW]
content_available[RW]
custom_payload[RW]
mutable_content[RW]
sound[RW]
thread_id[RW]
url_args[RW]

Public Instance Methods

background_notification?() click to toggle source
# File lib/apnotic/notification.rb, line 8
def background_notification?
  aps.count == 1 && aps.key?('content-available') && aps['content-available'] == 1
end

Private Instance Methods

aps() click to toggle source
# File lib/apnotic/notification.rb, line 14
def aps
  {}.tap do |result|
    result.merge!(alert: alert) if alert
    result.merge!(badge: badge) if badge
    result.merge!(sound: sound) if sound
    result.merge!(category: category) if category
    result.merge!('content-available' => content_available) if content_available
    result.merge!('url-args' => url_args) if url_args
    result.merge!('mutable-content' => mutable_content) if mutable_content
    result.merge!('thread-id' => thread_id) if thread_id
  end
end
to_hash() click to toggle source
# File lib/apnotic/notification.rb, line 27
def to_hash
  { aps: aps }.tap do |result|
    result.merge!(custom_payload) if custom_payload
  end
end