XU XUv0.8.8
中文

API

#net/apns

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

XuAPI
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

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

Purpose

Public constant `host_sandbox`. Value `"api.sandbox.push.apple.com"`.

Parameters

none

struct Client

XuAPI
pub struct Client {

}

Purpose

Public struct `Client`.

Parameters

none

struct PushResult

XuAPI
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

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.

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

XuAPI
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

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

Purpose

Method on `&mut Client`: close the resource.

Parameters

c &mut Client
receiver &mut Client (exclusive borrow)