[SOLVED] Unable to connect in Metamask Mobile iOS and Android

Using vanilla Javascript to authenticate with wallet.

What’s working:

  • Metamask PC
  • TrustWallet Android
  • QR code scan through other browsers

But when I try to connect the wallet by directly opening the site in MetaMask mobile (both iOS and Android), it does not work.

Android Metamask: Clicking on “Connect” tab does nothing.
iOS Metamask: Prompts to App Store to download Metamask.

Site is hosted here: https://minisatoshidev.herokuapp.com

Could you please check and let me know? Thank you!

1 Like

can you add a console log in this code:

async function authenticate() {
 try {
  if (typeof web3 !== 'undefined') {
    const user = await Moralis.authenticate();
    web3 = await Moralis.enable();
} else {
  const user = await Moralis.authenticate({  provider: "walletconnect"});
  web3 = await Moralis.enable({  provider: "walletconnect" });
}
    walletAddress = user.get('ethAddress');
  } catch (error) {
    console.log('authenticate failed', error);
  }
  renderApp();
}

to know on what of those two branches will execute?

1 Like

thank you! It’s already there and on Metamask mobile walletconnect is executed.

I guess that if you are using metamask internal browser, then you don’t want wallet connect to be executed.

yeah exactly! why does that happen? trust wallet internal browser works well. Could you please help?

I guess that this if doesn’t work in that particular situation when using metamask internal browser

1 Like

sorry for late reply. i just put another else condition

window.ethereum

and that identifies web3 on MetaMask mobile

so everything works fine now?

1 Like

yeah everything is working good! But i have another question, it’s not directly related to coding .

Some of the wallets cannot see their balance and NFTs which they hold. Of course, they are able to log in but the backend does not return balance and NFTs. But let’s say if I ask them to create a new wallet and use MetaMask or TW to check again, IT WORKS.

How is that possible? Could it be a problem with the Smart Chain that is restricting some wallet address?

you can create a separate forum thread for this problem, I don’t completely understand what you want to say

1 Like

no problem. will do if required. I will try to solve by myself first.

Hi @minisatoshi,
I am trying to implement the logic in the same way.
My implementation works well if I try in a Computer but it does not work when I try to use it from mobile using the metamask Dapp browser.
For some reason the send transaction button does’t recognize anything.
I am using pure javascript and html as well.
Can you put the code that you used here please?
any help will be appreciated.
TIA

You can make a new topic with more details like your code, which versions of Moralis you’re using, etc.