ericlathrop

ericlathrop

Firebase_cloud_messaging_http_v1_api - Send Firebase Cloud Messaging Push Notifications via the FCM HTTP v1 API

I needed to send push notifications to a mobile app from my elixir server. I wanted to use Firebase Cloud Messaging’s “topics” so I didn’t have to keep track of every individiual device’s token, which requires using the newer FCM HTTP v1 API. All the other libraries I found on hex (like Pigeon) used the deprecated Legacy HTTP protocol. Versions of this code have been in production since April 2019.

From the README:

FirebaseCloudMessagingHttpV1Api

Send Firebase Cloud Messaging Push Notifications via the FCM HTTP v1 API.

Use goth to acquire authentication tokens.

Example

{:ok, %Goth.Token{token: token}} =
  Goth.Token.for_scope("https://www.googleapis.com/auth/firebase.messaging")

%Google.Firebase.FCM.V1.Message{
  notification: %Google.Firebase.FCM.V1.Notification{
    title: "notification title",
    body: "notification body"
  },
  android: %Google.Firebase.FCM.V1.AndroidConfig{
    priority: "HIGH",
    ttl: "86400s",
    notification: %Google.Firebase.FCM.V1.AndroidNotification{
      channel_id: "my-android-channel"
    }
  },
  topic: "my-topic"
}
|> Google.Firebase.FCM.V1.Message.send("projects/my-firebase-project", token)

Where Next?

Popular in Libraries Top

marcuslankenau
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New
tompave
Hello there, I would like to share a feature toggles library (AKA feature flags) I’ve been working on. The main package is FunWithFlags...
New
sabiwara
Dune is a sandbox for Elixir and aims to safely evaluate user-provided code. You can try it out using this basic Elixir playground made ...
New
mbuhot
Leverage Open Api 3.0 (Swagger) to document, test, validate and explore your Plug and Phoenix APIs. Generate and serve a JSON Open API ...
New
mindok
What is ContEx? A pure Elixir server-side data plotting/charting library outputting SVG. It has nice barcharts in particular and works g...
New
New
Crowdhailer
Experimenting with this code. OK.try do user <- fetch_user(1) cart <- fetch_cart(1) order = checkout(cart, user) save_or...
New
mtrudel
Bandit is an HTTP server for Plug and WebSock apps. Bandit is written entirely in Elixir and is built atop Thousand Island. It can serve...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
mplatts
With HEEX released we decided to start a components library using Tailwind CSS - check it out here: Petal Components. We also have a boi...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

Sub Categories:

We're in Beta

About us Mission Statement