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

owaisqayum
I have a sample string sentence = "Hello, world ... 123 *** ^%&*())^% %%:>" From this string, I want to only keep the integers, ...
New
Fl4m3Ph03n1x
Background This question comes mainly from my ignorance. Today is Black Friday, one of my favorite days of the year to buy books. One boo...
New
chuck
Let me start by stating an assumption: Phoenix is a great approach to building REST APIs. There are many reasons for this, but I will ass...
New
lucaong
Hello Elixir and Nerves community, I have been working for a while on an open-source embedded key-value database for Elixir, that I call...
230 14049 124
New
AstonJ
Are there any Elixir or Erlang libraries that help with this? I’ve been thinking how streaming services like twitch have exploded recentl...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
tomekowal
Hey guys! I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
opsb
We’re considering our architecture from a viewpoint of scaling our traffic heavily over the next 6 months. Our current deployment is runn...
New
New

Other popular topics Top

WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
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
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
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
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
New

We're in Beta

About us Mission Statement