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)
Popular in Announcing
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
Hi everyone,
I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
Raxx is an alternative to Plug and is inspired by projects such as Rack(Ruby) and Ring(Clojure).
1.0-rc.1 is now available. To use it re...
New
Hello all,
I have been working on my proposed project called Tensorflex as part of Google Summer of Code 2018.. Tensorflex can be used f...
New
What is ContEx?
A pure Elixir server-side data plotting/charting library outputting SVG.
It has nice barcharts in particular and works g...
New
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
Hey everyone!
Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
Other popular topics
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
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









