Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/pushmeup/apns/notification.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
module APNS
class Notification
attr_accessor :device_token, :alert, :badge, :sound, :other
attr_accessor :device_token, :alert, :badge, :sound, :content_available, :other

def initialize(device_token, message)
self.device_token = device_token
if message.is_a?(Hash)
self.alert = message[:alert]
self.badge = message[:badge]
self.sound = message[:sound]
self.content_available = message[:content_available]
self.other = message[:other]
elsif message.is_a?(String)
self.alert = message
Expand All @@ -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']['content-available'] = self.content_available if self.content_available
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
Expand All @@ -40,6 +42,7 @@ def ==(that)
alert == that.alert &&
badge == that.badge &&
sound == that.sound &&
content_available == that.content_available &&
other == that.other
end

Expand Down