Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] WalletConnect deeplink breaks in Android WebView "wc:3cc..." should be "wc://3cc..." #414

Open
skhetcho opened this issue Jul 30, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@skhetcho
Copy link

skhetcho commented Jul 30, 2024

Describe the bug

Deep linking to external wallets (like WalletConnect wc:3cc.... urls) does not seem to work on Android when loaded inside an app. The app crashes with ERR_UNKOWN_URL_SCHEME

To reproduce

A way to produce opening a ConnectKit inside a webview in an android app could be done by creating a Telegram Mini App which creates a webview instance of the webapp inside the Android App.

1- Create a demo webapp using the Get Started guide.
2- Host an https instance of the webapp, (you could use nextjs with vercel)
3- Create a mini app on telegram and supply it with your https url to your webapp
4- Launch the mini app and press on connect wallet.
5- Select Metamask, and it will break.

Expected behavior
It should trigger "wc://3cc..." and not "wc:3cc..." - It seems this is only necessary for Android as the wallet connection works seamlessly on the browser, IOS, and desktop.

Screenshots
photo_2024-07-29_17-25-05

If applicable, add screenshots to help explain your problem.

Environment details

Android WebView (irrespective of the android version)

Additional context
none

@skhetcho skhetcho added the bug Something isn't working label Jul 30, 2024
@skhetcho skhetcho changed the title [BUG] WalletConnect deeplink breaks on Android "wc:3cc..." should be "wc://3cc..." [BUG] WalletConnect deeplink breaks in Android WebView "wc:3cc..." should be "wc://3cc..." Jul 30, 2024
@skhetcho
Copy link
Author

skhetcho commented Jul 30, 2024

I rewrote it from "wc:3cc..." to "wc://3cc..." this still didn't trigger the WebView in Android to open metamask wallet
this is in packages\connectkit\src\components\Common\ConnectorList\index.tsx

if (deeplink && deeplink.startsWith('wc:')) {
    deeplink = deeplink.replace('wc:', 'wc://');
  }
  console.log('deeplink', deeplink);
  return (
    <ConnectorButton
      type="button"
      as={deeplink ? 'a' : undefined}
      href={deeplink ? deeplink : undefined}
      disabled={context.route !== routes.CONNECTORS}
      onClick={
        deeplink
          ? undefined
          : () => {
            if (redirectToMoreWallets) {
              context.setRoute(routes.MOBILECONNECTORS);
            } else {
              if (shouldConnectImmediately) {
                connect({ connector: wallet?.connector });
              }
              context.setRoute(routes.CONNECT);
              context.setConnector({ id: wallet.id });
            }
          }
      }
    >
    ....

@lochie
Copy link
Member

lochie commented Aug 1, 2024

I rewrote it from "wc:3cc..." to "wc://3cc..." this still didn't trigger the WebView in Android to open metamask wallet

@skhetcho thanks for doing all of this research into this problem!

just checking, it sounds like there is no resolve in this PR as the issue still persists even with this change in place?

@skhetcho
Copy link
Author

skhetcho commented Aug 1, 2024

@lochie I just noticed it breaking on a different android phone V-14 Kernel 5.10.198-android12-9-28575147 while working on V-14 Kernel 5.4.254-qgbi-28582291. I am not sure if this matters though. I continue to investigate this issue. The most important line is in 4b0d0be is the addition of line 117

@skhetcho
Copy link
Author

skhetcho commented Aug 1, 2024

I also noticed that I didn't add a fix for wallets inside the "Other" menu

@skhetcho
Copy link
Author

skhetcho commented Aug 1, 2024

found the fix! it shouldn't be browserDetect() === 'chromium-webview`, this condition should be isAndroid() ? then the target should be '_blank'

pr is coming your way. I tested this on multiple android devices

@vimtor
Copy link

vimtor commented Aug 27, 2024

Hey @skhetcho, we've been considering migrating from RainbowKit because of this and other problems.

We currently have a Telegram Web app with ~100k users. Let me know if we can help you solve/test this issue.

@skhetcho
Copy link
Author

@vimtor That's awesome to see the ecosystem helping each other!
The CTO of WalletConnect commented on my X thread regarding it being a deprecated version of WalletConnect that's being used. tbh I'm not sure if that's the issue, I was able to get around it but my pr solution is quirky

@harissatti
Copy link

why are they closing the issue if they didn't find the solution ,still having the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants