Skip to content

A Python client for Apple Push Notification service(APNs)

License

Notifications You must be signed in to change notification settings

casualuser/apns-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

apns-python package

apns-python is a package to help you to commmunicate with Apple Push Notification Service (APNs).

It support the HTTP2.0 protocol with APNs.

Precondition

  • Python 2.7.9 and later
  • Python 3.5 and later

Installation

Make sure you have pip installed. If not, install pip

$ wget https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py

Install apns-python:

$ pip install apns-python

Demo

from apns_python import Alert, APS, Payload, Headers, Client


alert = Alert(
    title='Notification Title',
    body='A preview content from apn-python')

aps = APS(
    alert=alert,
    badge=1,
    sound='sound.mp3')

payload = Payload(
    aps=aps,
    custom_fields=dict(
        customized_field='some data'))

headers = Headers(
    custom_fields={"Content-Type": "application/json; charset=utf-8"})

client = Client(
    push_mode='dev',
    secure=True,
    cert_location='/your/apns/certfile.pem',
    cert_password='APNsCertPassword')

result = client.send(target_device_token, headers, payload)

print result

About

A Python client for Apple Push Notification service(APNs)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%