Window.ethereum works in Desktop chrome and not in mobile and trustwallet

Viewed 2264

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.

0 Answers
Related