View Source Pigeon (Pigeon v2.0.0-rc.1)

HTTP2-compliant wrapper for sending iOS and Android push notifications.

getting-started

Getting Started

Check the module documentation for your push notification service.

creating-dynamic-runtime-dispatchers

Creating Dynamic Runtime Dispatchers

Pigeon can spin up dynamic dispatchers for a variety of advanced use-cases, such as supporting dozens of dispatcher configurations or custom connection pools.

See Pigeon.Dispatcher for instructions.

writing-a-custom-dispatcher-adapter

Writing a Custom Dispatcher Adapter

Want to write a Pigeon adapter for an unsupported push notification service?

See Pigeon.Adapter for instructions.

Link to this section Summary

Types

Async callback for push notifications response.

Options for sending push notifications.

Functions

Returns the configured default pool size for Pigeon dispatchers. To customize this value, include the following in your config/config.exs

Returns the configured JSON encoding library for Pigeon. To customize the JSON library, include the following in your config/config.exs

Link to this section Types

@type notification() :: %{
  :__struct__ => atom(),
  :__meta__ => Pigeon.Metadata.t(),
  optional(atom()) => any()
}
@type on_response() ::
  (notification() -> no_return())
  | {module(), atom()}
  | {module(), atom(), [any()]}

Async callback for push notifications response.

examples

Examples

handler = fn(%Pigeon.ADM.Notification{response: response}) ->
  case response do
    :success ->
      Logger.debug "Push successful!"
    :unregistered ->
      Logger.error "Bad device token!"
    _error ->
      Logger.error "Some other error happened."
  end
end

n = Pigeon.ADM.Notification.new("token", %{"message" => "test"})
Pigeon.ADM.push(n, on_response: handler)
@type push_opts() :: [on_response: on_response() | nil, timeout: non_neg_integer()]

Options for sending push notifications.

  • :on_response - Optional async callback triggered on receipt of push. See on_response/0
  • :timeout - Push timeout. Defaults to 5000ms.

Link to this section Functions

@spec default_pool_size() :: pos_integer()

Returns the configured default pool size for Pigeon dispatchers. To customize this value, include the following in your config/config.exs:

config :pigeon, :default_pool_size, 5
@spec json_library() :: module()

Returns the configured JSON encoding library for Pigeon. To customize the JSON library, include the following in your config/config.exs:

config :pigeon, :json_library, Jason
Link to this function

push(pid, notifications, opts \\ [])

View Source
@spec push(pid() | atom(), notification :: notification(), push_opts()) ::
  notification :: struct() | no_return()
@spec push(pid() | atom(), notifications :: [notification(), ...], push_opts()) ::
  notifications :: [struct(), ...] | no_return()