fix: use deeplink instead of universal link (#7017)

* fix: use deeplink instead of universal link

* docs: added comment
This commit is contained in:
cartcrom 2023-07-28 10:58:01 -04:00 committed by GitHub
parent 6a3abbfb56
commit 1fde2504b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

@ -13,6 +13,7 @@ import { QRCodeSVG } from 'qrcode.react'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import styled, { useTheme } from 'styled-components/macro' import styled, { useTheme } from 'styled-components/macro'
import { CloseIcon, ThemedText } from 'theme' import { CloseIcon, ThemedText } from 'theme'
import { isIOS } from 'utils/userAgent'
import uniPng from '../../assets/images/uniwallet_modal_icon.png' import uniPng from '../../assets/images/uniwallet_modal_icon.png'
import { DownloadButton } from './DownloadButton' import { DownloadButton } from './DownloadButton'
@ -41,8 +42,9 @@ export default function UniwalletModal() {
const { activationState, cancelActivation } = useActivationState() const { activationState, cancelActivation } = useActivationState()
const [uri, setUri] = useState<string>() const [uri, setUri] = useState<string>()
// Displays the modal if a Uniswap Wallet Connection is pending & qrcode URI is available // Displays the modal if not on iOS, a Uniswap Wallet Connection is pending, & qrcode URI is available
const open = const open =
!isIOS &&
activationState.status === ActivationStatus.PENDING && activationState.status === ActivationStatus.PENDING &&
activationState.connection.type === ConnectionType.UNISWAP_WALLET_V2 && activationState.connection.type === ConnectionType.UNISWAP_WALLET_V2 &&
!!uri !!uri

@ -83,10 +83,9 @@ export class UniwalletConnect extends WalletConnectV2 {
// Opens deeplink to Uniswap Wallet if on iOS // Opens deeplink to Uniswap Wallet if on iOS
if (isIOS) { if (isIOS) {
const newTab = window.open(`https://uniswap.org/app/wc?uri=${encodeURIComponent(uri)}`) // Using window.location.href to open the deep link ensures smooth navigation and leverages OS handling for installed apps,
// avoiding potential popup blockers or inconsistent behavior associated with window.open
// Fixes blank tab opening on mobile Chrome window.location.href = `uniswap://wc?uri=${encodeURIComponent(uri)}`
newTab?.close()
} }
}) })
} }