Skip to content
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
7 changes: 7 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ of the Payload constructor.
payload = Payload(alert="Hello World!", custom={'sekrit_number':123})
```

To send a **silent push notification** to an iOS 7 device, use the
content_available kwarg of the Payload constructor.

```python
payload = Payload(content_available=1, sound="")
```

## Travis Build Status

[![Build Status](https://secure.travis-ci.org/simonwhitaker/PyAPNs.png?branch=master)](http://travis-ci.org/simonwhitaker/PyAPNs)
Expand Down
6 changes: 5 additions & 1 deletion apns.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,14 @@ def __init__(self):

class Payload(object):
"""A class representing an APNs message payload"""
def __init__(self, alert=None, badge=None, sound=None, custom={}):
def __init__(self, alert=None, badge=None, sound=None, custom={},
content_available=False):
super(Payload, self).__init__()
self.alert = alert
self.badge = badge
self.sound = sound
self.custom = custom
self.content_available = content_available
self._check_size()

def dict(self):
Expand All @@ -203,6 +205,8 @@ def dict(self):
d['sound'] = self.sound
if self.badge is not None:
d['badge'] = int(self.badge)
if self.content_available:
d['content-available'] = 1

d = { 'aps': d }
d.update(self.custom)
Expand Down