Trust Wallet via WalletConnect not connecting on mobile / iOS

Im having issues specifically with connecting to a Trust Wallet via WalletConnect on a mobile device (iPhone) from our Moralis dapp. The issue I am seeing after you choose Trust Wallet from the WalletConnect popup, it launches Trust Wallet app and says “WalletConnect - connecting may take a few seconds” at the bottom but after a while it quits and says “WalletConnect - failed to connect”. I have tried all the usual workarounds for this issue such as disconnecting from other dapps, restarting Trust Wallet app, rebooting entire device, trying multiple mobile browsers (Safari and Chrome) but they all result in the same error / it never connects.

I can confirm that the same process using WalletConnect to connect to MetaMask instead of Trust works fine on the same device / dapp. I can also confirm that when I use WalletConnect on other webapps such as Uniswap and Pancake swap it also connects ok to the Trust Wallet on the same device (most of the time).

The script import in the html is as follows:

<script src="https://github.com/WalletConnect/walletconnect-monorepo/releases/download/1.4.1/web3-provider.min.js"></script>

Does anyone have any advice or perhaps a link to a dapp made with Moralis that works on mobile iOS with WalletConnect / Trust Wallet that I could test? Trust Wallet support is a major requirement for our mobile dapp.

Any help would be appreciated!

Solved it! Was super simple. Looks like the older WalletConnect version in the script include 1.4.1 is no longer compatible with Trust Wallet. I changed it to link to the latest version 1.7.1 and it now works!

<script src="https://github.com/WalletConnect/walletconnect-monorepo/releases/download/1.7.1/web3-provider.min.js"></script>

I am using v1.7.1, when i connect via walletConnect everything is ok but when i back to browser it is on link.trustwallet.com address instead of my dApp. I am very confused!

Привет @mrminute ! Попробуй это:

 document.addEventListener('visibilitychange', () => {
    if (document.visibilityState === 'hidden') {
      window.localStorage.removeItem('WALLETCONNECT_DEEPLINK_CHOICE');
    }
  });

Thanks, but this will cause to every time user send a transaction he should manually switch to trust wallet. this is not fair!

1 Like

Hey! Yep, I agree.
If you find an alternative solution, please let us know!