Owens

Owens

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.

First 5 of 5 Posts Switch mode

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.

Owens

Owens OP

Awesome thanks for this. So there’s no need for AWS Pinpoint if you are using Pigeon? Also we are not using Firebase as we would like to serve users in China where that is blocked.

siddhant3030

siddhant3030

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

sb8244

sb8244

Author of Real-Time Phoenix

We use Pigeon at SalesLoft and have had 0 issues with it since we released using it. You register your APNS credentials and include them at runtime. It’s also free since it’s just using APNS.

I think that AWS Pinpoint may be for sending 1 notification and determining what method/device the user should receive the notification on?

No idea re: China in this case.

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 91898 914
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement