Skip to content

Commit

Permalink
unset badge by passing badge=0
Browse files Browse the repository at this point in the history
  • Loading branch information
tominsam committed Apr 19, 2012
1 parent 1a25206 commit 9d17aa4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apns.py
Expand Up @@ -192,7 +192,7 @@ def dict(self):
d['alert'] = self.alert
if self.sound:
d['sound'] = self.sound
if self.badge:
if self.badge is not None:
d['badge'] = int(self.badge)

d = { 'aps': d }
Expand Down
7 changes: 7 additions & 0 deletions tests.py
Expand Up @@ -147,6 +147,13 @@ def testPayload(self):
self.assertTrue('alert' not in d['aps'])
self.assertTrue('sound' not in d['aps'])

# Payload with just badge removal
p = Payload(badge=0)
d = p.dict()
self.assertTrue('badge' in d['aps'])
self.assertTrue('alert' not in d['aps'])
self.assertTrue('sound' not in d['aps'])

# Test plain string alerts
alert_str = 'foobar'
p = Payload(alert=alert_str)
Expand Down

0 comments on commit 9d17aa4

Please sign in to comment.