Skip to content

tomdyson/PyAPNs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyAPNs

A Python library for interacting with the Apple Push Notification service (APNs)

Sample usage

from pyapns import APNs, Payload

apns = APNs(use_sandbox=True, cert_file='cert-file.pem', key_file='key-file.pem')

# Send some notifications
token_hex = 'b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c'
payload   = Payload(
    alert = "Hello World!", 
    sound = "default", 
    badge = 4
)

apns.gateway_server.send_notification(token_hex, payload)

# Get feedback messages
for (token_hex, fail_time) in apns.feedback_server.items():
    # do stuff with token_hex and fail_time

For more complicated alerts including custom buttons etc, use the PayloadAlert class. Example:

alert = PayloadAlert("Hello world!", action_loc_key="Click me")
payload = Payload(alert=alert, sound="default")

Further Info

iOS Reference Library: Local and Push Notification Programming Guide

Credits

Written and maintained by Simon Whitaker at Goo Software Ltd.

About

Python library for interacting with the Apple Push Notification service (APNs)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published