API
#net/apns
Xu 0.8.8 API
import: #net/apns
counts: 1 fns, 2 methods, 2 types, 2 consts, 0 ifaces
Apple Push Notification service provider client (token auth, ES256). priv := ecdsa.parse_private_pem(&p8_pem) or... c := apns.connect(true, &team_id, &key_id, &priv, &bundle_id) or... r := c.push(&device_token, &payload_json) connect opens HTTP/2 to api.push.apple.com (prod) or api.sandbox.push.apple.com. JWT is minted per push (APNs allows cache up to 1h — minting every send is simpler and still cheap vs TLS). v1: one stream per push, no connection pool, no retry, no 410 unregistered bookkeeping. Payload is raw JSON the caller built (aps + custom).
const host_prod
pub const host_prod = "api.push.apple.com"
Purpose
Apple Push Notification service provider client (token auth, ES256). priv := ecdsa.parse_private_pem(&p8_pem) or... c := apns.connect(true, &team_id, &key_id, &priv, &bundle_id) or... r := c.push(&device_token, &payload_json) connect opens HTTP/2 to api.push.apple.com (prod) or api.sandbox.push.apple.com. JWT is minted per push (APNs allows cache up to 1h — minting every send is simpler and still cheap vs TLS). v1: one stream per push, no connection pool, no retry, no 410 unregistered bookkeeping. Payload is raw JSON the caller built (aps + custom). Value `"api.push.apple.com"`.
Parameters
none
const host_sandbox
pub const host_sandbox = "api.sandbox.push.apple.com"
Purpose
Public constant `host_sandbox`. Value `"api.sandbox.push.apple.com"`.
Parameters
none
struct Client
Purpose
Public struct `Client`.
Parameters
none
struct PushResult
pub struct PushResult {
pub status int
pub apns_id string
pub reason string
pub ok bool
}
Purpose
Public struct `PushResult`.
Parameters
status int- field (int)
apns_id string- field (string)
reason string- field (string)
ok bool- field (bool)
connect
pub fn connect(production bool, team_id string, key_id string, private_key string, topic string) Client
Purpose
connect dials the APNs host and completes the h2 preface. Throws on failure.
Parameters
production bool- production (bool)
team_id string- team_id (string)
key_id string- key_id (string)
private_key string- private_key (string)
topic string- topic (string)
Returns
Client — a value of this type
(&mut Client) push
pub fn (c &mut Client) push(device_token string, payload_json string) PushResult
Purpose
push sends payload_json to device_token. Builds a fresh provider JWT.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
device_token string- device_token (string)
payload_json string- payload_json (string)
Returns
PushResult — a value of this type
(&mut Client) close
pub fn (c &mut Client) close()
Purpose
Method on `&mut Client`: close the resource.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)