A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
On iOS, the badge number on the app icon is not cleared automatically when the app is opened. The app (or the server sending the push) must explicitly set or reset the badge count.
For a .NET MAUI/iOS app this is done via the iOS APIs that control the application icon badge number:
-
UIApplication.ApplicationIconBadgeNumber - Or, when scheduling local notifications,
UILocalNotification.ApplicationIconBadgeNumber
To clear the badge when the app is opened, set the badge number to 0 in the iOS-specific startup code (for example in FinishedLaunching or when the app becomes active):
using UIKit;
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
// ... existing setup code ...
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
return base.FinishedLaunching(app, options);
}
public override void OnActivated(UIApplication uiApplication)
{
base.OnActivated(uiApplication);
// Clear badge whenever the app becomes active
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
}
If using local notifications, ensure that any UILocalNotification created does not keep incrementing the badge unintentionally, or that the server-side push payload sets the correct badge value.
Without this explicit reset, iOS will keep showing the last badge number that was set.
References: