HTTP/2 client for APNs API.
APNs requires HTTP/2 connections. This client handles:
- Token-based authentication (JWT in Authorization header)
- HTTP/2 protocol negotiation
- APNs-specific error handling
Summary
Functions
Get an access token for use in manual requests.
Send a push notification to a device.
Send a push notification using the cached token.
Validate a device token format.
Functions
Get an access token for use in manual requests.
Send a push notification to a device.
Parameters
device_token: The hex-encoded device token (64 characters)notification: Map containing:aps: Alert dictionary withalert,badge,sound, etc.- Custom payload keys
opts: Per-call configuration overrides
Examples
ApplePushNotifications.Client.push(
"a1b2c3d4e5f6...",
%{
aps: %{
alert: %{title: "Hello", body: "World"},
badge: 1,
sound: "default"
}
}
)
Send a push notification using the cached token.
This is the preferred method for production use as it uses the TokenCache to avoid regenerating JWTs on every request.
Validate a device token format.
Device tokens should be 64 hex characters.