View Source Pigeon.APNS.JWTConfig (Pigeon v1.6.3)

Configuration for APNS Workers using JWT.

Summary

Types

Options for configuring JWT APNS connections.

t()

JWT APNS configuration struct

Functions

Returns a new APNS.JWTConfig with given opts or name.

Types

@type config_opts() :: [
  name: atom() | nil,
  mode: :dev | :prod | nil,
  key: binary() | {atom(), binary()},
  key_identifier: binary() | nil,
  team_id: binary() | nil,
  reconnect: boolean(),
  ping_period: pos_integer(),
  port: pos_integer(),
  uri: binary()
]

Options for configuring JWT APNS connections.

Configuration Options

  • :name - Registered worker name.
  • :mode - If set to :dev or :prod, will set the appropriate :uri
  • :key - JWT private key. Can be one of three options:
    • Static file path
    • Full-text string of the file contents (useful for environment variables)
    • {:my_app, "keys/private_key.p8"} (indicates path relative to the priv folder of the given application)
  • :key_identifier - A 10-character key identifier (kid) key, obtained from your developer account
  • :team_id - Your 10-character Team ID, obtained from your developer account
  • :uri - Push server uri. If set, overrides uri defined by :mode. Useful for test environments.
  • :port - Push server port. Can be any value, but APNS only accepts 443 and 2197
  • :ping_period - Interval between server pings. Necessary to keep long running APNS connections alive. Defaults to 10 minutes.

Deprecated Options

  • :reconnect - No longer used as of v1.2.0.
@type headers() :: [{binary(), binary()}]
@type t() :: %Pigeon.APNS.JWTConfig{
  key: binary() | nil | {:error, term()},
  key_identifier: binary() | nil,
  keyfile: binary() | nil | {:error, term()},
  name: atom() | nil,
  ping_period: pos_integer(),
  port: pos_integer(),
  reconnect: boolean(),
  team_id: binary() | nil,
  uri: binary() | nil
}

JWT APNS configuration struct

This struct should not be set directly. Instead use new/1 with config_opts/0.

Examples

%Pigeon.APNS.JWTConfig{
  name: :apns_default,
  reconnect: true,
  uri: "api.push.apple.com",
  port: 443,
  ping_period: 600_000,
  key: nil,
  keyfile: "key.p8",
  key_identifier: "ABC1234567",
  team_id: "DEF1234567"
}

Functions

Returns a new APNS.JWTConfig with given opts or name.

If given an atom, returns the config specified in your config.exs.

Examples

iex> Pigeon.APNS.JWTConfig.new(
...>   name: :test,
...>   mode: :prod,
...>   key: "test/support/AuthKey.p8-mock",
...>   key_identifier: "ABC1234567",
...>   team_id: "DEF1234567",
...>   port: 2197,
...>   ping_period: 300_000
...> )
%Pigeon.APNS.JWTConfig{uri: "api.push.apple.com", name: :test,
team_id: "DEF1234567", key_identifier: "ABC1234567", 
keyfile: Path.expand("test/support/AuthKey.p8-mock"),
ping_period: 300000, port: 2197, reconnect: false}

iex> config = Pigeon.APNS.JWTConfig.new(:apns_jwt_static)
iex> %{config | key: nil, key_identifier: nil, team_id: nil} # Hide for testing
iex> match? %_{uri: "api.development.push.apple.com", name: :apns_jwt_static,
...> ping_period: 600_000, port: 443, reconnect: false}, config
true