How to show the notification count over app icon using xamarin forms using visual studio

Raju Gadda 66 Reputation points
2021-09-16T06:14:30.237+00:00

How to show the notification count over app icon using xamarin forms in visual studio .

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,364 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,961 Reputation points
    2021-09-17T02:43:19.89+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    Xamarin.Forms is only an UI framework, this function needs to achieved on each platform. On iOS, please register for user notifications to be able to set the application icon badge number:

       //Register this in the Appdelegate  
       UIUserNotificationSettings settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Badge, null);  
       UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);  
    

    Then use the UIApplication.SharedApplication.ApplicationIconBadgeNumber = number; to set the badge number, you could DependencyService to call the function code in the shared project.

    Unfortunately, the function is limited on Android. Android system doesn't allow changing of the application icon because it is sealed in the .apk tightly once the program is compiled. There is no way to change the icon to a 'drawable' programmatically.

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.