简体   繁体   English

Metamask 移动浏览器未在 android 中注入 window.ethereum

[英]Metamask mobile browser not injecting window.ethereum in android

I am running a simple code like below:我正在运行一个简单的代码,如下所示:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Hello Bulma!</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
</head>
<body>
<section class="section">
    <div class="container">
        <h1 class="title">
            Hello World
        </h1>
        <p class="subtitle">
            <button class="btn btn-warning text-white" type="button" onclick="metamask()">
                Invest
                Here &rarr;
            </button>
        </p>
    </div>
</section>
<script>
    async function metamask() {
        const {ethereum} = window;
        var metamask = Boolean(ethereum && ethereum.isMetaMask);
        alert(typeof window.ethereum);
    }
</script>
</body>
</html>

but I get但我明白了

typeof window.ethereum is undefined typeof window.ethereum 未定义

It works fine in desktop metamask and iphone metamask dAPP.它在桌面 metamask 和 iphone metamask dAPP 中运行良好。 Doesnot work only in android metamask.仅在 android 元掩码中不起作用。

On a mobile, you need to use WalletConnect protocol .在手机上,您需要使用WalletConnect 协议

On android, press and hold metamask icon, go to app information, memory, "force stop".在 android 上,按住 metamask 图标,go 到应用程序信息,memory,“强制停止”。 Try again.再试一次。 It worked for me after doing that.这样做后它对我有用。 Also, take advantage to allow access to "files, media and camera".此外,利用允许访问“文件、媒体和相机”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用新的 window.ethereum 提供程序从 Metamask 获取代币余额 - How to get token balance from Metamask using new window.ethereum provider MetaMask 不注入 window.ethereum: Uncaught (in promise) TypeError: Cannot read property 'request' of undefined - MetaMask does not inject window.ethereum: Uncaught (in promise) TypeError: Cannot read property 'request' of undefined 使用 window.ethereum 到达 Wei function - Getting toWei function using window.ethereum 为什么 window.ethereum 在以下代码中不起作用? - Why is window.ethereum not working in the following code? 收到警告将 window.web3 替换为 window.ethereum - Got a warning to replace window.web3 by window.ethereum 未在 android 的 Metamask 应用程序上检测到以太坊提供商 - Not detecting ethereum provider on Metamask App for android 在带有以太 JS 的 Next Js 中使用 window.ethereum 时出错 - getting error while using window.ethereum in Next Js with ether JS 无法在 metamask 移动浏览器中加载 dapp - Cant load dapp in metamask mobile browser 检测到非以太坊浏览器。 您应该考虑尝试 MetaMask - Non-Ethereum browser detected. You should consider trying MetaMask 使用 ReactJS 和 Javascript 中的 Metamask 连接用户以太坊帐户 - Connecting User Ethereum account with Metamask in ReactJS and Javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM