const openInstallPage = () => {
const md = new MobileDetect(navigator.userAgent);
if (md.is("iPhone")) {
window.open(
"https://apps.apple.com/us/app/metamask-blockchain-wallet/id1438144202"
);
} else if (md.os() || md.mobile()) {
try {
window.open(
"https://metamask.app.link/dapp/emirpreview.vercel.app" //deeplink, this url will try to open metamask mobile app. If it cant, i want to redirect user to install page.
);
} catch (err) {
window.open("https://play.google.com/store/apps/details?id=io.metamask");
}
} else {
window.open(
"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn"
);
}
};
When someone click my button on mobile, i want to redirect user to the metamask app if its installed. If it's not i want to redirect user to metamask install page.
How can i handle this? Try catch methods are not working at all... Am i doing something wrong?
Note: i want to do this things on mobile so im using mobile-deteck package from npm.