Skip to content

Instantly share code, notes, and snippets.

@ano
Created November 27, 2024 20:22
Show Gist options
  • Save ano/902d65a363fdf53a6487502153446729 to your computer and use it in GitHub Desktop.
Save ano/902d65a363fdf53a6487502153446729 to your computer and use it in GitHub Desktop.
Redirect to App
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>App Download</title>
<script>
// JavaScript to detect platform and redirect
document.addEventListener("DOMContentLoaded", function () {
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(userAgent)) {
// Redirect to Google Play Store for Android
window.location.href = "https://play.google.com/store/apps/details?id=com.smartie.merchant";
} else if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
// Redirect to Apple App Store for iOS
window.location.href = "https://apps.apple.com/nz/app/smartie-merchant/id6504093979";
} else {
// Redirect to a fallback URL for unsupported devices or desktops
window.location.href = "https://www.smartie.com";
}
});
</script>
</head>
<body>
<h1>Redirecting to the App Store...</h1>
<p>If you are not redirected, <a href="https://www.yourwebsite.com">click here</a>.</p>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>App Download</title>
<script>
// JavaScript to detect platform and redirect
document.addEventListener("DOMContentLoaded", function () {
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(userAgent)) {
// Redirect to Google Play Store for Android
window.location.href = "https://play.google.com/store/apps/details?id=com.smartie.merchant";
} else if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
// Redirect to Apple App Store for iOS
window.location.href = "https://play.google.com/store/apps/details?id=com.smartie.customer";
} else {
// Redirect to a fallback URL for unsupported devices or desktops
window.location.href = "https://www.smartie.com";
}
});
</script>
</head>
<body>
<h1>Redirecting to the App Store...</h1>
<p>If you are not redirected, <a href="https://www.yourwebsite.com">click here</a>.</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment