Skip to content

Commit 9a7d1ca

Browse files
committed
Consolidate prefersEphemeralSession availability check
1 parent feb55dc commit 9a7d1ca

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

Source/AppAuth/iOS/OIDAuthorizationService+IOS.m

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,38 @@ @implementation OIDAuthorizationService (IOS)
6060
+ (id<OIDExternalUserAgentSession>)presentAuthorizationRequest:(OIDAuthorizationRequest *)request
6161
callback:(OIDAuthorizationCallback)callback {
6262
return [self presentAuthorizationRequest:request
63-
prefersEphemeralSession:NO
63+
prefersEphemeralSessionIfAvailable:NO
6464
callback:callback];
6565
}
6666

6767
+ (id<OIDExternalUserAgentSession>)presentAuthorizationRequest:(OIDAuthorizationRequest *)request
6868
prefersEphemeralSession:(BOOL)prefersEphemeralSession
6969
callback:(OIDAuthorizationCallback)callback {
70+
return [self presentAuthorizationRequest:request
71+
prefersEphemeralSessionIfAvailable:prefersEphemeralSession
72+
callback:callback];
73+
}
74+
75+
+ (id<OIDExternalUserAgentSession>)presentAuthorizationRequest:(OIDAuthorizationRequest *)request
76+
prefersEphemeralSessionIfAvailable:(BOOL)prefersEphemeralSession
77+
callback:(OIDAuthorizationCallback)callback {
7078
id<OIDExternalUserAgent> externalUserAgent;
79+
80+
if (@available(iOS 13, *)) {
7181
#if TARGET_OS_MACCATALYST
72-
externalUserAgent = [[OIDExternalUserAgentCatalyst alloc]
73-
initWithPrefersEphemeralSession:prefersEphemeralSession];
82+
externalUserAgent = [[OIDExternalUserAgentCatalyst alloc]
83+
initWithPrefersEphemeralSession:prefersEphemeralSession];
84+
#else // TARGET_OS_MACCATALYST
85+
externalUserAgent = [[OIDExternalUserAgentIOS alloc]
86+
initWithPrefersEphemeralSession:prefersEphemeralSession];
87+
#endif // TARGET_OS_MACCATALYST
88+
} else {
89+
#if TARGET_OS_MACCATALYST
90+
externalUserAgent = [[OIDExternalUserAgentCatalyst alloc] init];
7491
#else // TARGET_OS_MACCATALYST
75-
externalUserAgent = [[OIDExternalUserAgentIOS alloc]
76-
initWithPrefersEphemeralSession:prefersEphemeralSession];
92+
externalUserAgent = [[OIDExternalUserAgentIOS alloc] init];
7793
#endif // TARGET_OS_MACCATALYST
94+
}
7895
return [self presentAuthorizationRequest:request
7996
externalUserAgent:externalUserAgent
8097
callback:callback];

0 commit comments

Comments
 (0)