File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed
legacy_packages/react/src Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @thirdweb-dev/react " : patch
3
+ ---
4
+
5
+ Fix window popup blocked for social login in iOS Safari when using ` useEmbeddedWallet ` hook
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
15
15
} from "@thirdweb-dev/wallets" ;
16
16
import { useCallback } from "react" ;
17
17
import { embeddedWallet } from "../../../wallet/wallets/embeddedWallet/embeddedWallet" ;
18
+ import { openOauthSignInWindow } from "../../../wallet/utils/openOauthSignInWindow" ;
18
19
19
20
/**
20
21
* Hook to connect `EmbeddedWallet` which allows users to login via Email or social logins
@@ -130,6 +131,18 @@ export function useEmbeddedWallet() {
130
131
}
131
132
const wallet = create ( embeddedWallet ( ) ) ;
132
133
try {
134
+ // open window immediately to fix issue in iOS Safari
135
+ // if not opened immediately, it adds a bit of delay between user click and opening the window which causes the popup to be blocked
136
+ if (
137
+ authParams . strategy === "apple" ||
138
+ authParams . strategy === "facebook" ||
139
+ authParams . strategy === "google"
140
+ ) {
141
+ const win = openOauthSignInWindow ( authParams . strategy ) ;
142
+ if ( win ) {
143
+ authParams . openedWindow = win ;
144
+ }
145
+ }
133
146
const authResult = await wallet . authenticate ( authParams ) ;
134
147
await wallet . connect ( { authResult } ) ;
135
148
setWallet ( wallet ) ;
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ function getWidthAndHeight(authOption: EmbeddedWalletOauthStrategy) {
23
23
24
24
export function openOauthSignInWindow (
25
25
authOption : EmbeddedWalletOauthStrategy ,
26
- themeObj : Theme ,
26
+ themeObj ? : Theme ,
27
27
) {
28
28
// open the popup in the center of the screen
29
29
const { height, width } = getWidthAndHeight ( authOption ) ;
@@ -39,8 +39,8 @@ export function openOauthSignInWindow(
39
39
const title = getBodyTitle ( authOption ) ;
40
40
win . document . title = title ;
41
41
win . document . body . innerHTML = spinnerWindowHtml ;
42
- win . document . body . style . background = themeObj . colors . modalBg ;
43
- win . document . body . style . color = themeObj . colors . accentText ;
42
+ win . document . body . style . background = themeObj ? .colors . modalBg || "black" ;
43
+ win . document . body . style . color = themeObj ? .colors . accentText || "white" ;
44
44
}
45
45
46
46
// close it when current window is closed or refreshed
You can’t perform that action at this time.
0 commit comments