My app uses XF 1.3.4 with XLabs 2.0.5520 and the MVVM pattern. Consider the following scenario...
Page A is an item-list page
Page B is an item-detail page with an EDIT button
Page C is an item-edit-wizard page (1 of 2)
Page D is an item-edit-wizard page (2 of 2)
If you click on a list item in Page A, the page does a Navigation.PushAsync for Page B to show the item details.
If you click the [EDIT] button in Page B, the page does a Navigation.PushModalAsync(new NavigationPage( )) for Page C to start the edit process.
If you click ADVANCED in Page C, the page does a Navigation.PushAsync for Page D to allow the user to edit advanced details.
If you click the [SAVE] button in Page C, the page does a Navigation.PopModalAsync which will go back to Page B.
If you click the [SAVE] button in Page D, the page does a Navigation.PopModalAsync which will go back to Page B.
I want to customize the behavior so that clicking on SAVE in Page C or Page D will jump back to Page A, skipping or popping page B.
The recommended pattern for this is to use MessagingCenter. Configure Page C/D to send an "ItemSaved" message when [SAVE] is clicked. Configure Page B to subscribe to this message, and when received, do a Navigation.PopAsync to pop Page B and go back to Page A.
So, I placed the Subscribe in the Page B constructor, and I placed the Unsubscribe in the Page B OnDisappearing method.
The problem - on iOS, when Page B pushes to Page C, page B fires the OnDisappearing method, which Unsubscribes from the "ItemSaved" message. When the SAVE button is clicked in Page C, and the "ItemSaved" message is sent, Page B won't receive the message because it's unsubscribed, and thus won't automatically pop Page B back to Page A.
Note - this works fine on Android because a page's OnDisappearing event isn't fired when a new page is pushed, only when the current page is popped.
Any suggestions on how to resolve this issue, and the difference in behavior between Android and iOS?