ToolbarItemBadgeSample icon indicating copy to clipboard operation
ToolbarItemBadgeSample copied to clipboard

Crashing on back in ios and doesn't update in android

Open amrkamal1993 opened this issue 6 years ago • 9 comments

It works fine but if you are on a navigation page with zero items go forward and then go back it get crash on iOS. On android the number doesn't update when you go back . At least on my MVVM project.

amrkamal1993 avatar Aug 26 '18 14:08 amrkamal1993

@amrkamal1993 I also facing this issue. @Pujolsluis can you please give any solutions

shashikant0423 avatar Aug 28 '18 12:08 shashikant0423

@shashikant0423 sorry i still looking for the solution :(

amrkamal1993 avatar Aug 28 '18 13:08 amrkamal1993

no help in ios issues ?

amrkamal1993 avatar Sep 06 '18 13:09 amrkamal1993

On Android, I was also facing the same issue: "the badge value was disappearing for example while going back (or pressing the back button).

However, I've fixed the issue by applying the following workaround,

Task.Run(async () =>
                {
                    await Task.Delay(500);

                    //Call the method which should update the badge value here
                });

So, while debugging, I noticed all code and everything looked fine, and most likely the events were not being executed in the right order. However, adding little delay actually fixed it.

mwasim avatar Mar 08 '19 12:03 mwasim

You have to insert in your App.xaml.cs this following code:

public App()
{
        .......
 	navigationPage.Popped += NavigationPage_Popped;
        ........
}

private void NavigationPage_Popped(object sender, NavigationEventArgs e)
{
	if (ToolbarItems.Count() > 0)
	{
		DependencyService.Get<IToolbarItemBadgeService>().SetBadge(e.Page, ToolbarItems.First(), $"{CartNumber}", Color.Red, Color.White);
	}
		
}

Gasdani avatar Mar 22 '19 15:03 Gasdani

On Android, I was also facing the same issue: "the badge value was disappearing for example while going back (or pressing the back button).

However, I've fixed the issue by applying the following workaround,

Task.Run(async () =>
                {
                    await Task.Delay(500);

                    //Call the method which should update the badge value here
                });

So, while debugging, I noticed all code and everything looked fine, and most likely the events were not being executed in the right order. However, adding little delay actually fixed it.

It worked perfectly but there is a slight fluctuation to load the badge, anyhow thanks for the help and btw do you have any idea why this is happening and any other way to fix it?

shubhamkumarnayak avatar Oct 05 '19 00:10 shubhamkumarnayak

On Android, I was also facing the same issue: "the badge value was disappearing for example while going back (or pressing the back button). However, I've fixed the issue by applying the following workaround,

Task.Run(async () =>
                {
                    await Task.Delay(500);

                    //Call the method which should update the badge value here
                });

So, while debugging, I noticed all code and everything looked fine, and most likely the events were not being executed in the right order. However, adding little delay actually fixed it.

It worked perfectly but there is a slight fluctuation to load the badge, anyhow thanks for the help and btw do you have any idea why this is happening and any other way to fix it?

Not sure why is this happening, but most likely it's a bug in the library. Alternatively, you may also try the approach suggested by "Gasdani" above as that may also fix it. Thanks!

mwasim avatar Oct 05 '19 07:10 mwasim

I don't know your code but i doing in this way:

var menuPage = new MasterPage(); 
NavigationPage navigationPage;
navigationPage = new NavigationPage(new PageHome());
navigationPage.Popped += NavigationPage_Popped;
var rootPage = new RootPage(); //This is my MasterDetailPage
rootPage.Master = menuPage;
rootPage.Detail = navigationPage;

Gasdani avatar Oct 05 '19 10:10 Gasdani

Thanks a lot, will try this and let you know :)

On Sat, 5 Oct, 2019, 3:35 PM Gaspare Daniele Fioretto, < [email protected]> wrote:

I don't know you code but i doing in this way: var menuPage = new MasterPage(); NavigationPage navigationPage; navigationPage = new NavigationPage(new PageHome()); navigationPage.Popped += NavigationPage_Popped; var rootPage = new RootPage(); //This is my MasterDetailPage rootPage.Master = menuPage; rootPage.Detail = navigationPage;

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/CrossGeeks/ToolbarItemBadgeSample/issues/3?email_source=notifications&email_token=ABYYG3FBU2G2MOWBVA2VCZLQNBRHZA5CNFSM4FRTHXY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEANO7TI#issuecomment-538636237, or mute the thread https://github.com/notifications/unsubscribe-auth/ABYYG3E4QMXCOUFNVEXVI63QNBRHZANCNFSM4FRTHXYQ .

shubhamkumarnayak avatar Oct 05 '19 14:10 shubhamkumarnayak