Pigeon v1.0.4 Pigeon.ADM.Notification View Source

Defines Amazon ADM notification struct and convenience constructor functions.

Link to this section Summary

Functions

Calculates md5 hash of notification data payload

ADM requires that “data” keys and values are all strings

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

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

Link to this section Types

Link to this type t() View Source
t() :: %Pigeon.ADM.Notification{consolidation_key: String.t, expires_after: integer, md5: binary, payload: %{}, registration_id: String.t, updated_registration_id: String.t}

Link to this section Functions

Link to this function calculate_md5(notification) View Source

Calculates md5 hash of notification data payload.

ADM requires that “data” keys and values are all strings.

Link to this function new(registration_id, data \\ %{}) View Source

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
}

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
}