Skip to content

barumrho/apush

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

apush

A simple Apple push notification service provider in Python.

Important: Service overrides identifier attribute of Notification object. Instead, errors include token.

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.

for n in notifications:
    service.queue(n)

service.flush()

Check for errors after sending notifications.

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.

for (timestamp, token) in service.feedbacks:
    remove(token)

About

A simple Apple push notification service provider

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages