Skip to content

Commit c44e75a

Browse files
author
Aleksandar Cakalic
committed
refactor: trigger app deep link if user is on mobile devices
1 parent fecae28 commit c44e75a

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/connectors/argent/argentMobile/modal/argentModal.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { getDevice } from "./getDevice"
1+
import { getDevice } from "../../../../helpers/getDevice"
22
import Modal from "../../../../modal/Modal.svelte"
33
import { Layout, type ModalWallet } from "../../../../types/modal"
44
import { getModalTarget } from "../../../../helpers/modal"
5-
import { StarknetkitConnector } from "../../../connector"
5+
import type { StarknetkitConnector } from "../../../connector"
66

77
const device = getDevice()
88

@@ -56,8 +56,8 @@ class ArgentModal {
5656
this.showModal(
5757
{
5858
desktop: `${this.bridgeUrl}?wc=${wcParam}&href=${href}&device=desktop&onlyQR=true`,
59-
ios: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile`,
60-
android: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile`,
59+
ios: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile&onlyQR=true`,
60+
android: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile&onlyQR=true`,
6161
},
6262
modalWallet,
6363
)
@@ -69,15 +69,26 @@ class ArgentModal {
6969

7070
this.getQR({
7171
desktop: `${this.bridgeUrl}?wc=${wcParam}&href=${href}&device=desktop&onlyQR=true`,
72-
ios: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile`,
73-
android: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile`,
72+
ios: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile&onlyQR=true`,
73+
android: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile&onlyQR=true`,
7474
})
7575
}
7676

7777
private getQR(urls: Urls) {
7878
const overlay = document.createElement("div")
7979
const shadow = document.querySelector("#starknetkit-modal-container")
8080

81+
if (["android", "ios"].includes(device)) {
82+
const toMobileApp = document.createElement("button")
83+
toMobileApp.style.display = "none"
84+
toMobileApp.addEventListener("click", () => {
85+
window.location.href = urls[device]
86+
})
87+
toMobileApp.click()
88+
89+
return
90+
}
91+
8192
if (shadow?.shadowRoot) {
8293
const slot = shadow.shadowRoot.querySelector(".qr-code-slot")
8394

0 commit comments

Comments
 (0)