A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Hi @Kim Strasser ,
Thanks for your question.
Android does not automatically reset the app icon badge just because the app was launched. So I recommend clearing the notifications by adding these two methods to Activity1.cs (the main activity):
using AndroidX.Core.App;
using CommunityToolkit.Maui;
protected override void OnResume()
{
base.OnResume();
ClearBadgeAndNotifications();
}
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
ClearBadgeAndNotifications();
}
private void ClearBadgeAndNotifications()
{
var notificationManager = NotificationManagerCompat.From(this);
notificationManager.CancelAll();
try
{
Badge.Default.SetCount(0); // You need to install CommunityToolkit.Maui
}
catch { }
}
Also update OnCreate to call it once after setup if needed:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// ... your existing code
ClearBadgeAndNotifications();
}
Note: Setup if you want to use Badge.Default.SetCount(0):
- Install the NuGet package
CommunityToolkit.Maui - In your startup code (usually MainApplication.cs or MauiProgram.cs), make sure you have
builder.UseMauiCommunityToolkit();
After adding the code, please clean and rebuild your project. Then, uninstall the app -> reinstall and test again.
On some phones, the badge may still not clear perfectly. In that case:
- Please long-press your app icon -> App info -> Notifications -> Turn "Notification dot" or "Badges" off and back on.
- Or go to Settings → Apps → Your App → Storage → Clear Cache.
Please give it a try and let me know if it works as expected.
I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback.