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

WalletConnect - MetaMask redirects to the App Store before transaction can be authorised #3914

Closed
davidm03 opened this issue Mar 18, 2022 · 45 comments
Assignees
Labels
stale Issues that have not had activity in the last 90 days team-sdk SDK team type-bug Something isn't working WalletConnect WalletConnect related issue or bug

Comments

@davidm03
Copy link

davidm03 commented Mar 18, 2022

Describe the bug
When a user attempts to send a transaction from our dapp using WalletConnect and MetaMask - the MetaMask app will open, the transaction pop-up will appear with all the transaction details pre-filled from our dapp for a very brief period of time (maybe less than 1 second), then the MetaMask app will redirect/open the app store as if the user does not have MetaMask installed. If the user navigates back to the MetaMask app from the app store, the browser tab is open with the metamask.app.link url inserted but the user is not able to get the transaction pop-up to reappear and no response is sent back to our dapp ever.

To Reproduce
Difficult to reproduce without access to our dapp but I'll do my best to explain.

  1. From a React Native dapp which uses WalletConnect - connect to your MetaMask wallet via WalletConnect pop-up window.
  2. Once MetaMask wallet is successfully connected and you have been redirected back to your dapp - attempt to call the WalletConnect sendTransaction function (code will be included below) using the same data.
  3. MetaMask mobile app is re-opened, transaction pop-up is displayed briefly before the app will redirect the user to the app store - as if they did not ever have it installed.

The following code is being used to call the sendTransaction function via WalletConnect after a user has connected a MetaMask wallet.

const sendTransaction = async (): Promise<void> => {
    await connector
      .sendTransaction({
        from: connector.accounts[0],
        to: "0xb81c36B5BCdDB20BFECE8F355DC5B212565AF907",
        value: Web3.utils.toHex(0.01 * 1e18),
        type: "native",
      })
      .then((res) => {
        console.log("Transaction Hash => ", res);
      })
      .catch((e) => console.warn(e));
  };

Expected behavior
User is redirected to MetaMask to authorise the transaction, transaction pop-up is displayed to the user for authentication, app store should not open as the user already has the app installed, user is able to approve/reject the transaction and should the be redirected back to our dapp and response returned to WalletConnect sendTransaction function.

Smartphone (please complete the following information):

  • Device: iPhone XS
  • OS: iOS 15.4
  • App Version v4.2.2 (834)
@davidm03 davidm03 added the type-bug Something isn't working label Mar 18, 2022
@gantunesr gantunesr added the WalletConnect WalletConnect related issue or bug label Mar 18, 2022
@davidm03
Copy link
Author

Update:
The issue is only happening on iOS devices and appears to be caused by line 136 within the WalletConnectProvider.js file

const url = formatWalletServiceUrl(walletService);
return (await Linking.canOpenURL(url)) && Linking.openURL(url);

Linking.openURL(url) launches MetaMask via the metamask.app.link URL and triggers the in-app browser, which is then redirecting the user to the app store - even if they have the app installed.

We've came up with a workaround for this issue and deployed a patch to use the connected wallet deeplink to launch the wallet app instead of the wallet service URL previously being generated.

const url = formatWalletServiceUrl(walletService);
return (await Linking.canOpenURL(url)) && Linking.openURL(walletService.mobile.native);

This resolves the issue for now, MetaMask opens correctly without redirected to the app store and the transaction pop-up is displayed correctly.

@epshtielsl
Copy link

epshtielsl commented Mar 28, 2022

The universal URL should still open MetaMask without prompting the AppStore. Perhaps there is an issue with how they have configured the universal URL when opened with parameters (i.e. sending the sign personal message command via deep link).

Thanks for the quick fix info though. This could be a good alternative if the issue takes long to be resolved.

@andreahaku
Copy link
Member

Thanks @davidm03 and @epshtielsl. I'll test the fix and eventually integrate in the app. Thanks again.

@rafaelaugustos
Copy link

Any news about this problem?

@zosim
Copy link

zosim commented Apr 12, 2022

Any news about this problem?

yes also hoping for some news. Thanks.

@thiagofreirebr
Copy link

Me too.
Looks so easy to solve this. Why they're taking so long?

@joharzmn
Copy link

@davidm03 The fix you mentioned above, How can we use that fix when using walletconnect?? I can't find WalletConnectProvider.js in walletConnect.

@andreahaku
Copy link
Member

Did you try the latest version of the app (5.0.x) as most of the deep links related issue should be solved with it. Please let me know. Thanks!

@fablanglet
Copy link

I still have the issue on iOS. Metamask deep link doesn't work. It still going to App Store.

@andreahaku
Copy link
Member

I still have the issue on iOS. Metamask deep link doesn't work. It still going to App Store.

Did you check the solution suggested here?
#3965 (comment)

@davidm03
Copy link
Author

davidm03 commented May 3, 2022

@davidm03 The fix you mentioned above, How can we use that fix when using walletconnect?? I can't find WalletConnectProvider.js in walletConnect.

The file I mentioned can be found within node_modules > @WalletConnect > react-native-dapp > providers > WalletConnectProvider.js

We used the patch package library to create a patch to apply this fix on every npm install and ensure it's not overridden.

@y0unghe
Copy link

y0unghe commented May 5, 2022

I still have the issue on iOS. Metamask deep link doesn't work. It still going to App Store.

The same.

@anxolin
Copy link

anxolin commented May 5, 2022

@andreahaku i'm using 5.0.1 and still have the same issue in IOS Safari.

You can try it here https://cowswap.staging.gnosisdev.com (approving a token for example).

I use web3-react which delegates to @walletconnect/ethereum-provider . Any hint on how to debug/solve the issue?
We are not the ones creating the deep links, I assume Wallet Connect is.

@rafaelaugustos
Copy link

I have same problem in my React Native app, but it is not happen in all apps

@fopina
Copy link

fopina commented Jun 17, 2022

Not sure if related but https://metamask.app.link/dapp/Google.com from iOS safari opens App Store while clicking the same link in any “inapp browser” (like Telegram or WhatsApp) does work

@antinomy-studio
Copy link

Having the same issue on iOS. Wallet Connect opens the App Store even if MetaMask is installed + Wallet is setup.

@xaun
Copy link

xaun commented Jul 4, 2022

The solution for me was to ensure the web3 provider send request (RPC API) was the first network request after a user action.

I've deployed an example here forked from web3-react/example-next (v8) which consistently reproduces the issue when the checkbox is ticked on iOS by making a random async request first instead. Example diff here: xaun/web3-react@694f791

I'm guessing this is something to do with mobile devices blocking redirections (deeplinks/universal links/or what not) that are not detected as derived from a user action.. something along the lines maybe? I'de love to know exactly why this behaviour occurs, as it's been a bit of a journey to figure out this "gotcha".

@davidm03 what invokes your sendTransaction method? Is there any async behaviour before it?

@davidm03
Copy link
Author

davidm03 commented Jul 6, 2022

The solution for me was to ensure the web3 provider send request (RPC API) was the first network request after a user action.

I've deployed an example here forked from web3-react/example-next (v8) which consistently reproduces the issue when the checkbox is ticked on iOS by making a random async request first instead. Example diff here: xaun/web3-react@694f791

I'm guessing this is something to do with mobile devices blocking redirections (deeplinks/universal links/or what not) that are not detected as derived from a user action.. something along the lines maybe? I'de love to know exactly why this behaviour occurs, as it's been a bit of a journey to figure out this "gotcha".

@davidm03 what invokes your sendTransaction method? Is there any async behaviour before it?

@xaun Very interesting solution + theory, thanks for sharing. As for my sendTransaction method - there is no async behaviour before it and it is invoked directly from a simple button onPress (onPress={sendTransaction} ).

@LifeWithArt1
Copy link

Still happening for me...so frustrating.

@grp06
Copy link

grp06 commented Sep 12, 2022

Still an issue for me. I'm using Rainbow kit.

It also happens when you use Uniswap or AAVE and try to sign in with WalletConnect. Crazy it's still broken!

@xaun
Copy link

xaun commented Sep 14, 2022

Also don't updated your Metamask on iOS to the latest version that was released recently or it'll completely stop working. The code example I gave above doesn't work anymore, nor does connecting with well known sites like Uniswap (noting they're using the same underlying web3-react lib).

@niraj-khatiwada
Copy link

The solution for me was to ensure the web3 provider send request (RPC API) was the first network request after a user action.

I've deployed an example here forked from web3-react/example-next (v8) which consistently reproduces the issue when the checkbox is ticked on iOS by making a random async request first instead. Example diff here: xaun/web3-react@694f791

I'm guessing this is something to do with mobile devices blocking redirections (deeplinks/universal links/or what not) that are not detected as derived from a user action.. something along the lines maybe? I'de love to know exactly why this behaviour occurs, as it's been a bit of a journey to figure out this "gotcha".

@davidm03 what invokes your sendTransaction method? Is there any async behaviour before it?

For some reason this works for me for both spawnBug set or unset. But my app still redirects to appstore even when spawnBug is false. Any idea?

@Tdweller
Copy link

Tdweller commented Oct 1, 2022

This has frustrated me forever, but today I stumbled on a weird fix. I have no idea why it works, but it has for me every time.

When I initiate a transaction and am told to sign in my wallet, Im then automatically redirected to the App Store, to the MetaMask Page.

In the App Store, next to the MetaMask logo is a back arrow. (Not the one to go back to MetaMask, the one to go back to App Store home page) Tap dat.

Then, use the top left arrow to go back to MetaMask: for me, the place to sign is right there waiting.

Hope this works for others, I have no idea how or why it does for me.

@codeforreal1
Copy link

This has frustrated me forever, but today I stumbled on a weird fix. I have no idea why it works, but it has for me every time.

When I initiate a transaction and am told to sign in my wallet, Im then automatically redirected to the App Store, to the MetaMask Page.

In the App Store, next to the MetaMask logo is a back arrow. (Not the one to go back to MetaMask, the one to go back to App Store home page) Tap dat.

Then, use the top left arrow to go back to MetaMask: for me, the place to sign is right there waiting.

Hope this works for others, I have no idea how or why it does for me.

If the metamask is not in quit state, the transaction is already pending in metamask. Its just the redirection was gone to Appstore.

@sra-fiberswitch
Copy link

I had the same issue on my iPhone. Fixed it by long-pressing the MetaMask symbol when in the WalletConnect menu. You get a dropdown list whereafter you can select “Open with MetaMask”.

@andreahaku andreahaku self-assigned this Nov 8, 2022
@JstKuLam
Copy link

Having the same issue on iOS. The latest Metamask version. Wallet Connect opens the App Store even if MetaMask is installed. So frustrating

p/s: Other wallets worked fine (Coin98, Trust, GNosis...)

@SunnyCheung-cp
Copy link

Unfortunately, I also ran into this problem. Is there a solution now?

@andreahaku
Copy link
Member

We just release an update of the app (v5.12.0 and up) that should help fix this issue. It's rolling out now on Android and iOS. Please let me know if this solves or not. Thanks

@SunnyCheung-cp
Copy link

SunnyCheung-cp commented Dec 8, 2022

@andreahaku Thanks, I just tried it with v5.12.0, unfortunately the result didn't change
In addition, let me provide that the connection method I am currently using is walletconnect v2.0, don't know if this will make a difference

metamask-dome-video.mp4

@andreahaku
Copy link
Member

@SunnyCheung-cp we don't support WC v2.0 for now. We only support WC v1

@ZiggStardust
Copy link

ZiggStardust commented Feb 3, 2023

@andreahaku why won't you support WC v2 ? What is the reason behind this ? Metamask has a large market share of wallets out there and wallet connect provides a great UX experience for onboarding users....

Also which parts of the integration from a technical perspective is not supported ?

@GainsGoblin
Copy link

Bruh fix this already

@markoorn
Copy link

markoorn commented Mar 6, 2023

How is this still ongoing after a full year? Is there any working for browser apps similar to what @davidm03 did for the native dependency? I have a web app which is largely used on phones and am struggling to get a decent UX with walletconnect and MetaMask

@hinahoh0
Copy link

hinahoh0 commented Apr 4, 2023

it's like this issue comes up again after every upgrade. can't it be fixed once and for all?

@andreahaku
Copy link
Member

This has been tackled multiple times already but some still have this problem. What we've found for example is that this mainly happens on iOS. This may happen if you have a not "stable" (read beta or RC) version of iOS installed on your iOS device.

WC is aware of that and to finally fix this they are developing a new modal that uses deep links (so URL schemas like metamask:// and wc://) instead of Universal Links (https://metamask.app.link/) and we already have a PR (#6076) that should be out soon supporting this change.

Hopefully this should solve the unreliability of some WC connections using universal links.

@anxolin
Copy link

anxolin commented Apr 5, 2023

I agree, this is super annoying, we get complaints from time to time. I also experienced it many times, and I don't have a non stable IOS version

Awesome if this PR fixes it, it has been there for a while and I feel like especially WC is important for mobile devices, and IOS is nothing to leave behind.

Thanks in advance to the one tackling it, I hope the new solution works 🤞

@derrick-ag
Copy link

This issue happens(for me) after I was asked to redirect (open) MetaMask to sign a transaction and I clicked on cancel (because it was a mistake).. there after I got redirected to the AppStore and not the app. Same with other wallets.

@aktoriukas
Copy link

Is there any solution for this??
my issue is that - while trying to connect the wallet to the site it directs to the app store instead of the application.

the weird part about it is that on some phones ( IOS ) it does it correctly and on others, it does not.

@arbaz-meo
Copy link

arbaz-meo commented Aug 14, 2023

i m also facing one issue its exist on triggering the transaction not on connection when i connect wallet and use ### https://metamask.app.link/wc?uri=ecncode(wc) so its open wallet and pop up appear then redirect to the dapp .
now when i trgger the transaction i use ### https://metamask.app.link its take me to the wallet pop up appear for transaction but its not redirect me to the dapp

Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale Issues that have not had activity in the last 90 days label Nov 12, 2023
@HarlamovEvgeniy
Copy link

This problem is still relevant, we are waiting for fixes.

@github-actions github-actions bot removed the stale Issues that have not had activity in the last 90 days label Nov 17, 2023
@christopherferreira9
Copy link
Contributor

christopherferreira9 commented Dec 6, 2023

Hi all! We are trying to replicate this issue. Can you please clarify the following?

  • WalletConnect version you're using
  • Make sure you have the latest WC version on your dapp
  • MetaMask Wallet version you recently saw this happening
  • Has this issue been raised on the WalletConnect side?

Copy link
Contributor

github-actions bot commented Mar 5, 2024

This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale Issues that have not had activity in the last 90 days label Mar 5, 2024
Copy link
Contributor

This issue was closed because there has been no follow activity in 7 days. If you feel this was closed in error please provide evidence on the current production app in a new issue or comment in the existing issue to a maintainer. Thank you for your contributions.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
@22JH
Copy link

22JH commented Aug 15, 2024

The problem is still not resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issues that have not had activity in the last 90 days team-sdk SDK team type-bug Something isn't working WalletConnect WalletConnect related issue or bug
Projects
Archived in project
Development

No branches or pull requests