Window.ethereum works in Desktop chrome and not in mobile and trustwallet
Asked Answered
G

0

6

I have my web3.js detector define as in function below:

const ethEnabled = () => {
    if (window.ethereum) {
      web3 = new Web3(window.ethereum)
      return true
    } else if (window.web3) {
      web3 = window.web3
      return true
    }
    return false
  }
  if (!ethEnabled()) {
    alert(
      'Please install an Ethereum-compatible browser or extension like MetaMask to use this dApp!'
    )
  }

The problem is that this works in Chrome and Brave browser on desktop but fails on mobile and trustwallet. So the alert message below is triggered.

Please let me know how I should go about this.

Thanks.

Grainfield answered 5/3, 2021 at 5:23 Comment(2)
My suggestion is to forget in-wallet dApp browsers and tell users to use a native mobile browser with WalletConnect mobile linking: docs.walletconnect.org/mobile-linking - embedded WebViews cause all sort of problems and make life of dApp developers painfulPatrilineal
Same issue! Did anyone figure out any work-around for this?Siriasis

© 2022 - 2024 — McMap. All rights reserved.