Pigeon v1.0.4 Pigeon.FCM.Notification View Source

Defines FCM notification struct and convenience constructor functions.

Link to this section Summary

Functions

Creates FCM.Notification struct with device registration IDs and optional notification and data payloads

Updates "data" key in push payload

Updates "notification" key in push payload

Link to this section Types

Link to this type t() View Source
t() :: %Pigeon.FCM.Notification{payload: %{}, priority: :normal | :high, registration_id: String.t | [String.t]}

Link to this section Functions

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

Creates FCM.Notification struct with device registration IDs and optional notification and data payloads.

Examples

iex> Pigeon.FCM.Notification.new("reg ID")
%Pigeon.FCM.Notification{
  payload: %{},
  registration_id: "reg ID",
  priority: :normal
}

iex> Pigeon.FCM.Notification.new("reg ID", %{"body" => "test message"})
%Pigeon.FCM.Notification{
  payload: %{"notification" => %{"body" => "test message"}},
  registration_id: "reg ID",
  priority: :normal
}

iex> Pigeon.FCM.Notification.new("reg ID", %{"body" => "test message"}, %{"key" => "value"})
%Pigeon.FCM.Notification{
  payload: %{
    "data" => %{"key" => "value"},
    "notification" => %{"body" => "test message"}
  },
  registration_id: "reg ID",
  priority: :normal
}

Updates "data" key in push payload.

Examples

iex> Pigeon.FCM.Notification.put_data(%Pigeon.FCM.Notification{}, %{"key" => 1234})
%Pigeon.FCM.Notification{
  payload: %{"data" => %{"key" => 1234}},
  registration_id: nil
}
Link to this function put_notification(n, notification) View Source

Updates "notification" key in push payload.

Examples

iex> Pigeon.FCM.Notification.put_notification(%Pigeon.FCM.Notification{},
...> %{"body" => "message"})
%Pigeon.FCM.Notification{
  payload: %{"notification" => %{"body" => "message"}},
  registration_id: nil
}