diff --git a/app/constants/deeplinks.ts b/app/constants/deeplinks.ts index 439416c211b8..581fefe632b4 100644 --- a/app/constants/deeplinks.ts +++ b/app/constants/deeplinks.ts @@ -26,6 +26,7 @@ export enum ACTIONS { BUY_CRYPTO = 'buy-crypto', SELL = 'sell', SELL_CRYPTO = 'sell-crypto', + HOME = 'home', EMPTY = '', } @@ -43,5 +44,6 @@ export const PREFIXES = { [ACTIONS.SELL]: '', [ACTIONS.BUY_CRYPTO]: '', [ACTIONS.SELL_CRYPTO]: '', + [ACTIONS.HOME]: '', METAMASK: 'metamask://', }; diff --git a/app/core/AppConstants.ts b/app/core/AppConstants.ts index 4fddd8f3cd85..14274a902087 100644 --- a/app/core/AppConstants.ts +++ b/app/core/AppConstants.ts @@ -44,6 +44,7 @@ export default { }, }, MM_UNIVERSAL_LINK_HOST: 'metamask.app.link', + MM_IO_UNIVERSAL_LINK_HOST: 'link.metamask.io', MM_DEEP_ITMS_APP_LINK: 'https://metamask.app.link/skAH3BaF99', SAI_ADDRESS: '0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359', HOMEPAGE_URL: 'https://portfolio.metamask.io/explore?MetaMaskEntry=mobile/', diff --git a/app/core/DeeplinkManager/DeeplinkManager.ts b/app/core/DeeplinkManager/DeeplinkManager.ts index 114d1a60a669..f6024d4e8733 100644 --- a/app/core/DeeplinkManager/DeeplinkManager.ts +++ b/app/core/DeeplinkManager/DeeplinkManager.ts @@ -10,6 +10,7 @@ import switchNetwork from './Handlers/switchNetwork'; import parseDeeplink from './ParseManager/parseDeeplink'; import approveTransaction from './TransactionManager/approveTransaction'; import { RampType } from '../../reducers/fiatOrders/types'; +import Routes from '../../constants/navigation/Routes'; class DeeplinkManager { public navigation: NavigationProp; @@ -87,6 +88,10 @@ class DeeplinkManager { rampType: RampType.SELL, }); } + // FRANK: *Step 7: open the home screen + _handleOpenHome() { + this.navigation.navigate(Routes.WALLET.HOME); + } parse( url: string, diff --git a/app/core/DeeplinkManager/ParseManager/handleUniversalLink.ts b/app/core/DeeplinkManager/ParseManager/handleUniversalLink.ts index 4ac42b61e7cf..0584fa580e18 100644 --- a/app/core/DeeplinkManager/ParseManager/handleUniversalLink.ts +++ b/app/core/DeeplinkManager/ParseManager/handleUniversalLink.ts @@ -30,16 +30,21 @@ function handleUniversalLink({ wcURL: string; url: string; }) { - const { MM_UNIVERSAL_LINK_HOST, MM_DEEP_ITMS_APP_LINK } = AppConstants; + const { MM_UNIVERSAL_LINK_HOST, MM_DEEP_ITMS_APP_LINK, MM_IO_UNIVERSAL_LINK_HOST } = AppConstants; const DEEP_LINK_BASE = `${PROTOCOLS.HTTPS}://${MM_UNIVERSAL_LINK_HOST}`; // Universal links handled(); - if (urlObj.hostname === MM_UNIVERSAL_LINK_HOST) { - // action is the first part of the pathname - const action: ACTIONS = urlObj.pathname.split('/')[1] as ACTIONS; + // action is the first part of the pathname + const action: ACTIONS = urlObj.pathname.split('/')[1] as ACTIONS; + if (urlObj.hostname === MM_UNIVERSAL_LINK_HOST) { // FRANK: *Step 5: deeplinks are currently caught here + // Placeholder for testing new actions navigation for new subdomain + if (action === ACTIONS.HOME) { + instance._handleOpenHome(); + return; + } if (action === ACTIONS.ANDROID_SDK) { DevLogger.log( `DeeplinkManager:: metamask launched via android sdk universal link`, @@ -145,6 +150,22 @@ function handleUniversalLink({ // Normal links (same as dapp) instance._handleBrowserUrl(urlObj.href, browserCallBack); } + } else if (urlObj.hostname === MM_IO_UNIVERSAL_LINK_HOST) { + // FRANK: *Step 6: branch off here for new subdomain + // The new actions will be handled when there is a new subdomain + if (action === ACTIONS.HOME) { + instance._handleOpenHome(); + } else if (action === ACTIONS.BUY || action === ACTIONS.BUY_CRYPTO) { + const rampPath = urlObj.href + .replace(`${DEEP_LINK_BASE}/${ACTIONS.BUY_CRYPTO}`, '') + .replace(`${DEEP_LINK_BASE}/${ACTIONS.BUY}`, ''); + instance._handleBuyCrypto(rampPath); + } else if (action === ACTIONS.SWAP) { + instance._handleOpenSwap(); + } else { + // Default to home if no action specified + instance._handleOpenHome(); + } } else { // Normal links (same as dapp) instance._handleBrowserUrl(urlObj.href, browserCallBack);