A simple Apple push notification service provider
Project description
apush
=====
### A simple Apple push notification service provider in Python.
Important: `Service` overrides `identifier` attribute of `Notification` object.
Instead, errors include token.
```python
from apush import Service, Notification, ERROR_INVALID_TOKEN
token = 'hex-encoded token'.decode('hex')
service = Service('/path/to/certificate.pem')
notification = Notification(token, alert='A new notification', badge=1)
service.send(notification)
```
For several notifications, use `queue` and `flush`.
```python
for n in notifications:
service.queue(n)
service.flush()
```
Check for errors after sending notifications.
```python
def remove(token):
'''Remove token from database.'''
...
for (status, identifier, token) in service.errors:
if status == ERROR_INVALID_TOKEN:
remove(token)
```
Check feedback service for invalid tokens.
```python
for (timestamp, token) in service.feedbacks:
remove(token)
```
=====
### A simple Apple push notification service provider in Python.
Important: `Service` overrides `identifier` attribute of `Notification` object.
Instead, errors include token.
```python
from apush import Service, Notification, ERROR_INVALID_TOKEN
token = 'hex-encoded token'.decode('hex')
service = Service('/path/to/certificate.pem')
notification = Notification(token, alert='A new notification', badge=1)
service.send(notification)
```
For several notifications, use `queue` and `flush`.
```python
for n in notifications:
service.queue(n)
service.flush()
```
Check for errors after sending notifications.
```python
def remove(token):
'''Remove token from database.'''
...
for (status, identifier, token) in service.errors:
if status == ERROR_INVALID_TOKEN:
remove(token)
```
Check feedback service for invalid tokens.
```python
for (timestamp, token) in service.feedbacks:
remove(token)
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
apush-0.2.0.tar.gz
(4.3 kB
view details)
File details
Details for the file apush-0.2.0.tar.gz
.
File metadata
- Download URL: apush-0.2.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f2540a9d900126895cabdabf7e63e1748bcaaaff4082ce35501e64583814a60 |
|
MD5 | b02ccbc394ee3bc7c7909b1cfc84155b |
|
BLAKE2b-256 | 83dccbbfefc4ad37cdb55a4c5322f68b8a8d501ccd29f1d7cc337529ddc8df01 |