Skip to content

Commit 9838e62

Browse files
fix(ios): Ensure useSFSafariViewController: true correctly opens SFSafariViewController (#1257)
1 parent e6e4b17 commit 9838e62

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/platforms/native/bridge/NativeBridgeManager.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
NativeClearSessionOptions,
77
} from '../../../types';
88
import {
9+
SafariViewControllerPresentationStyle,
910
type LocalAuthenticationOptions,
1011
type NativeAuthorizeOptions,
1112
} from '../../../types/platform-specific';
@@ -71,16 +72,11 @@ export class NativeBridgeManager implements INativeBridge {
7172
parameters: WebAuthorizeParameters,
7273
options: NativeAuthorizeOptions
7374
): Promise<Credentials> {
74-
let presentationStyle: number | undefined;
75-
if (options.useSFSafariViewController === true) {
76-
// If just `true`, default to a safe style like `fullScreen` (value 1 from our enum)
77-
presentationStyle = 1;
78-
} else if (typeof options.useSFSafariViewController === 'object') {
79-
presentationStyle = options.useSFSafariViewController.presentationStyle;
80-
} else {
81-
// If false or undefined, pass undefined to the native layer.
82-
presentationStyle = undefined;
83-
}
75+
let presentationStyle = options.useSFSafariViewController
76+
? (options.useSFSafariViewController as { presentationStyle: number })
77+
?.presentationStyle ??
78+
SafariViewControllerPresentationStyle.fullScreen
79+
: undefined;
8480
const scheme =
8581
parameters.redirectUrl?.split('://')[0] ?? options.customScheme;
8682
const credential = await this.a0_call(
@@ -97,7 +93,8 @@ export class NativeBridgeManager implements INativeBridge {
9793
parameters.invitationUrl,
9894
options.leeway ?? 0,
9995
options.ephemeralSession ?? false,
100-
presentationStyle,
96+
presentationStyle ?? 99, // Since we can't pass null to the native layer, and we need a value to represent this parameter is not set, we are using 99.
97+
// //The native layer will check for this and ignore if the value is 99
10198
parameters.additionalParameters ?? {}
10299
);
103100
return new CredentialsModel(credential);

src/platforms/native/bridge/__tests__/NativeBridgeManager.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe('NativeBridgeManager', () => {
9999
undefined, // invitationUrl
100100
0, // leeway
101101
false, // ephemeralSession
102-
undefined, // presentationStyle
102+
99, // presentationStyle
103103
{} // additionalParameters
104104
);
105105
});

0 commit comments

Comments
 (0)