Exemple #1
0
def _apns_create_socket(creds=None, application_id=None):
    if creds is None:
        if not get_manager().has_auth_token_creds(application_id):
            cert = get_manager().get_apns_certificate(application_id)
            creds = apns2_credentials.CertificateCredentials(cert)
        else:
            keyPath, keyId, teamId = get_manager().get_apns_auth_creds(
                application_id)
            # No use getting a lifetime because this credential is
            # ephemeral, but if you're looking at this to see how to
            # create a credential, you could also pass the lifetime and
            # algorithm. Neither of those settings are exposed in the
            # settings API at the moment.
            creds = creds or apns2_credentials.TokenCredentials(
                keyPath, keyId, teamId)
    if SETTINGS["PROXY_HOST"] != "":
        client = apns2_client.APNsClient(
            creds,
            use_sandbox=get_manager().get_apns_use_sandbox(application_id),
            use_alternative_port=get_manager().get_apns_use_alternative_port(
                application_id),
            proxy_host=SETTINGS["PROXY_HOST"],
            proxy_port=SETTINGS["PROXY_PORT"])
    else:
        client = apns2_client.APNsClient(
            creds,
            use_sandbox=get_manager().get_apns_use_sandbox(application_id),
            use_alternative_port=get_manager().get_apns_use_alternative_port(
                application_id))

    client.connect()
    return client
Exemple #2
0
def _apns_create_socket(certfile=None):
    certfile = certfile or SETTINGS.get("APNS_CERTIFICATE")
    client = apns2_client.APNsClient(
        certfile,
        use_sandbox=SETTINGS.get("APNS_USE_SANDBOX"),
        use_alternative_port=SETTINGS.get("APNS_USE_ALTERNATIVE_PORT"))
    client.connect()
    return client
Exemple #3
0
def _apns_create_socket(certfile=None, application_id=None):
	certfile = certfile or get_manager().get_apns_certificate(application_id)
	client = apns2_client.APNsClient(
		certfile,
		use_sandbox=get_manager().get_apns_use_sandbox(application_id),
		use_alternative_port=get_manager().get_apns_use_alternative_port(application_id)
	)
	client.connect()
	return client