diff --git a/apns_python/__init__.py b/apns_python/__init__.py index 998b1d3..62e0b9e 100644 --- a/apns_python/__init__.py +++ b/apns_python/__init__.py @@ -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 diff --git a/apns_python/client.py b/apns_python/client.py index ff13071..b4f8d9d 100644 --- a/apns_python/client.py +++ b/apns_python/client.py @@ -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': @@ -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. diff --git a/apns_python/notification.py b/apns_python/notification.py index 8c9379b..57b42b8 100644 --- a/apns_python/notification.py +++ b/apns_python/notification.py @@ -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]