MetaMask / MetaMask/detect-provider
@metamask/detect-provider: Unable to detect window.ethereum.
- Dominant language
- JavaScript
- Stars
- 238
- Forks
- 63
- PR merge metrics
- No merged PRs in 30d
Description
I'm building a hybrid app using Ionic.
When I serve the app in the browser (Chrome), it works fine asking for the Metamask authentication (opens Metamask as expected).
However when I build that for native Android (I'm using Capacitor), even though the app opens on my Android phone normally after I launch it from Android Studio, it does not ask me to authenticate with Metamask.
After doing some troubleshoot I attached to the app (via Chrome Device Inspect) running on my real phone which is plugged via USB in my computer, and this is what I get on the native app:
```
common.js:166 @metamask/detect-provider: Unable to detect window.ethereum.
handleEthereum @ common.js:166
23:50:21.508 vendor.js:86490 ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of null (reading 'request')
TypeError: Cannot read properties of null (reading 'request')
at src_app_home_home_module_ts.js:272:22
at ZoneDelegate.invoke (polyfills.js:413:30)
at Object.onInvoke (vendor.js:108502:25)
at ZoneDelegate.invoke (polyfills.js:412:56)
at Zone.run (polyfills.js:173:47)
at polyfills.js:1331:38
at ZoneDelegate.invokeTask (polyfills.js:447:35)
at Object.onInvokeTask (vendor.js:108490:25)
at ZoneDelegate.invokeTask (polyfills.js:446:64)
at Zone.runTask (polyfills.js:218:51)
at resolvePromise (polyfills.js:1268:35)
at polyfills.js:1338:21
at ZoneDelegate.invokeTask (polyfills.js:447:35)
at Object.onInvokeTask (vendor.js:108490:25)
at ZoneDelegate.invokeTask (polyfills.js:446:64)
at Zone.runTask (polyfills.js:218:51)
at drainMicroTaskQueue (polyfills.js:633:39)
at ZoneTask.invokeTask (polyfills.js:533:25)
at ZoneTask.invoke (polyfills.js:518:52)
at data.args. (polyfills.js:3076:36)
```
What should I do in order to have the native app being able to authenticate with the Metamask installed app?
Thanks!
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with @metamask/detect-provider's window.ethereum detection and compare the browser environment with the Capacitor native Android WebView described in the report. Reproduce the null provider and determine whether this repository supports native-app provider detection; done should be a confirmed supported path or a clearly documented limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- authentication, mobile-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100