diff --git a/lib/pushmeup/apns/core.rb b/lib/pushmeup/apns/core.rb index fe9d79a..66d168f 100644 --- a/lib/pushmeup/apns/core.rb +++ b/lib/pushmeup/apns/core.rb @@ -80,8 +80,8 @@ def self.with_connection rescue StandardError, Errno::EPIPE raise unless attempts < @retries - @ssl.close - @sock.close + @ssl.close unless @ssl.nil? + @sock.close unless @sock.nil? attempts += 1 retry diff --git a/lib/pushmeup/apns/notification.rb b/lib/pushmeup/apns/notification.rb index 60d76f6..25c7b81 100644 --- a/lib/pushmeup/apns/notification.rb +++ b/lib/pushmeup/apns/notification.rb @@ -1,6 +1,6 @@ module APNS class Notification - attr_accessor :device_token, :alert, :badge, :sound, :other + attr_accessor :device_token, :alert, :badge, :sound, :category, :other def initialize(device_token, message) self.device_token = device_token @@ -8,6 +8,7 @@ def initialize(device_token, message) self.alert = message[:alert] self.badge = message[:badge] self.sound = message[:sound] + self.category = message[:category] self.other = message[:other] elsif message.is_a?(String) self.alert = message @@ -31,6 +32,7 @@ def packaged_message aps['aps']['alert'] = self.alert if self.alert aps['aps']['badge'] = self.badge if self.badge aps['aps']['sound'] = self.sound if self.sound + aps['aps']['category'] = self.category if self.category aps.merge!(self.other) if self.other aps.to_json.gsub(/\\u([\da-fA-F]{4})/) {|m| [$1].pack("H*").unpack("n*").pack("U*")} end @@ -40,8 +42,8 @@ def ==(that) alert == that.alert && badge == that.badge && sound == that.sound && + category == that.category && other == that.other end - end end