MCPcopy
hub / github.com/sideshow/apns2 / NewClient

Function NewClient

client.go:91–111  ·  view source on GitHub ↗

NewClient returns a new Client with an underlying http.Client configured with the correct APNs HTTP/2 transport settings. It does not connect to the APNs until the first Notification is sent via the Push method. As per the Apple APNs Provider API, you should keep a handle on this client so that you

(certificate tls.Certificate)

Source from the content-addressed store, hash-verified

89// If your use case involves multiple long-lived connections, consider using
90// the ClientManager, which manages clients for you.
91func NewClient(certificate tls.Certificate) *Client {
92 tlsConfig := &tls.Config{
93 Certificates: []tls.Certificate{certificate},
94 }
95 if len(certificate.Certificate) > 0 {
96 tlsConfig.BuildNameToCertificate()
97 }
98 transport := &http2.Transport{
99 TLSClientConfig: tlsConfig,
100 DialTLS: DialTLS,
101 ReadIdleTimeout: ReadIdleTimeout,
102 }
103 return &Client{
104 HTTPClient: &http.Client{
105 Transport: transport,
106 Timeout: HTTPClientTimeout,
107 },
108 Certificate: certificate,
109 Host: DefaultHost,
110 }
111}
112
113// NewTokenClient returns a new Client with an underlying http.Client configured
114// with the correct APNs HTTP/2 transport settings. It does not connect to the APNs

Callers 7

TestClientManagerAddFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92

Calls

no outgoing calls