0

I am using TabbedPage in Xamarin forms. In iOS I am not able to update TabbedPage badge item value. I am using custom renderer for iOS. My code is :

[assembly: ExportRenderer(typeof(TabbedPage), typeof(BottomTabbedPage))]
namespace Graysons.iOS.Renderers
{
    public class BottomTabbedPage : TabbedRenderer
    {
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            TabBar.UnselectedItemTintColor = UIColor.FromRGB(208, 208, 208);
            TabBar.BackgroundColor = UIColor.White;
            TabBar.Items[1].BadgeValue = "1";
            TabBar.Items[2].BadgeValue = "1";
        }
    }
}

When app is initialized first time badge value is display. But problem is I want to update badge value when my app is open from background mode(i.e. press Home button and reopen app). Also when in foreground mode I want to update this value. How can I achieve this?

Srusti Thakkar
  • 1,835
  • 2
  • 22
  • 52
  • The code you've shown will always have a value of "1". Is this the code you're using, or are you doing something else? (This will help me understand the issue you may be having.) – Curtis Shipley Jul 06 '18 at 14:03
  • Actually I am using Settings Plugin for Xamarin and stored value of notification count in that and bind that value. – Srusti Thakkar Jul 09 '18 at 04:21

1 Answers1

0

I think you should have the BadgeValue added as a property to your TabbedPage. You should then be able to pull it out with:

if(Element is MyTabbedPage myTabbedPage)
        {
            TabBar.Items[1].BadgeValue = myTabbedPage.YourProperty;
        }
mrmichaeldev
  • 329
  • 3
  • 11