ExFirebase v0.3.1 ExFirebase.Messaging View Source
Firebase messaging interface
Link to this section Summary
Functions
Enqueues a message payload for immediate delivery in a GenStage pipeline
Sends a push notification with Firebase Cloud Messaging v1 API
Link to this section Functions
Link to this function
get_queue_stats()
View Source
get_queue_stats() :: ExFirebase.Messaging.QueueMonitor.state()
Enqueues a message payload for immediate delivery in a GenStage pipeline
Link to this function
send(payload)
View Source
send(map()) :: {:ok, HTTPoison.Response.t()} | {:error, HTTPoison.Error.t()} | {:error, ExFirebase.Error.t()}
Sends a push notification with Firebase Cloud Messaging v1 API
Examples
iex> ExFirebase.Messaging.send(%{message: %{token: "dyZHH...", notification: %{body: "Hello World"}}})
{:ok,
%HTTPoison.Response{
body: %{
"name" => "projects/project-id/messages/0:1544204830625699%2575e27c2575e27c"
},
...
status_code: 200
}}
iex> ExFirebase.Messaging.send(%{message: %{token: ""}})
{:ok,
%HTTPoison.Response{
body: %{
"error" => %{
"code" => 400,
"details" => [...],
"message" => "The registration token is not a valid FCM registration token",
"status" => "INVALID_ARGUMENT"
}
},
...
status_code: 400
}}