Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deeplink not opening the browser of metamask #3855

Closed
QiteBlock opened this issue Mar 4, 2022 · 28 comments · Fixed by #3971
Closed

Deeplink not opening the browser of metamask #3855

QiteBlock opened this issue Mar 4, 2022 · 28 comments · Fixed by #3971
Labels
type-bug Something isn't working

Comments

@QiteBlock
Copy link

Describe the bug
I'm trying to open metamask with the deep link https://metamask.app.link/dapp.
I tried it on two different phones, in one it open the browser in Metamask App, and all is working well. But on another phone, it opened metamask app but it did not trigger the browser, nothing happened.

Screenshots
Here is two videos where we can see that in one phone all is working well and in another, it's not working.

This one is working
https://github.com/Qiweih/twino/blob/master/testmetamask.mp4
This one is not working
https://github.com/Qiweih/twino/blob/master/MetaMask%20(2).mp4

Smartphone (please complete the following information):

  • OS: [Android 12]
  • App Version [4.1.1] - find version number in app from Settings > About MetaMask
@QiteBlock QiteBlock added the type-bug Something isn't working label Mar 4, 2022
@andreahaku
Copy link
Member

Hi Qiweih,
starting from version 4.1.x you need to provide a url after /dapp/ to have the internal browser open a page.
Let me know if you still have problems with this.

@cmac2992
Copy link

cmac2992 commented Mar 7, 2022

I'm having this same issue on android. https://metamask.app.link/dapp/example.com or https://metamask.app.link/dapp/https://example.com just drops me into the wallet not into the browser. Works fine on ios/safari

smartphone

  • os: android 12
  • app: 4.1.1

@QiteBlock
Copy link
Author

QiteBlock commented Mar 8, 2022

@andreahaku Yes i have the /dapp/ , i still have the problem with this. Can you reopen the issue, as it's not resolved ?

@Programalyst
Copy link

Also having this issue. It was working for me in December but it's not working now. Tried generating the deep link again but it's the same and the metamask app browser doesn't open with the dapp URL.

@QiteBlock
Copy link
Author

I'll reopen another issue, we can't close an issue while nothing is solved

@andreahaku
Copy link
Member

Android

@andreahaku andreahaku reopened this Mar 8, 2022
@andreahaku
Copy link
Member

Hi,
Android 12 issues with deeplinks should be solved with the about to be released version 4.2.2.
Please test with this version and let me know if you still have issues with this.
Thanks

@QiteBlock
Copy link
Author

@andreahaku i tried the new version, still the same issue, when trying to open a deeplink, it opens the app but do not trigger the browser.

@QiteBlock
Copy link
Author

@andreahaku i tested several times, it works if i open the deeplink in an Application that i made, however it don't open it if i use a navigator like chrome or others.

@tejvirmann
Copy link

Hi everyone! Just wondering, was this issue fixed? Experiencing the same problem. Whenever I do:
https://metamask.app.link/dapp/example.com or (https://metamask.app.link/dapp/https://example.com) I am directed to the wallet, not the browser.

4.2.2 of metamask.
I have an iphone 12 pro with the latest update, using Xcode and Swift. Does it work on other devices?

@jacob-abe
Copy link

It doesnt make a difference if you add https://metamask.app.link/dapp/example.com or https://metamask.app.link/dapp/https://example.com as the code just replaces the https:// and http:// after /dapp.

@basememara
Copy link

It's really annoying.. however this seems like a platform issue. When I long-press the link in the mobile browser in iOS, one of the opens is to open MetaMask which does deep link into the in-app browser.

I'm not sure if MetaMask can do anything extra to make this without the long-press which would be ideal.

@liho00
Copy link

liho00 commented Apr 26, 2022

@cortisiko seem not fixed yet...quite a many comments specified not resolving...
this is the code that i used to trigger the deep link navigation.
Im using IOS 15.3.1

window.open(`https://metamask.app.link/dapp/${window.location.host}`)

@andreahaku Same not working with latest v5.0.1, here is the screen recording https://user-images.githubusercontent.com/77238199/165326244-c9471c12-f88b-4ff8-b207-80f410623c51.MOV

@andreahaku
Copy link
Member

So we have investigated the issue and unfortunately it does not depend on MetaMask mobile but on a mix of restrictions from mobile browsers and our deep link service provider.

The issue doesn't happen if the link is "tapped/clicked" by the user. It does happen with redirects and similar programmatic link openings.

So there are two potential workaround to it:

  1. make the link tappable by associating it to a button or something like that
  2. "simulate" a tap/click

About point 2 I just developed and tested a quick and simple JS function that does that.

function openMetaMaskUrl(url) {
    const a = document.createElement("a");
    a.href = url;
    a.target = "_self";
    document.body.appendChild(a);
    a.click();
    a.remove();
}

and it can be used like this:

openMetaMaskUrl("https://metamask.app.link/dapp/google.com");

This works on Android and iOS Chrome. On iOS Safari still opens the app store instead of MetaMask mobile app.

Let me know if this helps you. Thanks.

@jacob-abe
Copy link

This worked for me. Thanks

@liho00
Copy link

liho00 commented Apr 27, 2022

So we have investigated the issue and unfortunately it does not depend on MetaMask mobile but on a mix of restrictions from mobile browsers and our deep link service provider.

The issue doesn't happen if the link is "tapped/clicked" by the user. It does happen with redirects and similar programmatic link openings.

So there are two potential workaround to it:

  1. make the link tappable by associating it to a button or something like that
  2. "simulate" a tap/click

About point 2 I just developed and tested a quick and simple JS function that does that.

function openMetaMaskUrl(url) {
    const a = document.createElement("a");
    a.href = url;
    a.target = "_self";
    document.body.appendChild(a);
    a.click();
    a.remove();
}

and it can be used like this:

openMetaMaskUrl("https://metamask.app.link/dapp/google.com");

This works on Android and iOS Chrome. On iOS Safari still opens the app store instead of MetaMask mobile app.

Let me know if this helps you. Thanks.

@andreahaku I personally thinking most Iphone user will be using safari as primary browser (im one of it), as you said this problem still persist in IOS safari when open deeplink of the metamask, I am trying the find the solution on it, lets reopen the issue?

@andreahaku
Copy link
Member

andreahaku commented Apr 27, 2022

@andreahaku I personally thinking most Iphone user will be using safari as primary browser (im one of it), as you said this problem still persist in IOS safari when open deeplink of the metamask, I am trying the find the solution on it, lets reopen the issue?

@liho00 At the moment there isn't anything else that can be done other than using one of the two suggested workarounds.

I also developed another workaround that we are deciding if we want to integrate in the app or not. You can find it here.

@Spider149
Copy link

Spider149 commented May 27, 2022

I'm still facing this problem although I try both ways: window.location.replace or your openMetaMaskUrl
My metamask version is 5.1.1, Android 11.
It's open metamask and after that prompt a password form, after enter the password it's just open the wallet not browser.
Update:
Sometimes, It's work if I create a button for user to open that deep link, but most of the time it still not work.
Chrome mobile will block any programmatic way to open deep link.
image

@lepadatumihail
Copy link

It works for me if I do location.href= "the link you want to open"

@Spider149
Copy link

It works for me if I do location.href= "the link you want to open"

I tried your way but still the same result :(

@b-pmcg
Copy link

b-pmcg commented May 27, 2022

I'm having the same issue as @Spider149 with Android. None of the suggested solutions are working, the Metamask app opens, but it just shows the wallet page.
MM: 5.1.1
Android: 12

@spectrl
Copy link

spectrl commented Jun 9, 2022

Just want to add that none of the suggested approaches are working for me either. The behaviour I want is that MetaMask is opened with the browser open, and the URL I pass in is loaded.

Here's what I've tried and every time it just lands on the MetaMask home (wallet) screen:

  • https://metamask.app.link/dapp/opensea.io/assets/ethereum/0xa9074445881ffd9bd1096414149f0feb8147b4a9/4346
  • metamask://dapp/opensea.io/assets/ethereum/0xa9074445881ffd9bd1096414149f0feb8147b4a9/4346

I'm on Android 12 and using this Intent launching code:

val intent = Intent(Intent.ACTION_VIEW, uri)
            .addCategory(Intent.CATEGORY_BROWSABLE)
            .addFlags(
                Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_REQUIRE_NON_BROWSER
            )
startActivity(intent)

Hope this gets resolved soon! 🙏

@iners-max
Copy link

iners-max commented Jun 15, 2022

Still not working on iOS nor Android

Android Chrome, Android 12 (Samsung Note 10), with Metamask Mobile 5.2.0
iOS Safari, iOS 15.3.1, with Metamask Mobile 5.2.0

No matter https://metamask.app.link/dapp/ nor metamask://dapp/. It will eventually only open Metamask app's wallet page. They are not opening the dapp URLs in the in-app browsers.

@luoei
Copy link

luoei commented Jun 22, 2022

Still not working on iOS nor Android

Android Chrome, Android 12 (Samsung Note 10), with Metamask Mobile 5.2.0 iOS Safari, iOS 15.3.1, with Metamask Mobile 5.2.0

No matter https://metamask.app.link/dapp/ nor metamask://dapp/. It will eventually only open Metamask app's wallet page. They are not opening the dapp URLs in the in-app browsers.

Encountered the same problem, is there a solution?

@grantwwoodford
Copy link

This solution worked for me: #3965 (comment)

@mavcom12
Copy link

Is there a way where android will not have to change chooser settings?

@anila-mathew
Copy link

Did anyone find a solution to this issue??

@syahbes
Copy link

syahbes commented Jul 15, 2024

Did anyone find a solution to this issue??

yes!!
this post "https://dev.to/miki-digital/working-with-smart-contract-on-the-frontend-3mem"
help me undrestand that I need to add "\"
in the end of my 'metamaskAppDeepLink'
for exemple if my app link is 'https://syhabesapp.vercel.app'

the link to open is :
const metamaskAppDeepLink =
https://metamask.app.link/dapp/syahbesapp.vercel.app\\/

and than just 
  <a href={metamaskAppDeepLink}>
    <button className="btn">
      connect wallet
    </button>
  </a>
  
  that will open metamask browser on the link you provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.