Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apns_python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
use them with their module prefix like notification.Alert
"""

from notification import Alert, APS, Payload, Headers
from client import Client
from .notification import Alert, APS, Payload, Headers
from .client import Client
11 changes: 5 additions & 6 deletions apns_python/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Client(object):
apns_path = '/3/device/'

def __init__(
self, push_mode='dev', secure=True, cert_location=None,
cert_password=None, conn_timeout, request_timeout):
self, push_mode='dev', secure=True, cert_chain_location=None, cert_location=None,
cert_password=None):
if push_mode == 'dev':
self.apns_host = Client.dev_apns_host
elif push_mode == 'prd':
Expand All @@ -23,14 +23,13 @@ def __init__(
'The push_mode param must be "dev" or "prd", not {0}'.format(
push_mode))
raise ValueError(err_msg)
if cert_location:
ssl_context_obj = tls.init_context(
if cert_location and cert_chain_location:
ssl_context_obj = tls.init_context(cert_path=cert_chain_location,
cert=cert_location, cert_password=cert_password)
else:
ssl_context_obj = None
self.conn = HTTP20Connection(
self.apns_host, secure=secure, ssl_context=ssl_context_obj,
timeout=(conn_timeout, request_timeout))
self.apns_host, secure=secure, ssl_context=ssl_context_obj)

def send(self, device_token, headers, payload):
"""Send the notification to apns.
Expand Down
2 changes: 1 addition & 1 deletion apns_python/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, custom_fields={}, **apn_args):

def update_keys(self, apn_args, msg_obj_keys):
"""Transform the input keys with '_' to apns format with '-'."""
for k, v in apn_args.iteritems():
for k, v in apn_args.items():
formated_k = k.replace('_', '-')
if formated_k in msg_obj_keys:
del apn_args[k]
Expand Down