Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add category to APNS notification #66

Closed
wants to merge 1 commit into from
Closed
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, :category, :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.category = message[:category]
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']['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
Expand All @@ -40,6 +42,7 @@ def ==(that)
alert == that.alert &&
badge == that.badge &&
sound == that.sound &&
category == that.category &&
other == that.other
end

Expand Down