Module: ApnServer::Payload

Included in:
Notification
Defined in:
lib/apnserver/payload.rb

Constant Summary collapse

PayloadInvalid =
Class.new(RuntimeError)

Instance Method Summary collapse

Instance Method Details

#create_payload(payload) ⇒ Object



5
6
7
8
9
10
# File 'lib/apnserver/payload.rb', line 5

def create_payload(payload)
  case payload
    when String then { :aps => { :alert =>  payload } }
    when Hash then create_payload_from_hash(payload)
  end
end

#create_payload_from_hash(payload) ⇒ Object



12
13
14
15
16
17
# File 'lib/apnserver/payload.rb', line 12

def create_payload_from_hash(payload)
  custom = payload.delete(:custom)
  aps = {:aps => payload }
  aps.merge!(custom) if custom
  aps
end