I'm trying to make a React.js page so when you scan a Qr code it goes to this page and the page redirects to the Apple app store or Google Play depending on your phone. google play is working just fine the problem is that if you open it from iPhone it doesn't work and if you have the app already installed it opens it, I want to open the app store on the web or the app itself, and is it possible that it opens in a new window instead of the same window. thanks in advance.
if (detect.os.name.toLocaleLowerCase() === "Android".toLocaleLowerCase()) {
window.location =
"https://play.google.com/store/apps/details?id=myAppId";
setTimeout(() => (window.location.pathname = "/download"), 10000);
return <div>redirecting to GooglePlay</div>;
} else if (detect.os.name.toLocaleLowerCase() === "IOS".toLocaleLowerCase()) {
window.location.href =
"https://apps.apple.com/eg/app/myApp";
setTimeout(() => (window.location.pathname = "/download"), 10000);
return <div>redirecting to Apple Store</div>;
detect = parser(navigator.userAgent) and parser is a library I installed using npm
Via Active questions tagged javascript - Stack Overflow https://ift.tt/BlExXgL
Comments
Post a Comment