View Source Pigeon.APNS.Config (Pigeon v1.6.3)
Configuration for APNS Workers using certificates.
Summary
Types
@type config_opts() :: [ name: atom() | nil, mode: :dev | :prod | nil, cert: binary() | {atom(), binary()}, key: binary() | {atom(), binary()}, reconnect: boolean(), ping_period: pos_integer(), port: pos_integer(), uri: binary(), jwt_key: binary() | {atom(), binary()}, jwt_key_identifier: binary() | nil, jwt_team_id: binary() | nil ]
Options for configuring certificate APNS connections.
Configuration Options
:name
- Registered worker name.:mode
- If set to:dev
or:prod
, will set the appropriate:uri
:cert
- Push certificate. Can be one of three options:- Static file path
- Full-text string of the file contents (useful for environment variables)
{:my_app, "certs/cert.pem"}
(indicates path relative to thepriv
folder of the given application)
:key
- Push private key. Same as:cert
: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 accepts443
and2197
: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 ofv1.2.0
.
@type t() :: %Pigeon.APNS.Config{ cert: binary() | nil, certfile: binary() | nil, key: binary() | nil, keyfile: binary() | nil, name: atom() | nil, ping_period: pos_integer(), port: pos_integer(), reconnect: boolean(), uri: binary() | nil }
Certificate APNS configuration struct
This struct should not be set directly. Instead use new/1
with config_opts/0
.
Examples
%Pigeon.APNS.Config{
name: :apns_default,
reconnect: true,
cert: nil,
certfile: "cert.pem",
key: nil,
keyfile: "key.pem",
uri: "api.push.apple.com",
port: 443,
ping_period: 600_000
}
Functions
Returns a new APNS.Config
with given opts
or name.
If given an atom, returns the config specified in your config.exs
.
Examples
iex> Pigeon.APNS.Config.new(
...> name: :test,
...> mode: :prod,
...> cert: "test/support/test_cert.pem-mock",
...> key: "test/support/test_key.pem-mock",
...> port: 2197,
...> ping_period: 300_000
...> )
%Pigeon.APNS.Config{uri: "api.push.apple.com", name: :test,
certfile: Path.expand("test/support/test_cert.pem-mock"),
keyfile: Path.expand("test/support/test_key.pem-mock"),
ping_period: 300000, port: 2197, reconnect: false}
iex> config = Pigeon.APNS.Config.new(:apns_default)
iex> %{config | certfile: nil, keyfile: nil} # Hide for testing
iex> match? %_{uri: "api.development.push.apple.com",
...> name: :apns_default, ping_period: 600_000, port: 443}, config
true