From c0cfa270b7c8cfdcf97eafb64b3119800e620c74 Mon Sep 17 00:00:00 2001 From: James Elliott Date: Tue, 25 Sep 2012 16:57:49 -0500 Subject: [PATCH] Stop stripping out the "default" sound from APNS objects, because sending that is Apple's recommended way of requesting the default notification sound. If you omit it, then no sound at all is played. --- src/herolabs/apns/message.clj | 9 +++------ test/herolabs_test/apns/message.clj | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/herolabs/apns/message.clj b/src/herolabs/apns/message.clj index 2318258..e36d591 100644 --- a/src/herolabs/apns/message.clj +++ b/src/herolabs/apns/message.clj @@ -4,11 +4,7 @@ (defn with-badge [message number] (assoc-in message [:aps :badge ] number)) (defn with-sound [message sound] - (cond - (= :default sound) (update-in message [:aps ] #(dissoc % :sound )) - (= "default" sound) (update-in message [:aps ] #(dissoc % :sound )) - :else (assoc-in message [:aps :sound ] sound) - ) + (assoc-in message [:aps :sound ] (name sound)) ) (defn with-standard-alert [message body] @@ -44,4 +40,5 @@ (if key (assoc-in message [:aps :alert :body ] body) message) - ) \ No newline at end of file + ) + diff --git a/test/herolabs_test/apns/message.clj b/test/herolabs_test/apns/message.clj index eb67d05..5bd20be 100644 --- a/test/herolabs_test/apns/message.clj +++ b/test/herolabs_test/apns/message.clj @@ -7,9 +7,9 @@ (facts "about message assembly" (with-badge {} 1) => (just {:aps {:badge 1}}) - (with-sound {} :default) => (just {:aps nil}) - (with-sound {} "default") => (just {:aps nil}) - (with-sound {} :chimes) => (just {:aps {:sound :chimes}}) + (with-sound {} :default) => (just {:aps {:sound "default"}}) + (with-sound {} "default") => (just {:aps {:sound "default"}}) + (with-sound {} :chimes) => (just {:aps {:sound "chimes"}}) (with-standard-alert {} "Hello world") => (just {:aps {:alert "Hello world"}}) (with-action-loc-key {} "TEST") => (just {:aps {:alert {:action-loc-key "TEST"}}}) (with-loc-key {} "TEST") => (just {:aps {:alert {:loc-key "TEST"}}})