I have implemented below navigation for my app which has login and logout feature. How to block hardware Back button and re-login again. Below is the flow:
1) Login page is the MainPage when App launch
MainPage = new Login();
2) After successfully login, user will be navigated to MainMenu Page
NavigationPage NP = new NavigationPage(new MainMenu());
App.current.MainPage = Np;
In MainMenu:
1) How to I override the Hardware button for iOS and Android (but iOS has no Back Button in current ipad and iphone).
This is what I got so far to stop back button.
protected override bool OnBackButtonPressed()
{
base.OnBackButtonPressed();
return false
}
1a) How to detect if device is iOS and Android phone? Since iOS has no back Button, will onBackButtonPressed() apply to it?
1b) will putting return false before or after base.OnBackButtonPressed(), make a difference?
2) User logout
in the beginning: Login -> MainMenu: in MainMenu page, user click Logout button
void LogoutButton()
{
Navigate.PopModalAsync(new Login());
}
will this cause any problem since the first time login, MainPage is App.current.MainPage = Np;
Now what is the Mainpage = ?? when user click Logout button?
What happen when user login again? Which Navigation method I should use to go back to Login Page?
Thanks