ToolbarItemBadgeSample icon indicating copy to clipboard operation
ToolbarItemBadgeSample copied to clipboard

xamarin forms + mvvmcross can't show badge in ios

Open iQiaoQ opened this issue 5 years ago • 2 comments

xamarin forms + mvvmcross can't show badge in ios

iQiaoQ avatar Oct 10 '19 00:10 iQiaoQ

Is anyone has the answer?

iQiaoQ avatar Oct 11 '19 09:10 iQiaoQ

I do find a solution for the iOS that you may try to see if it works for you when calling the ToolbarItemBadgeService.SetBadge method in the ViewModel

var page = App.Current.MainPage.Navigation.NavigationStack.LastOrDefault();  
var item = page.ToolbarItems.LastOrDefault(); // not necessary the last one
var count = //code to get the count number...

ToolbarItemBadgeService.SetBadge(page, item, count, Color.Red, Color.White);

At first, I only use App.Current.MainPage but when accessing the ToolbarItems, it has zero counts. It seems only App.Current.MainPage.Navigation.NavigationStack.LastOrDefault() returns the real current active page with the toolbar items.

AlvinKwong avatar Aug 05 '20 06:08 AlvinKwong