From 87a754c30f9d756a5652854e0eee87ef75b0aae8 Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Mon, 20 Apr 2020 11:13:18 -0700 Subject: [PATCH 1/3] GH-1210: Try to make AS&SF Static --- .../WebAuthenticator/WebAuthenticator.ios.tvos.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs b/Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs index eae90b326..5ed86aaeb 100644 --- a/Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs +++ b/Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs @@ -24,6 +24,10 @@ public static partial class WebAuthenticator static TaskCompletionSource tcsResponse; static UIViewController currentViewController; static Uri redirectUri; +#if __IOS__ + static ASWebAuthenticationSession was; + static SFAuthenticationSession sf; +#endif internal static async Task PlatformAuthenticateAsync(Uri url, Uri callbackUrl) { @@ -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)) { @@ -69,7 +73,7 @@ void AuthSessionCallback(NSUrl cbUrl, NSError error) 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; } From 1a9e2096b6896b5e4e7aaa7483e3af0e56a84176 Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Mon, 20 Apr 2020 11:45:32 -0700 Subject: [PATCH 2/3] Cleanup statics --- .../WebAuthenticator/WebAuthenticator.ios.tvos.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs b/Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs index 5ed86aaeb..15ff1e560 100644 --- a/Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs +++ b/Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs @@ -68,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)) { sf = new SFAuthenticationSession(new NSUrl(url.OriginalString), scheme, AuthSessionCallback); sf.Start(); - return await tcsResponse.Task; + var result = await tcsResponse.Task; + sf?.Dispose(); + was = null; + return result; } // THis is only on iOS9+ but we only support 10+ in Essentials anyway From 2c49c739c5f8e04f99b80481fc1b7ba982b887ea Mon Sep 17 00:00:00 2001 From: Jonathan Dick Date: Mon, 20 Apr 2020 14:53:03 -0400 Subject: [PATCH 3/3] Update Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs --- .../WebAuthenticator/WebAuthenticator.ios.tvos.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs b/Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs index 15ff1e560..14e523c0e 100644 --- a/Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs +++ b/Xamarin.Essentials/WebAuthenticator/WebAuthenticator.ios.tvos.cs @@ -80,7 +80,7 @@ void AuthSessionCallback(NSUrl cbUrl, NSError error) sf.Start(); var result = await tcsResponse.Task; sf?.Dispose(); - was = null; + sf = null; return result; }