@@ -24,6 +24,10 @@ public static partial class WebAuthenticator
24
24
static TaskCompletionSource < WebAuthenticatorResult > tcsResponse ;
25
25
static UIViewController currentViewController ;
26
26
static Uri redirectUri ;
27
+ #if __IOS__
28
+ static ASWebAuthenticationSession was ;
29
+ static SFAuthenticationSession sf ;
30
+ #endif
27
31
28
32
internal static async Task < WebAuthenticatorResult > PlatformAuthenticateAsync ( Uri url , Uri callbackUrl )
29
33
{
@@ -55,7 +59,7 @@ void AuthSessionCallback(NSUrl cbUrl, NSError error)
55
59
56
60
if ( UIDevice . CurrentDevice . CheckSystemVersion ( 12 , 0 ) )
57
61
{
58
- var was = new ASWebAuthenticationSession ( new NSUrl ( url . OriginalString ) , scheme , AuthSessionCallback ) ;
62
+ was = new ASWebAuthenticationSession ( new NSUrl ( url . OriginalString ) , scheme , AuthSessionCallback ) ;
59
63
60
64
if ( UIDevice . CurrentDevice . CheckSystemVersion ( 13 , 0 ) )
61
65
{
@@ -64,14 +68,20 @@ void AuthSessionCallback(NSUrl cbUrl, NSError error)
64
68
}
65
69
66
70
was . Start ( ) ;
67
- return await tcsResponse . Task ;
71
+ var result = await tcsResponse . Task ;
72
+ was ? . Dispose ( ) ;
73
+ was = null ;
74
+ return result ;
68
75
}
69
76
70
77
if ( UIDevice . CurrentDevice . CheckSystemVersion ( 11 , 0 ) )
71
78
{
72
- var sf = new SFAuthenticationSession ( new NSUrl ( url . OriginalString ) , scheme , AuthSessionCallback ) ;
79
+ sf = new SFAuthenticationSession ( new NSUrl ( url . OriginalString ) , scheme , AuthSessionCallback ) ;
73
80
sf . Start ( ) ;
74
- return await tcsResponse . Task ;
81
+ var result = await tcsResponse . Task ;
82
+ sf ? . Dispose ( ) ;
83
+ sf = null ;
84
+ return result ;
75
85
}
76
86
77
87
// THis is only on iOS9+ but we only support 10+ in Essentials anyway
0 commit comments