View Source Pigeon.FCM.Notification (Pigeon v2.0.1)

Defines FCM notification struct and convenience constructor functions.

Summary

Types

t()

FCM notification target. Must be one of the following

Functions

Creates FCM.Notification struct with given target and optional notification and data payloads.

Types

error_response()

@type error_response() ::
  :unspecified_error
  | :invalid_argument
  | :unregistered
  | :sender_id_mismatch
  | :quota_exceeded
  | :unavailable
  | :internal
  | :third_party_auth_error
  | :unknown_error

t()

@type t() :: %Pigeon.FCM.Notification{
  __meta__: Pigeon.Metadata.t(),
  android: map() | nil,
  apns: map() | nil,
  data: map() | nil,
  error: map() | nil,
  fcm_options: map() | nil,
  name: binary() | nil,
  notification: map() | nil,
  response: atom() | nil,
  target: target(),
  validate_only: boolean() | nil,
  webpush: map() | nil
}

target()

@type target() :: {:token, binary()} | {:topic, binary()} | {:condition, binary()}

FCM notification target. Must be one of the following:

  • {:token, "string"} - Registration token to send a message to.
  • {:topic, "string"} - Topic name to send a message to, e.g. "weather". Note: "/topics/" prefix should not be provided.
  • {:condition, "string"} - Condition to send a message to, e.g. "'foo' in topics && 'bar' in topics".

Functions

new(target, notification \\ nil, data \\ nil)

Creates FCM.Notification struct with given target and optional notification and data payloads.

Examples

iex> Pigeon.FCM.Notification.new({:token, "reg ID"})
%Pigeon.FCM.Notification{
  data: nil,
  notification: nil,
  target: {:token, "reg ID"}
}

iex> Pigeon.FCM.Notification.new({:topic, "example"})
%Pigeon.FCM.Notification{
  data: nil,
  notification: nil,
  target: {:topic, "example"}
}

iex> Pigeon.FCM.Notification.new({:token, "reg ID"}, %{"body" => "test message"})
%Pigeon.FCM.Notification{
  data: nil,
  notification: %{"body" => "test message"},
  target: {:token, "reg ID"}
}

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