簡體   English   中英

Metamask 移動瀏覽器未在 android 中注入 window.ethereum

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

我正在運行一個簡單的代碼,如下所示:

<!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>

但我明白了

typeof window.ethereum 未定義

它在桌面 metamask 和 iphone metamask dAPP 中運行良好。 僅在 android 元掩碼中不起作用。

在手機上,您需要使用WalletConnect 協議

在 android 上,按住 metamask 圖標,go 到應用程序信息,memory,“強制停止”。 再試一次。 這樣做后它對我有用。 此外,利用允許訪問“文件、媒體和相機”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM