DEV Community

Cover image for How do we manage to redirect users to the App Store from our download page?
Dileepa Chandima
Dileepa Chandima

Posted on

How do we manage to redirect users to the App Store from our download page?

One of my clients needs to redirect users to the app store when they load the download page. This is because the client created a few stickers with a QR code for the website's download page. Then, users need to click on the app store icons to go to the app store.

So to implement that we added the following JS script to the download page

var location = window.location;
var fullUrl = location.href;

var userAgent = navigator.userAgent || navigator.vendor || window.opera;

// iOS detection
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
  window.location.href = "apple app store link";
}
// Android detection
else if (/android/i.test(userAgent)) {
  window.location.href = "google play store link";
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)