xamarin / Xamarin.Auth

Xamarin.Auth
Apache License 2.0
541 stars 351 forks source link

Xamarin web view not dismissing on DismissViewController #434

Open tm-peyton-dent opened 4 years ago

tm-peyton-dent commented 4 years ago

We've been fighting for days attempting to get a Xamarin.Auth web view to close. We passed it into a renderer in iOS and can call DismissViewController but it doesn't seem to go away. And weirdly enough, it's saying the view is not being presented when investigating the object. This is in version 1.7.0 on iOS

OAuth2Authenticator authenticator = new InstagramAuthenticator(
clientId: queryParams["app_id"],
scope: queryParams["scope"],
authorizeUrl: uriBuilder.Uri,
redirectUrl: new Uri(queryParams["redirect_uri"]),
isUsingNativeUI: (Device.RuntimePlatform == Device.Android),
getUsernameAsync: null);

OAuthLoginPresenter presenter = new OAuthLoginPresenter();

TaskCompletionSource<InstagramLongTermAccessTokenResponseDto> tcs = new TaskCompletionSource<InstagramLongTermAccessTokenResponseDto>();
void instagramAuthHandler(string code = null, InstagramLongTermAccessTokenResponseDto response = null)
{
    CustomerManageSocialAccountsView.RequestClose.Invoke(authenticator, EventArgs.Empty);
///handle auth code...

}
App.Current.InstagramAuthCallback += instagramAuthHandler;

presenter.Login(authenticator);

In our event handler

var viewController = ((OAuth2Authenticator)sender).GetUI();

viewController.DismissViewController(false, null);