Skip to content

Commit

Permalink
Merge pull request #1955 from Web3Auth/feat/native-apps-redirect
Browse files Browse the repository at this point in the history
redirect wc apps to native apps
  • Loading branch information
chaitanyapotti authored Sep 20, 2024
2 parents a9ebd68 + f6eea33 commit dda0f94
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 62 deletions.
124 changes: 62 additions & 62 deletions demo/vue-app-new/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@ async function getLastActiveSession(signClient: ISignClient): Promise<SessionTyp
return null;
}

function isMobileDevice() {
return /Mobi|Android|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i.test(window.navigator.userAgent);
}

export async function sendJrpcRequest<T, U>(signClient: ISignClient, chainId: number, method: string, params: U): Promise<T> {
const session = await getLastActiveSession(signClient);
if (!session) {
throw providerErrors.disconnected();
}

if (typeof window !== "undefined" && isMobileDevice()) {
if (session.peer.metadata.redirect && session.peer.metadata.redirect.native) {
window.open(session.peer.metadata.redirect.native, "_blank");
}
}

return signClient.request<T>({
topic: session.topic,
chainId: `eip155:${chainId}`,
Expand Down

0 comments on commit dda0f94

Please sign in to comment.