13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/igetui/validate.rb', line 13
def get_payload(args = {})
apnsMap = Hash.new
sound = "default" unless validate_length(args, :sound)
apnsMap["sound"] = args[:sound]
alertMap = Hash.new
if validate_length(args, :launch_image)
alertMap["launch-image"] = args[:launch_image]
end
if validate_length(args, :loc_key)
alertMap["loc-key"] = args[:loc_key]
if validate_length(args, :loc_args)
alertMap["loc-args"] = args[:loc_args].split(", ")
end
elsif validate_length(nil, message)
alertMap["body"] = message
end
apnsMap["alert"] = alertMap
if validate_length(args, :action_loc_key)
apnsMap["action-loc-key"] = args[:action_loc_key]
end
apnsMap["badge"] = badge
h = Hash.new
h["aps"] = apnsMap
h["payload"] = payload if validate_length(nil, payload)
return h
end
|