XU XUv0.16.0

#net/apns

import: #net/apns

counts: 1 functions, 2 methods, 2 types, 2 constants, 0 method sets

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

XuAPI
pub const HOST_PROD = "api.push.apple.com"

Purpose

Constant HOST_PROD, defining protocol or algorithm parameters.

const HOST_SANDBOX

XuAPI
pub const HOST_SANDBOX = "api.sandbox.push.apple.com"

Purpose

Constant HOST_SANDBOX, defining protocol or algorithm parameters.

struct Client

XuAPI
pub struct Client {

}

Purpose

Apns Client session maintaining connection and operations.

Public fields

This type has no public fields.

struct PushResult

XuAPI
pub struct PushResult {
    pub status int
    pub apns_id string
    pub reason string
    pub ok bool
}

Purpose

Structure encapsulating status, apns_id, reason, ok.

Public fields

status int
field (int)
apns_id string
field (string)
reason string
field (string)
ok bool
field (bool)

connect

XuAPI
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; handle the error or propagate it to the caller.

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

($&Client) push

XuAPI
pub fn (c $&Client) push(device_token string, payload_json string) PushResult

Purpose

push sends payload_json to device_token. Reuses cached provider JWT up to 45m.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).
device_token string
device_token (string)
payload_json string
payload_json (string)

Returns

PushResult — a value of this type

($&Client) close

XuAPI
pub fn (c $&Client) close()

Purpose

Operation on $&Client: close the resource.

Parameters

c $&Client
The Client instance used by this call (exclusive borrow).

Returns

This call does not return a value.