class Crusade::APNS::Notification

Attributes

device_token[RW]
notification[RW]

Public Class Methods

new(notification, device_token = nil) click to toggle source
Calls superclass method
# File lib/crusade/apns/notification.rb, line 8
def initialize(notification, device_token = nil)
  if notification.is_a? Hash
    device_token = notification[:device_token]
    notification = Crusade::Notification.new notification
  end
  super notification
  self.notification = notification
  self.device_token = device_token
end

Public Instance Methods

json_size() click to toggle source
# File lib/crusade/apns/notification.rb, line 22
def json_size
  to_json.size
end
to_json() click to toggle source
# File lib/crusade/apns/notification.rb, line 18
def to_json
  payload.to_json
end

Private Instance Methods

alert() click to toggle source
# File lib/crusade/apns/notification.rb, line 37
def alert
  h = {
    "title" => title,
    "body" => body
  }
  h.update "action" => action if action
  h
end
aps() click to toggle source
# File lib/crusade/apns/notification.rb, line 46
def aps
  h = {
    "alert" => alert,
  }
  h.update "url-args" => url_args if url_args.any?
  h
end
payload() click to toggle source
# File lib/crusade/apns/notification.rb, line 31
def payload
  {
    "aps" => aps
  }
end