View Source Pigeon.ADM.Notification (Pigeon v1.6.3)

Defines Amazon ADM notification struct and convenience constructor functions.

Summary

Types

ADM error responses

ADM push response

t()

ADM notification

Functions

Creates ADM.Notification struct with device registration ID and optional data payload.

Updates "data" key on push payload and calculates md5 hash.

Types

@type error_response() ::
  :access_token_expired
  | :invalid_registration_id
  | :invalid_data
  | :invalid_consolidation_key
  | :invalid_expiration
  | :invalid_checksum
  | :invalid_type
  | :max_rate_exceeded
  | :message_too_large
  | :unregistered
  | :unknown_error

ADM error responses

@type response() :: nil | :success | error_response() | :timeout

ADM push response

  • nil - Push has not been sent yet
  • :success - Push was successfully sent
  • error_response/0 - Push attempted but server responded with error
  • :timeout - Internal error. Push did not reach ADM servers
@type t() :: %Pigeon.ADM.Notification{
  consolidation_key: String.t(),
  expires_after: integer(),
  md5: binary(),
  payload: %{},
  registration_id: String.t(),
  response: response(),
  updated_registration_id: String.t()
}

ADM notification

Examples

%Pigeon.ADM.Notification{
  consolidation_key: nil,
  expires_after: 604_800,
  md5: "qzF+HgArKZjJrpfcTbiFxg==",
  payload: %{
    "data" => %{"message" => "your message"}
  },
  registration_id: "reg ID",
  response: nil, # Set on push response
  updated_registration_id: nil
}

Functions

Link to this function

new(registration_id, data \\ %{})

View Source
@spec new(String.t(), %{required(String.t()) => term()}) :: t()

Creates ADM.Notification struct with device registration ID and optional data payload.

Examples

iex> Pigeon.ADM.Notification.new("reg ID")
%Pigeon.ADM.Notification{
  consolidation_key: nil,
  md5: "1B2M2Y8AsgTpgAmY7PhCfg==",
  payload: %{"data" => %{}},
  registration_id: "reg ID",
  updated_registration_id: nil
}

iex> Pigeon.ADM.Notification.new("reg ID", %{"message" => "your message"})
%Pigeon.ADM.Notification{
  consolidation_key: nil,
  md5: "qzF+HgArKZjJrpfcTbiFxg==",
  payload: %{
    "data" => %{"message" => "your message"}
  },
  registration_id: "reg ID",
  updated_registration_id: nil
}

iex> Pigeon.ADM.Notification.new("reg ID", "not a map")
%Pigeon.ADM.Notification{
  consolidation_key: nil,
  md5: "1B2M2Y8AsgTpgAmY7PhCfg==",
  payload: %{"data" => %{}},
  registration_id: "reg ID",
  updated_registration_id: nil
}

Updates "data" key on push payload and calculates md5 hash.

Examples

iex> n = %Pigeon.ADM.Notification{}
iex> Pigeon.ADM.Notification.put_data(n, %{"message" => "your message"})
%Pigeon.ADM.Notification{
  consolidation_key: nil,
  md5: "qzF+HgArKZjJrpfcTbiFxg==",
  payload: %{
    "data" => %{"message" => "your message"}
  },
  registration_id: nil,
  updated_registration_id: nil
}