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

(iOS) (UX) Allow Dapps to open deep+universal links from MetaMask browser (twitter:// works - other custom schemes do not) #4213

Open hunterh37 opened 2 years ago

hunterh37 commented 2 years ago

Describe the bug

When using the MetaMask browser and interacting with a dapp, we are not able to use deep links such as (dog://, horse://, google://) to open our app after we are done in MetaMask.

I am not sure if this is intended due to security concerns, or if there is a workaround we can implement in the way the dapps open deep links.

I have tried using several different URL presentation methods - but it seems to be only working with whitelisted deep links, such as (twitter://, google://, facebook://)

To Reproduce Steps to reproduce the behavior

  1. Open your favorite web3 website/app/dapp on mobile device
  2. Click connect wallet
  3. URL Deeplink will open Dapp MetaMask browser
  4. Sign transaction, etc
  5. Now we are done with MetaMask, but no way for developers to send us back to another app

Expected behavior

Now I'll explain it in the context of my iOS app.

  1. Open my iOS app to create a new account
  2. Login screen allows user to create / register with MetaMask
  3. MetaMask button deeplinks into metamask browser to load our dapp url
  4. Connect wallet, sign transaction
  5. Our back-end handles signature validation + creates new account if successful
  6. Now the user is done with MetaMask. We need to deep link back into our app to pass the new user session code to allow user to automatically log in to our app
  7. Using a button or automatically redirecting to our deep link (foo://sessionToken?=XXXX) DOES NOT WORK. But if I replace our custom URL scheme with twitter:// it works!

Initially, I thought this was an issue with the way I push the deep link. However, when replacing our custom URL scheme with URL schemes from bigger companies that seem to be whitelisted by Apple, it works easily.

Smartphone (please complete the following information):


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

hunterh37 commented 2 years ago

Does any one have a working javascript implementation that allows us to successfully link out of MetaMask, and back to our iOS app? It appears the Android MetaMask browser does not have this issue.

<a href=, and window.location =

both not working for deep linking out of MetaMask

UnfortuN8 commented 2 years ago

Dealing with this issue as well and haven't found any workarounds.

gantunesr commented 2 years ago

Hey @hunterh37, for now we recommend using universal links. We'll provide a better solution in the near future.

Kiruel commented 1 year ago

Do you have any flow/example to show for this @gantunesr ? Have you find another solution @hunterh37 ?