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

Commit d7ba066

Browse files
authored
Merge pull request #1234 from xamarin/develop
Late 1.5.3 fix for WebAuthenticator
2 parents 98abb5a + b7da1f5 commit d7ba066

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public static partial class WebAuthenticator
2424
static TaskCompletionSource<WebAuthenticatorResult> tcsResponse;
2525
static UIViewController currentViewController;
2626
static Uri redirectUri;
27+
#if __IOS__
28+
static ASWebAuthenticationSession was;
29+
static SFAuthenticationSession sf;
30+
#endif
2731

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

5660
if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
5761
{
58-
var was = new ASWebAuthenticationSession(new NSUrl(url.OriginalString), scheme, AuthSessionCallback);
62+
was = new ASWebAuthenticationSession(new NSUrl(url.OriginalString), scheme, AuthSessionCallback);
5963

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

6670
was.Start();
67-
return await tcsResponse.Task;
71+
var result = await tcsResponse.Task;
72+
was?.Dispose();
73+
was = null;
74+
return result;
6875
}
6976

7077
if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
7178
{
72-
var sf = new SFAuthenticationSession(new NSUrl(url.OriginalString), scheme, AuthSessionCallback);
79+
sf = new SFAuthenticationSession(new NSUrl(url.OriginalString), scheme, AuthSessionCallback);
7380
sf.Start();
74-
return await tcsResponse.Task;
81+
var result = await tcsResponse.Task;
82+
sf?.Dispose();
83+
sf = null;
84+
return result;
7585
}
7686

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

0 commit comments

Comments
 (0)