on authcompleted what to navigate to main landing page get below error

I am able to successfully authenticate the user ; now i want navigate to page called page1; i tried different method with no luck one of then ( await Navigation.PushAsync(new Page1(),false);) got below error;

            await store.SaveAsync(account = e.Account, Constants.AppName);
            await Navigation.PushAsync(new Page1(),false);

            //MainPage = new NavigationPage(new Page1());

            //await DisplayAlert("Email address", user.Email, "OK");

        }

Unhandled Exception:

System.InvalidOperationException: PushAsync is not supported globally on Android, please use a NavigationPage.

Any help appreciated.

Answers

  • nAVINdnAVINd USMember

    complete code
    async void OnAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
    {
    var authenticator = sender as OAuth2Authenticator;
    if (authenticator != null)
    {
    authenticator.Completed -= OnAuthCompleted;
    authenticator.Error -= OnAuthError;
    }

            User user = null;
            if (e.IsAuthenticated)
            {
                // If the user is authenticated, request their basic user data from Google
    
                var request = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, e.Account);
                var response = await request.GetResponseAsync();
                if (response != null)
                {
                    // Deserialize the data and store it in the account store
                    // The users email address will be used to identify data in SimpleDB
                    string userJson = await response.GetResponseTextAsync();
                    user = JsonConvert.DeserializeObject<User>(userJson);
                }
    
                if (account != null)
                {
                    store.Delete(account, Constants.AppName);
                }
    
                await store.SaveAsync(account = e.Account, Constants.AppName);
                await Navigation.PushAsync(new Page1(),false);
    
                //MainPage = new NavigationPage(new Page1());
    
                //await DisplayAlert("Email address", user.Email, "OK");
    
            }
    
  • YorkGoYorkGo CNMember, Xamarin Team Xamurai

    PushAsync is not supported globally on Android, please use a NavigationPage.

    Please refer to: https://stackoverflow.com/questions/24621814/pushasync-is-not-supported-globally-on-android-please-use-a-navigationpage-xa

Sign In or Register to comment.