MetaMask / metamask-mobile

Mobile web browser providing access to websites that use the Ethereum blockchain
https://metamask.io
Other
2.04k stars 1.06k forks source link

Trouble with deep links #1596

Open Gropher opened 4 years ago

Gropher commented 4 years ago

Describe the bug I'm trying to use deep link to get the result of transaction back into my native Android app but it doesn't work. I'm getting ERR_UNKNOWN_URL_SCHEME error after redirect to my app link: jjoapp://open?click_id=123456

Screenshots https://ibb.co/Bq5WRhY

To Reproduce Redirect to any deep link in Metamask browser

Expected behavior After redirect to deep link Metamask opens the app in question

Smartphone (please complete the following information):


to be added after bug submission by internal support / PM Severity

omnat commented 4 years ago

Hi @Gropher, I can't reproduce this issue with MetaMask deeplinks.

Can you give more context into what you are trying to achieve?

  1. Are you creating a deep link transaction from within another app, and then have their users redirected back to that app?
  2. Which deeplink are you using?
  3. Do you support Wallet Connect?
Gropher commented 4 years ago
  1. Our android app passes method and params for ethereum.sendAsync to the backend and get metamask deep link like this: https://metamask.app.link/dapp/jjo.dev1.idfly.ru/api/v2/metamask/c4a9a8c5-c3c9-4937-9ef4-30735f115423
  2. Then the app redirects user to this link, metamask opens, ethereum.sendAsync being executed with requested params
  3. Then we need to pass the result of ethereum.sendAsync call back into the app, so we use https://branch.io to create deep link into our app with result encoded in it: jjoapp://open?click_id=123456

This whole procedure works fine on iOS but on Android we getting ERR_UNKNOWN_URL_SCHEME error on final step

And no we do not use Wallet Connect

RoyalSix commented 2 years ago

@Gropher You are saying you were able to open another app from within the MetaMask Browser? How did you achieve this? I am trying to use deep linking but its not working for me.

For example after the user is finished interacting on MetaMask and its time for them to go back to "MyApp" I do

window.location.href = "myapp://user?id=12345"

but nothing happens. Are you able to expand more on this? Or do can you explain your implementation using branch.io

Thank you!

Thaina commented 2 years ago

I too have a problem open firebase dynamic link or any deep link in metamask

image

Even the firebase dynamic link actually redirect to intent:// url scheme so it become broken when metamask cannot handle it. This very much decrease metamask app usability for other dapp

I think the solution is that metamask should at least open any error link in the external browser, or relegate them to native OS to handle instead of this useless ERR_UNKNOWN_URL_SCHEME message

And there was a fix at least for intent:// schema that firebase was used with originWhitelist attribute and onShouldStartLoadWithRequest event

source : https://stackoverflow.com/a/60883730/1513380

I suspect that the origin of this problem are around here

https://github.com/MetaMask/metamask-mobile/blob/375f742331b66f008b74b0436230e16b7ff1a1df/app/components/Views/BrowserTab/index.js#L1554-L1576

and here

https://github.com/MetaMask/metamask-mobile/blob/375f742331b66f008b74b0436230e16b7ff1a1df/app/components/Views/BrowserTab/index.js#L904-L915

So I would like to suggest

    const onShouldStartLoadWithRequest = ({ url }) => {
        if (isENSUrl(url)) {
            go(url.replace(/^http:\/\//, 'https://'));
            return false;
        }

        if (!url || url.startsWith("http:") || url.startsWith("https:")) {
            return true;
        }

        // open natively
        Linking.openURL(request.url).catch(er => { console.log('Failed to open Link:', er.message); });
        return false;
    };

Is it possible?

Thaina commented 2 years ago

Further investigation seem to be the reactnative itself not handle the intent:// url scheme

https://github.com/facebook/react-native/pull/31836

So we could try to make the reactnative team to fix this then wait metamask to rebuild a new version. Or metamask might try to handle intent: scheme with the intent URL parser in the mean time ?

Thaina commented 2 years ago

Another thing I would like to be considered

Given that firebase dynamic link, $projectname$.page.link, has this domain pattern and normal browser could handle this link. Maybe it would be better to detect .page.link/ in url and use Linking.openURL for this domain (with onShouldStartLoadWithRequest ?)

Alternatively, maybe could you have some way to expose Linking.openURL in webview?

Such as allow postMessage({ "action" : "openURL", "url" : "customscheme://custompath" }) or something like this to be call in webview ?

csalmeida commented 2 years ago

Hello all, I'm facing a similar issue with deep links on a React Native application (v0.64.0), currently only tested on iOS.

Trying to open a page to connect a wallet and navigate back to the app with a few details passed via a deep link URL something like app://connect/detailshere or https://app.com/connect/detailshere.

These deep links do work on a browser like Safari, the prompt to open them in the app shows up but not within the MetaMask browser.

Is this simply not possible for now or are we missing something? Any thoughts on how to go about this would be deeply appreciated. 🙏

AlexJupiter commented 2 years ago

This seems like a natural user journey that we should try and support.

Thaina commented 2 years ago

Are there any progress on this?

lixin9311 commented 2 years ago

It might be related to Universal Link handling if you are on iOS. It is said, a Universal Link can only be activated by user interaction. Perhaps your codes are like

setTimeout( () => { window.location.href = "https://yourapp.page.link/hook"; }, 1000);

Somehow, it will redirect the user to App store even with the App installed.

But after I changed it to

someBtn.onclick = () => { window.location.href = "https://yourapp.page.link/hook"; };

It works just fine.

Did anyone know how to programmatically navigate users back to our Apps?

Dipankershah commented 1 year ago

Is that issue fixed? I'm getting the same problem. I cannot redirect from metamask browser to my app by gaggle://home link

omnat commented 1 year ago

@andreahaku @ezgi-cengiz there may be some limitations in scalability on supporting link back to dapps, but I'd defer to your judgment on how we can support this issue.

AlexHerman1 commented 1 year ago

@gantunesr we have users reporting this error when attempting to list NFT's on opensea.

ZD 931973 and 933120

vildantursic commented 1 year ago

Hi everyone, I've been searching for solution where I would be able to redirect user back to browser app after he connects his wallet. I don't know if that would be possible, since WalletConnect had to implement whole bunch of stuff to make it work.

My idea was to use deep link in format https://metamask.app.link/dapp/myapp.com&redirect=true&function=auth or in case of message signature https://metamask.app.link/dapp/myapp.com&redirect=true&function=signMessage

Where after the function is done user would be redirected /dapp/ URL which is defined in deeplink.

Any ideas, maybe temporary solutions are welcome 😁

Thaina commented 1 year ago

Nearly 3 years passed and this bug still persist

christopherferreira9 commented 9 months ago

Hi all! Is this issue still applicable?

github-actions[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions.

Thaina commented 6 months ago

So metamask not in development anymore?

github-actions[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions.

Thaina commented 3 months ago

So would it be fix or will be closed?

github-actions[bot] commented 4 weeks ago

This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions.

Thaina commented 3 weeks ago

Is this problem still not being solved?

omnat commented 3 weeks ago

cc @andreahaku @adamceresko