Flutter show app icon badge on push notification - flutter

I'm looking for a way to show an app icon badge when a user receives a push notification.
I'm using the Firebase_messaging plugin for flutter for the handling of the push notifications and flutter_app_badger for the app icon badges.
But I want to combine the two so that the number is set on the icon without opening the app. Is it possible to make this happen? Or am I overlooking something obvious from the firebase_messaging plugin?
Sorry for the horrible explanation. I hope someone can help me with this issue.

App icon badge depends on the Application Launcher
Some of the Android Application Launcher includes this functionality by default, You can check this on Settings->Apps->Notification
Attached image
FYI
How to show notification count on app icon like Facebook?
How does Facebook add badge numbers on app icon in Android?
adding notification badge on app icon in android

My suspicion is that you have an icon that isn't compatible with the icon guidelines in your device. I suggest trying https://pub.dev/packages/flutter_launcher_icons to make icons for your device.

I think you try to create stream when run app to real time listen doc changes in Firestore. Read here How to listen for document changes in Cloud Firestore using Flutter?
And the icon can be update in background but without opening app is impossible I think.

I don't have a direct answer because I haven't encountered this issue before, but this might fix your problem
Ensure that you have defined the icon for your application properly - for flutter, here are the steps you should have:
Import the package into your pubsec.yaml file - it should be called flutter_launcher_icons: "^0.8.0" and imported under the dev-dependencies section of the pubspec.yaml file.
After the dev-dependencies section, add a new section for flutter icons as so:
flutter_icons:
ios: true
android: true
image_path_ios: "{Icon File Path}"
image_path_android: "{Icon File Path}"
Hopefully this helps, and good luck with fixing your issue!

Using https://pub.dev/packages/firebase_messaging for notifications ,
for Android Background notifications you can add this in your AndroidManifest.xml file in your application tag. And make sure you have androidlogo.png (this is example name) present in your drawable folder.
<application>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/androidlogo" />
</application>
In case of foreground notifications, you must be using Flutter Local Notifications, so you can provide the same while initializing like
var initializationSettingsAndroid = new AndroidInitializationSettings('androidlogo');
flutterLocalNotificationsPlugin.initialize(initializationSettings, onSelectNotification: onNotificationClicked);
And for application icon you can use this library https://pub.dev/packages/flutter_launcher_icons which is also suggested by answers above.
In case of iOS, your launcher icon will your notification icon.
And for display of badge icon you can use https://pub.dev/packages/flutter_app_badger. (For supported phones).
So using all this you will get both app icon with badge and notification icon as your app icon (or specified by you).

You can control the badge count from the notification payload.
If you send a notification manually from Firebase Console, you can set the badge count on Additional options step:
If you send it programmatically, add this payload (iOS example):
{"aps":{"alert":"Enter your message","badge":1,"sound":"default"}}
For more payload options, check out FCM documentation

Related

How to make the flutter app shows as it's an IOS version app inside android

I have a flutter app on an android device, it shows the app with the android adaptive things such as the date picker, the app bar, the dialogs...
I want to try a version of the app like it's on IOS, I mean I want that date picker shows as the IOS's, also for the app bar.
I'm pretty sure that this is related to the MediaQuery, but I just don't know what is it.
I know that I can show forcefully the widgets from the Cupertino library, however, I don't want to do it, I want just to get how the app will show when it runs on IOS with the current code.
Thank you !
Wherever you're setting your theme, you can simply set the platform property on it to TargetPlatform.iOS.
This should allow the theming to use iOS-specific widgets rather than their android counterparts. Note that this may not work everywhere; if Dart:io's Platform were used incorrectly in your code or 3rd party code for theming, this would not be overridden.

How to show dot badge instead of counter badge in app launcher icon?

I am using flutter_local_notifications: ^9.7.0 to show notification and that's really nice package, using that package I am available to get badge with icon "1" when notification pops up. What I would like to ask.. instead of showing "1" badge, I would like to show dot badge. Is there a way to do that using flutter_local_notifications or any other package ?
Notification Badges are Platform's entity & unfortunately, you can not do anything to change it.
As mentioned in Android docs
These dots appear by default in launcher apps that support them and there's nothing your app needs to do.

Flutter (2.5) - A splash screen was provided to Flutter, but this is deprecated

I am new to flutter and recently tried to develop a test app for learning sake with latest version Flutter 2.5. By looking at some tutorial online, I have added flutter_native_splash: ^1.2.3 package for splash screen. And works fine.
However, when I launch app for the first time, it shows following debug message
W/FlutterActivityAndFragmentDelegate(18569): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
After visiting the above link, I am not able to understand much what is supposed to be done.
Code in pubspec.yaml
flutter_native_splash:
color: "#FFFFFF"
color_dark: "#000000"
image: assets/images/splash_720.png
android: true
ios: true
android12: true
Also, compileSdkVersion and targetSdkVersion is set to 31 in build.gradle
Please help. Thanks in advance.
To avoid that warning you just need to remove that API usage from your project.
Remove these lines of code from the AndroidManifest.xml file.
Previously, Android Flutter apps would either set io.flutter.embedding.android.SplashScreenDrawable in their application manifest, or implement provideSplashScreen within their Flutter Activity. This would be shown momentarily in between the time after the Android launch screen is shown and when Flutter has drawn the first frame. This is no longer needed and is deprecated – Flutter now automatically keeps the Android launch screen displayed until Flutter has drawn the first frame. Developers should instead remove the usage of these APIs. - source
UPDATE (FLUTTER 2.8.0)
As per the flutter 2.8.0 update, The newly created project doesn't have this warning.
They removed unused API from Androidmanifest.yml but still have belove mentioned code.
Remove the below lines from the android manifest file. It's no longer used
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"/>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"/>

Is there a way to launch notes application in flutter from button click?

I have a button in my app. On click of the button, I want the notes app in the device to get launched whether iOS or Android. I there a way around this with flutter? I haven't discovered any solution yet.
Yes there is this plugin external_app_launcher will helps you to open another app from your app by providing PackageName for Android and URLscheme for IOS external_app_launcher

Push Notification icon in Settings

I've got an app that uses Apple's Push Notification Service. I'm registered, and receive the notifications just fine. However, when I go into the Settings -> Notifications area, my app is listed, but there's no icon visible. Is there a flag, or a special PNG I need to include in my bundle?
Thanks!
Okay, stupid mistake. The info.plist icon field was empty. By default, the OS still looks for an icon.png file for Springboard, but doesn't use the same trick for the Notification settings.