Skip to content
Open
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
15 changes: 8 additions & 7 deletions apns.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,20 +321,21 @@ def __init__(self, alert=None, badge=None, sound=None, category=None, custom=Non
def dict(self):
"""Returns the payload as a regular Python dictionary"""
d = {}

if self.sound:
d['sound'] = self.sound
if self.badge is not None:
d['badge'] = int(self.badge)
if self.category:
d['category'] = self.category
if self.alert:
# Alert can be either a string or a PayloadAlert
# object
if isinstance(self.alert, PayloadAlert):
d['alert'] = self.alert.dict()
else:
d['alert'] = self.alert
if self.sound:
d['sound'] = self.sound
if self.badge is not None:
d['badge'] = int(self.badge)
if self.category:
d['category'] = self.category


if self.content_available:
d.update({'content-available': 1})

Expand Down