Documentation
¶
Overview ¶
Package push 把中继收到的推送请求投给苹果推送服务。
用的是基于 p8 密钥的令牌鉴权(而不是证书):一把密钥可以同时用于开发与生产 环境,也不会像证书那样一年一换。令牌按苹果要求缓存复用,最多一小时换一次—— 每条推送都重签会被苹果限流。
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrBadPushRequest = errors.New("bad push request") ErrPushNotConfigured = errors.New("push not configured") ErrBadDeviceToken = errors.New("bad device token") ErrPushRejected = errors.New("push rejected by Apple") ErrPushThrottled = errors.New("push throttled by Apple") ErrPushTransport = errors.New("push transport error") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
func LoadProfilesFile ¶
LoadProfilesFile 读可选的多档推送 JSON:[{"bundle_id":"...","key_path":"...","key_id":"...","team_id":"..."}]
type Result ¶
type Result struct {
StatusCode int
Reason string // Apple's verbatim reason string, empty on success
ApnsID string // Apple's apns-id, may be empty on failure
}
Result is the structured outcome of one APNs delivery attempt: 200 means accepted for delivery, which is NOT the same as shown on the phone (NSE decrypt, offline devices, user settings are all downstream).
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router 按 bundle id 选推送 profile。自建单租户只有一份默认配置。
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
func (*Sender) Send ¶
Send delivers one push and returns the structured APNs outcome.
内容是加密的,所以推送本身必须带 mutable-content,让手机上的通知服务扩展 有机会在展示前把它解开;alert 里先放一句无信息量的占位,扩展解密成功后会 整条替换掉。用户关掉扩展或解密失败时,看到的就是这句占位——不理想,但绝不 会泄露内容,这个取舍是刻意的。
The returned Result only means accepted by APNs (200 = accepted), never that the phone displayed it. Callers must translate errors into receipts honestly: never treat "enqueued" as success, and never close the host connection because a push failed.