Send a push notification (Elixir)
Send a push notification via :thinwrap_notifications.send_push/2 in Elixir — one call shape for FCM, APNs, Expo and every other push provider.
1. Install
{:thinwrap_notifications, "~> 1.2"}2. Send the call
config = %{
provider: :fcm,
project_id: System.fetch_env!("FCM_PROJECT_ID"),
client_email: System.fetch_env!("FCM_CLIENT_EMAIL"),
private_key: System.fetch_env!("FCM_PRIVATE_KEY")
}
case :thinwrap_notifications.send_push(config, %{
to: device_token,
title: "Hello",
body: "Hello from Thinwrap",
data: %{"deepLink" => "/orders/42"}
}) do
{:ok, %{status: status, provider_message_id: id}} ->
IO.puts("#{status} #{id}")
{:error, %{code: code, message: message}} ->
IO.puts("#{code}: #{message}")
end
Same code works for all supported providers — just change the provider ID.