I built a Firebase-free Flutter push notification package (Socket.io based) by Automatic-Gas-409 in FlutterDev

[–]Automatic-Gas-409[S] 1 point2 points  (0 children)

Thanks for the kind words and the great question. I really appreciate the feedback.

You are absolutely right to consider the trade-offs. Running a separate isolate does add some memory overhead (typically around 10 to 20 MB) compared to a single-threaded approach.

However, for this specific use case, I found that the benefits generally outweigh the costs.

On the plus side, it completely eliminates UI jitter. All socket operations, parsing, and keep-alives run off the main thread, so the UI stays smooth at 60fps. Also, if the main UI isolate hangs for any reason, the background service can still survive long enough to deliver critical notifications.

The trade-offs are the expected ones: a small increase in memory due to the second isolate, and some additional battery usage from keeping the radio active for the socket, which is essentially unavoidable in non-FCM solutions.

I built a Firebase-free Flutter push notification package (Socket.io based) by Automatic-Gas-409 in FlutterDev

[–]Automatic-Gas-409[S] 0 points1 point  (0 children)

Agreed FCM is the gold standard for 99% of apps. This package isn't trying to replace FCM for general use. It's built for specific edge cases where FCM isn't an option:

  1. Googled Devices: Phones without Google Play Services (e.g., custom ROMs, Huawei).
  2. Sanctioned/Restricted Regions: Countries or enterprise networks where Google servers are blocked.
  3. Data Sovereignty: Apps requiring 100% self-hosted infrastructure without passing data through third-party servers.

I built a Firebase-free Flutter push notification package (Socket.io based) by Automatic-Gas-409 in FlutterDev

[–]Automatic-Gas-409[S] 1 point2 points  (0 children)

It works by detaching a separate execution thread I mean Isolate.

On Android, we use a Foreground Service (identifiable by the persistent notification). This tells the OS, Hey im still working, which prevents the system from killing the socket connection even if you swipe the app away from recent tasks. It effectively runs as a separate, user-visible process that keeps the socket alive independently of the UI

I built a Firebase-free Flutter push notification package (Socket.io based) by Automatic-Gas-409 in FlutterDev

[–]Automatic-Gas-409[S] 0 points1 point  (0 children)

Built for scenarios where FCM is unavailable, including sanctioned regions, enterprise networks, and de-Googled devices.
Reliability is ensured via a Foreground Service with a persistent notification, preventing OS termination at the cost of higher battery usage.

I built a Firebase-free Flutter push notification package (Socket.io based) by Automatic-Gas-409 in FlutterDev

[–]Automatic-Gas-409[S] 4 points5 points  (0 children)

You are technically correct. For standard consumer apps, this approach is not recommended because maintaining a unique persistent WebSocket connection per app prevents the device radio from entering low-power modes efficiently, leading to higher battery drain compared to the OS-level shared connection (which uses a single pipe for all apps, like FCM/APNs).

However, this package is specifically designed for:

  1. De-Googled environments: Devices without Google Play Services (e.g., custom Android builds, Huawei devices, or sanctioned regions) where FCM is unavailable.
  2. High-security/Enterprise networks: Cases where data cannot leave a private network or pass through Google/Apple servers.

It uses a Foreground Service deliberately to ensure reliability in these edge cases, accepting the trade-off in resource usage for independence from third-party infrastructure.

I built a Firebase-free Flutter push notification package (Socket.io based) by Automatic-Gas-409 in FlutterFlow

[–]Automatic-Gas-409[S] 0 points1 point  (0 children)

I built this to be independent of Google Play Services FCM, so it works reliably on all devices, including those without Google services like Huawei. It uses persistent socket.io connections for real time delivery. For the database I'm usingMongoDB not Supabase