Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

accepts hash options with string keys #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
8 changes: 4 additions & 4 deletions lib/apns/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class Notification
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.other = message[:other]
self.alert = message[:alert] || message["alert"]
self.badge = message[:badge] || message["badge"]
self.sound = message[:sound] || message["sound"]
self.other = message[:other] || message["other"]
self.message_identifier = message[:message_identifier]
self.content_available = !message[:content_available].nil?
self.expiration_date = message[:expiration_date]
Expand Down
6 changes: 6 additions & 0 deletions spec/apns/notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
n.alert.should == "Hello iPhone"
n.badge.should == 3
end

it "should take a hash whose keys are strings as the message" do
n = APNS::Notification.new('device_token', {"alert" => 'Hello iPhone', "badge" => 3})
n.alert.should == "Hello iPhone"
n.badge.should == 3
end

it "should have a priority if content_availible is set" do
n = APNS::Notification.new('device_token', {:content_available => true})
Expand Down