ApplePushNotifications.Token (apple_push_notifications v0.3.0)

Copy Markdown View Source

APNs JWT token generation.

APNs uses a P8 private key (ES256 P-256) to authenticate HTTP/2 requests. The JWT contains:

  • iss: Team ID (Apple Developer Team ID)
  • iat: Issued at timestamp
  • kid: Key ID from the APNs Auth Key

This JWT is used directly as the Bearer token in API requests.

Summary

Functions

Generate the APNs access token.

Like access_token/1 but also returns the unix-epoch expiry time, for cache use.

Build and sign the APNs JWT (ES256).

Types

jwt()

@type jwt() :: String.t()

Functions

access_token(opts \\ [])

@spec access_token(keyword()) :: {:ok, String.t()} | {:error, term()}

Generate the APNs access token.

access_token_with_expiry(opts \\ [])

@spec access_token_with_expiry(keyword()) ::
  {:ok, String.t(), integer()} | {:error, term()}

Like access_token/1 but also returns the unix-epoch expiry time, for cache use.

generate_jwt(opts \\ [])

@spec generate_jwt(keyword()) :: {:ok, jwt()} | {:error, term()}

Build and sign the APNs JWT (ES256).