Answer the question
In order to leave comments, you need to log in
How to connect the APNS certificate correctly?
There is a function to send messages
PUSH_NOTIFICATIONS_SETTINGS = {
"APNS_CERTIFICATE": os.path.join(PROJECT_ROOT, 'rss/CorruptionDevPushCer.p12'),
}
from rss.settings import PUSH_NOTIFICATIONS_SETTINGS
def send_message(data, kwargs):
device_apns_ids = [d.device_id for d in UserDevice.objects.filter(client=client, active=True, device=2).all()]
cert_file = PUSH_NOTIFICATIONS_SETTINGS['APNS_CERTIFICATE']
apns_enhanced = APNs(use_sandbox=True, cert_file=cert_file, enhanced=True)
payload = Payload(alert=kwargs['pid'], sound="default", badge=1)
frame = Frame()
identifier = 1
expiry = time.time() + 3600
priority = 10
for device_apns_id in device_apns_ids:
device_apns_id = str(device_apns_id)
frame.add_item(device_apns_id, payload, identifier, expiry, priority)
apns_responce = apns_enhanced.gateway_server.send_notification_multiple(frame)
[Errno 336265218] _ssl.c:355: error:140B0002:SSL routines:SSL_CTX_use_PrivateKey_file:system lib
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question