Trouble with MvvmCommunityToolkit Badge in .NET MAUI: Badge Not Reflecting on Google Pixel Mobile

103 Views Asked by At

I am attempting to display the number of notifications on the app icon using a badge. However, it is not functioning as expected. I am following the official documentation (https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/essentials/badge?tabs=android) for the Badge, but permissions for Google's Pixel mobile are not provided.

I Used badge provided by MvvmCommunityToolkit in viewModel

 private readonly IBadge badge;


 public RequestViewModel(IBadge badge)
 {
     this.badge = badge;

 }

 [RelayCommand]
 private async Task ViewDetails()
 {
     badge.SetCount(2);
 }

when this command is getting hit this badge set the counting on app icon as provided in documentation

In MauiProgram.cs

 var builder = MauiApp.CreateBuilder();
 builder
     .UseMauiApp<App>()
      .UseMauiCommunityToolkit()
     .RegisterAppServices()
     .UseMauiCommunityToolkit()
     .RegisterViewModels()
     .RegisterViews()
     .ConfigureMopups()
     .ConfigureFonts(fonts =>
     {
         fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
         fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
         fonts.AddFont("fa-solid-900.ttf", "Icons");
         fonts.AddFont("Poppins-Regular.ttf", "Poppins");

     });
 builder.Services.AddMemoryCache();
 builder.Services.AddSingleton<IBadge>(Badge.Default);
0

There are 0 best solutions below