question

RajuGadda-8585 avatar image
0 Votes"
RajuGadda-8585 asked JarvanZhang-MSFT answered

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

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

dotnet-xamarinformsdotnet-xamarinessentials
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered

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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.