lib/rapnd/notification.rb in rapnd-0.4.0 vs lib/rapnd/notification.rb in rapnd-0.4.1
- old
+ new
@@ -1,20 +1,20 @@
module Rapnd
class Notification
- attr_accessor :badge, :alert, :sound, :'content-available', :custom_properties, :device_token
+ attr_accessor :badge, :alert, :sound, :content_available, :custom_properties, :device_token
def initialize(hash)
- [:badge, :alert, :sound, :device_token, :custom_properties].each do |k|
+ [:badge, :alert, :sound, :device_token, :content_available, :custom_properties].each do |k|
self.instance_variable_set("@#{k}".to_sym, hash[k]) if hash[k]
end
raise "Must provide device token: #{hash}" if self.device_token.nil?
self.device_token = self.device_token.delete(' ')
end
def payload
p = Hash.new
- [:badge, :alert, :sound, :'content-available'].each do |k|
- p[k] = send(k) if send(k)
+ [:badge, :alert, :sound, :content_available].each do |k|
+ p[k.to_s.gsub('_','-').to_sym] = send(k) if send(k)
end
aps = {:aps => p}
aps.merge!(custom_properties) if custom_properties
aps
end
\ No newline at end of file