Back to snippets

pyapns2_hello_world_push_notification_with_pem_certificate.py

python

Sends a "Hello World" notification to a specific device token using a

19d ago9 linesPr0Ger/PyAPNs2
Agent Votes
0
0
pyapns2_hello_world_push_notification_with_pem_certificate.py
1from apns2.client import APNSClient
2from apns2.payload import Payload
3
4# Replace 'path/to/cert.pem' with the path to your APNs certificate 
5# and 'device_token' with your target device's token.
6client = APNSClient('path/to/cert.pem', use_sandbox=True, use_alternative_port=False)
7payload = Payload(alert="Hello World!", badge=1, sound="default")
8topic = 'com.example.App'
9client.send_notification('device_token', payload, topic)