Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1234 from xamarin/develop
Browse files Browse the repository at this point in the history
Late 1.5.3 fix for WebAuthenticator
  • Loading branch information
Redth committed Apr 20, 2020
2 parents 98abb5a + b7da1f5 commit d7ba066
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs
Expand Up @@ -24,6 +24,10 @@ public static partial class WebAuthenticator
static TaskCompletionSource<WebAuthenticatorResult> tcsResponse;
static UIViewController currentViewController;
static Uri redirectUri;
#if __IOS__
static ASWebAuthenticationSession was;
static SFAuthenticationSession sf;
#endif

internal static async Task<WebAuthenticatorResult> PlatformAuthenticateAsync(Uri url, Uri callbackUrl)
{
Expand Down Expand Up @@ -55,7 +59,7 @@ void AuthSessionCallback(NSUrl cbUrl, NSError error)

if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
{
var was = new ASWebAuthenticationSession(new NSUrl(url.OriginalString), scheme, AuthSessionCallback);
was = new ASWebAuthenticationSession(new NSUrl(url.OriginalString), scheme, AuthSessionCallback);

if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
Expand All @@ -64,14 +68,20 @@ void AuthSessionCallback(NSUrl cbUrl, NSError error)
}

was.Start();
return await tcsResponse.Task;
var result = await tcsResponse.Task;
was?.Dispose();
was = null;
return result;
}

if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
{
var sf = new SFAuthenticationSession(new NSUrl(url.OriginalString), scheme, AuthSessionCallback);
sf = new SFAuthenticationSession(new NSUrl(url.OriginalString), scheme, AuthSessionCallback);
sf.Start();
return await tcsResponse.Task;
var result = await tcsResponse.Task;
sf?.Dispose();
sf = null;
return result;
}

// THis is only on iOS9+ but we only support 10+ in Essentials anyway
Expand Down

0 comments on commit d7ba066

Please sign in to comment.