nishanthg92

nishanthg92

Push notifications using Elixir Channels?

Can i use elixir channels to push notification to android or IOS device like how google firebase do??

Most Liked

idi527

idi527

You would have to write a transport [0] (or something like that) for push notifications, probably (which are usually http/2 now) since they are different from websockets and long poll with which channels work right now.

It would be easier to just use one of the libraries made exactly for push notifications [1][2][3] and call their functions from within your channels.

You might also want to consider using something like a queue or a genstage [4].

[0] Phoenix.Socket.Transport — Phoenix v1.8.8
[1] GitHub - inaka/apns4erl: Apple Push Notification Server for Erlang · GitHub – ios only (supports http/2)
[2] GitHub - codedge-llc/pigeon: iOS and Android push notifications for Elixir · GitHub – ios and andriod (supports http/2)
[3] GitHub - chvanikoff/apns4ex: APNS for Elixir · GitHub – ios only (http/1.1 only?)
[4] https://blog.discordapp.com/how-discord-handles-push-request-bursts-of-over-a-million-per-minute-with-elixirs-genstage-8f899f0221b4

greenz1

greenz1

I went through the Pigeon library’s docs. It uses HTTP2. FCM too relies on persistent HTTP connection. Below I have attached a comparison of HTTP and MQTT.

MQTT was designed for connecting devices, sensors, etc. over an unreliable network. It has a low network overhead. Thus, keeping persistent TCP connection is more battery efficient. Further MQTT was built for remote sensors which don’t have huge power backups available. Read the articles below as they have done a better job at explaining the why and how.

https://medium.com/@shubhanshusingh/http-vs-mqtt-9008d448bf88
https://systembash.com/mqtt-vs-websockets-vs-http2-the-best-iot-messaging-protocol/

https://www.ibm.com/developerworks/community/blogs/sowhatfordevs/entry/using_mqtt_protocol_advantages_over_http_in_mobile_application_development5?lang=en

But there might be other reasons as to why you wouldn’t want MQTT. If you or your organization is reluctant to monitor security at ports other than 80 or you already have running infrastructure over HTTP2 or other preferences then you wouldn’t want to run MQTT.

And there is a good use case where a firm opted out of MQTT.

I for one feel there are too many benefits with MQTT along with customisability to overlook. MQTT gives necessary autonomy and fliexibility to build a highly customised mobile app, IoTproduct.

greenz1

greenz1

Check my answer on the same topic. Many answers here are not battery friendly.

idi527

idi527

How exactly is mqtt more battery friendly than something like apns? Both of these require a persistent tcp connection, do they not?

idi527

idi527

I do like mqtt as well, but the overhead from ws/mqtt/http2 is negligible in comparison with that of tcp, so I don’t think there is much difference in practice.

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
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
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
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
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

Darmani72
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
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
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
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New

We're in Beta

About us Mission Statement