Skip to content

Commit dda0f94

Browse files
Merge pull request #1955 from Web3Auth/feat/native-apps-redirect
redirect wc apps to native apps
2 parents a9ebd68 + f6eea33 commit dda0f94

File tree

2 files changed

+73
-62
lines changed

2 files changed

+73
-62
lines changed

demo/vue-app-new/package-lock.json

Lines changed: 62 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,22 @@ async function getLastActiveSession(signClient: ISignClient): Promise<SessionTyp
1212
return null;
1313
}
1414

15+
function isMobileDevice() {
16+
return /Mobi|Android|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i.test(window.navigator.userAgent);
17+
}
18+
1519
export async function sendJrpcRequest<T, U>(signClient: ISignClient, chainId: number, method: string, params: U): Promise<T> {
1620
const session = await getLastActiveSession(signClient);
1721
if (!session) {
1822
throw providerErrors.disconnected();
1923
}
24+
25+
if (typeof window !== "undefined" && isMobileDevice()) {
26+
if (session.peer.metadata.redirect && session.peer.metadata.redirect.native) {
27+
window.open(session.peer.metadata.redirect.native, "_blank");
28+
}
29+
}
30+
2031
return signClient.request<T>({
2132
topic: session.topic,
2233
chainId: `eip155:${chainId}`,

0 commit comments

Comments
 (0)