[英]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 →
</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.