locked
Xamarin Forms Badge on app icon RRS feed

  • Question

  • User302481 posted

    Hi, Im using the nugget plugin for badges in cross platform. I've tried many ways, but I can't get it to work.

    protected override void OnSleep() { Badge.Plugin.CrossBadge.Current.SetBadge(10); }

    Thursday, February 23, 2017 4:20 PM

Answers

  • User171749 posted

    https://github.com/B1naryStudio/Xamarin.Badge

    There is the documentation. Have you installed it in the other projects like iOS and Android? Doesn't look like you have to initialise this one. Try running CrossBadge.Current.SetBadge(10); in AppDelegate and see if it has the effect your expecting.

    Instead of installing additional packages to handle a simple thing, I just use the DependencyService with this method... for iOS anyway not sure about other platforms

    public void SetBadgeNumber(int number)
            {
                UIApplication.SharedApplication.ApplicationIconBadgeNumber = number;
            }
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, February 23, 2017 4:29 PM
  • User302481 posted

    i have fount the answer. I already tried to use DependecyService. But I missed the permissions.

    I added ` var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Badge, null);

    UIApplication.SharedApplication.RegisterUserNotificationSettings(settings); `

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, February 24, 2017 9:31 AM

All replies

  • User171749 posted

    Which one? Chances is its out dated and not compatible with the latest version of forms. Also make sure to install it in each platform specific project and initialise it in AppDelegate, MainActivity etc.

    Thursday, February 23, 2017 4:23 PM
  • User302481 posted

    Im using this one. How can I call in the AppDelegate? There is no documentation. Im a bit new in xamarin, sorry.

    Thursday, February 23, 2017 4:26 PM
  • User171749 posted

    https://github.com/B1naryStudio/Xamarin.Badge

    There is the documentation. Have you installed it in the other projects like iOS and Android? Doesn't look like you have to initialise this one. Try running CrossBadge.Current.SetBadge(10); in AppDelegate and see if it has the effect your expecting.

    Instead of installing additional packages to handle a simple thing, I just use the DependencyService with this method... for iOS anyway not sure about other platforms

    public void SetBadgeNumber(int number)
            {
                UIApplication.SharedApplication.ApplicationIconBadgeNumber = number;
            }
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, February 23, 2017 4:29 PM
  • User302481 posted

    i have fount the answer. I already tried to use DependecyService. But I missed the permissions.

    I added ` var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Badge, null);

    UIApplication.SharedApplication.RegisterUserNotificationSettings(settings); `

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, February 24, 2017 9:31 AM
  • User369501 posted

    @csampaio01 your solution for badge count on app icon is work for me on IOS app but how to do same for Android app. Thanks in advance. :smile:

    Thursday, June 7, 2018 11:32 AM