class Apnotic::AbstractNotification

Attributes

apns_collapse_id[RW]
apns_id[RW]
authorization[RW]
expiration[RW]
priority[RW]
token[R]
topic[RW]

Public Class Methods

new(token) click to toggle source
# File lib/apnotic/abstract_notification.rb, line 16
def initialize(token)
  @token   = token
  @apns_id = SecureRandom.uuid
end

Public Instance Methods

authorization_header() click to toggle source
# File lib/apnotic/abstract_notification.rb, line 25
def authorization_header
  authorization ? "bearer #{authorization}" : nil
end
background_notification?() click to toggle source
# File lib/apnotic/abstract_notification.rb, line 29
def background_notification?
  false
end
body() click to toggle source
# File lib/apnotic/abstract_notification.rb, line 21
def body
  JSON.dump(to_hash).force_encoding(Encoding::BINARY)
end

Private Instance Methods

to_hash() click to toggle source
# File lib/apnotic/abstract_notification.rb, line 35
def to_hash
  raise NotImplementedError, 'implement the to_hash method in a child class'
end