Adding device detection code on an ad project is blocked by browser probably detecting it as malware. I am not able to test this part. Do I need a whilte listed ad test server?
Here is the code.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script>
function getMobileOperatingSystem() {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
// Windows Phone must come first because its UA also contains "Android"
if (/windows phone/i.test(userAgent)) {
return "Windows Phone";
}
if (/android/i.test(userAgent)) {
return "Android";
}
// iOS detection from: http://stackoverflow.com/a/9039885/177710
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
return "iOS";
}
return "unknown";
}</script>
<script>
function DetectAndServe(){
if (getMobileOperatingSystem() == "Android") {
window.location.href = "https://play.google.com/store/apps/details?id=com.bigfishgames.jackpotcityslotsf2pgoogle&hl=en_IN";
}
if (getMobileOperatingSystem() == "iOS") {
window.location.href = "https://itunes.apple.com/us/app/jackpot-magic-slots-casino/id1090242126?mt=8";
}
if (getMobileOperatingSystem() == "Windows Phone") {
window.location.href = "https://itunes.apple.com/us/app/jackpot-magic-slots-casino/id1090242126?mt=8";
}
if (getMobileOperatingSystem() == "unknown") {
window.location.href = "https://itunes.apple.com/us/app/jackpot-magic-slots-casino/id1090242126?mt=8";}
}
</script>
</head>
<body onload="">
<button type="button" onclick="DetectAndServe()">Install the game!</button>
</body>
</html>