Owens

Owens

WebSockets vs Push Notifications (AWS Pinpoint)

Hello all, I am developing a new mobile app with Flutter frontend and Phoenix backend. The mobile app has real-time task management and chat. The Flutter app will also be available on web and desktops.

I’m a little confused about the difference between using Phoenix WebSockets vs Push Notifications via a service like AWS Pinpoint.

Do Push Notifications handle chat on a mobile app? Or is that through WebSockets and the Push Notification is just the notification?

If it’s WebSockets, is the connection kept open when the app is in the background?

Appreciate any insights.

Most Liked

sb8244

sb8244

Author of Real-Time Phoenix

I am not aware of Push Notifications being used for chat features. Push notifications are from server->client, which means that you would not be able to send data back up from client->server with them (although you could make regular web requests for that). While push notifications are usually instant, I don’t think you’re guaranteed that.

Where Push Notifications shine is if you want to send the user an event while the app is not open. I’m not sure about Android, but iOS will not keep your WebSocket open while the app is closed. So if you want to get real-time updates, you would need to send them over APNS.

Our approach for a mobile app at work (server->client feed events) is to always send an APNS event for any new notification. When the client boots, it tells the OS that it wants to intercept the APNS event and then it discards it. Instead, it has a WebSocket connection using Phoenix Channels (React Native) that allows it to receive the real-time events via the WebSocket. The benefit of this, even though we’re not pushing data from client->server is that the infrastructure can be monitored by us and we can keep track of things like latency to push. We give that up if we relied only on APNS. We can also easily add new features that would require client->server without rethinking our approach.

siddhant3030

siddhant3030

With pull notifications, mobile apps are required to continually poll the developer’s server, connecting every few minutes to determine if new information is available. With push notifications, however, the cloud service acts on behalf of the app and only connects to the mobile device when there are new notifications. If the device is powered on but the app is not running, the service will still forward the notification. If the device is powered off when a notification is sent, the service will hold on to the message and try again later.

Also, push notification doesn’t handle the chat on your mobile app. If you want to notify about something in your app you can use that. Like every time user send the message and if a user has not open the chat app then it will notification like that you have received a “new message”

I recently implemented push notification in flutter for iOS. If you want to test it with firebase using APNS you can send a message from the firebase to your mobile.

If you don’t want to use firebase then you can send the notification from the Phoenix server also using Pigeon library.

siddhant3030

siddhant3030

I think you need something similar to firebase. So AWS Pinpoint can work. There is also amazon sns you can try.

Where Next?

Popular in Discussions Top

PragTob
Hello everyone, I know we had quite some threads (read through lots of them) about background job processing but it remains a hotly deba...
New
mikl
I wanted to capitalize a string, and tried using String.capitalize(). That generally works well, until you try to capitalize a word like...
New
cvkmohan
The upcoming Phoenix 1.6 release looks very interesting. Became a habit to watch the commits - and - what they are bringing in. phx.gen...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39247 209
New
crabonature
I’m still quite new to Elixir. As I understand we got in Elixir “multi guards” as convention to simplify one large guard with or’s?: de...
New
New
jer
I’ve been using umbrellas for a while, and generally started off (on greenfield projects at least) by isolating subapps based on clearly ...
New
jsonify
So, is Heroku the only free option for hosting Phoenix/Elixir at this point? I’m not ready to commit to paying monthly and was wondering ...
New
und0ck3d
Hello everyone! A few days ago I’ve created a topic here about how people were creating CMSs with Elixir and Phoenix. I’ve been studying...
New
griffinbyatt
Sobelow Sobelow is a security-focused static analysis tool for the Phoenix framework. For security researchers, it is a useful tool for g...
New

Other popular topics Top

stefanchrobot
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
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
RisingFromAshes
I've read in another post that it may be possible with a router helper - but I couldn't find an appropriate one, and tbh, I'm still just ...
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
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement