I am trying to unsubscribe from the messaging center when the user uses the back button (top left) on a certain page. I am already doing it for the hardware back button
protected override bool OnBackButtonPressed()
{
MessagingCenter.Unsubscribe<App, string>(this, "Trolley");
return base.OnBackButtonPressed();
}
But it does not work for the back button showing on screen. I am aware of the existence of "OnDisappearing" but it does not work in my case because I actually need it to work when entering a new page.
I am on Page 1 and subscribe to "Trolley" then I load page 2, send a message "Trolley" and finally close page 2. OnDisappearing triggers when I load page 2 so I wouldn't be able to receive the message if I where to unsubscribe in OnDisappearing.