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

Accept mutable-content #2

Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions lib/apns/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Notification
attr_accessor :device_token, :alert, :badge, :sound, :category, :other, :priority
attr_accessor :message_identifier, :expiration_date
attr_accessor :content_available
attr_accessor :mutable_content

def initialize(device_token, message)
self.device_token = device_token
Expand All @@ -14,6 +15,7 @@ def initialize(device_token, message)
self.sound = message[:sound]
self.category = message[:category]
self.other = message[:other]
self.mutable_content = message[:mutable_content]
self.message_identifier = message[:message_identifier]
self.content_available = !message[:content_available].nil?
self.expiration_date = message[:expiration_date]
Expand Down Expand Up @@ -63,6 +65,7 @@ def packaged_message
aps['aps']['sound'] = self.sound if self.sound
aps['aps']['category'] = self.category if self.category
aps['aps']['content-available'] = 1 if self.content_available
aps['aps']['mutable-content'] = 1 if self.mutable_content

aps.merge!(self.other) if self.other
aps.to_json
Expand Down
5 changes: 5 additions & 0 deletions spec/apns/notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
n.packaged_message.should == "{\"aps\":{\"content-available\":1}}"
end

it 'should accept mutable-content key only if mentionned' do
n = APNS::Notification.new('device_token', {:mutable_content => 1})
n.packaged_message.should == "{\"aps\":{\"mutable-content\":1}}"
end

end

describe '#package_token' do
Expand Down