brendandonovan
brendandonovan5mo ago

Push notifications with FCM

Hi there, we have a live app built on FlutterFlow and are running into an issue where the app icon notification badge does not appear on iOS when a push notification is triggered, but works on Android. According to FlutterFlow, they are blocked from solving this issue due to the following Firebase bug (https://github.com/firebase/flutterfire/issues/9563). Using Buildship, is there a way to listen to the incoming FCM push notifications and update the recipient’s badge count? Or perhaps set a periodic background listener to update the badge count? Any workarounds would be incredibly helpful. Thanks so much in advance for your help.
GitHub
Issues · firebase/flutterfire
🔥 A collection of Firebase plugins for Flutter apps. - Issues · firebase/flutterfire
Solution:
This is worth a try. I've updated the Flutterflow Notifications node to add the badge count for iOS in the format FCM requires. A few things to remember with badgeCount, however... 1. Value Type: The badge count (badgeCount) should be a non-negative integer. Negative values are not valid and may be ignored or lead to unexpected behavior. ...
Jump to solution
7 Replies
Gaurav Chadha
Gaurav Chadha5mo ago
cc @Stu any suggestion if this could be solved using BuildShip?
Stu
Stu5mo ago
I'm curious to know if the latest update to Flutterflow has solved this for you @brendandonovan https://community.flutterflow.io/c/whats-new-in-flutterflow/post/what-s-new-in-flutterflow-april-25-2024-W6bpyQnwtHWEP8d (cc @Gaurav Chadha )
FlutterFlow Community
What's New in FlutterFlow | April 25, 2024
Dive into some exciting new features including notification count badges for iOS, support for Apple's privacy manifest, a redesigned color picker and so much more. Let’s explore ...
brendandonovan
brendandonovan5mo ago
Unfortunately, the new FlutterFlow update hasn't addressed this issue. It currently only allows badge updates when the app is open, not in the background. My goal is to update the recipients badge one push notification trigger. On Android, the badge count updates automatically for recipients, but on iOS, it does not. @Stu
Stu
Stu5mo ago
Ah, you're quite right @brendandonovan - do you have access to the user's device token? If you do, we could update the badge count from Buildship.
brendandonovan
brendandonovan5mo ago
I’m able to fetch the FCM token, which is what FCM uses to send messages to a specific device through APNs (for iOS devices). Would this work or do I need the specific device token? For security purposes Apple may not give me access to this… each user who enables push notifications on their device gets an FCM token which I can fetch like this: import 'package:firebase_messaging/firebase_messaging.dart'; Future<void> getFcmToken() async { FirebaseMessaging messaging = FirebaseMessaging.instance; String? fcmToken = await messaging.getToken(); print("FCM Token: $fcmToken"); }
Solution
Stu
Stu5mo ago
This is worth a try. I've updated the Flutterflow Notifications node to add the badge count for iOS in the format FCM requires. A few things to remember with badgeCount, however... 1. Value Type: The badge count (badgeCount) should be a non-negative integer. Negative values are not valid and may be ignored or lead to unexpected behavior. 2. Updating the Badge Count: The badge count set via push notification is entirely controlled by the server-sent payload. It's not automatically incremented or decremented by iOS; your server needs to track and send the correct count based on the app's specific logic (e.g., number of unread messages). 3. Resetting the Badge Count: To remove the badge, send a push notification with the badge count set to 0.
brendandonovan
brendandonovan5mo ago
Thanks @Stu! To clarify, this looks a bit different than just modifying the Inputs section in the FF push notification node. To go about modifying it as you've recommended, what part of the node would I update (Node Logic, Inputs, Output, Info, all of them)? Sorry for the elementary question, still new to Buildship.