I want mobile users to direct to stores. My code below work well on android and ios devices but huawei devices acting like android because of their android os. I wonder if there is a way detect huawei devices that use anroid operating system from browser.
NOTE: userAgent detect operation system, not detect huawei devices that use anroid operating system
<script>
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
// Huawei Phone must come first because its UA also contains "Android"
if (userAgent.includes("HUAWEI") || userAgent.includes("huawei") || userAgent.includes("Huawei")) {
window.location.replace("https://appgallery.huawei.com/app/C104724711");
} else if (userAgent.includes("Android")) {
window.location.replace("https://play.google.com/store/apps/details?id=com.emlakbank.mobil&hl=tr&gl=US");
} else if (userAgent.includes("iPhone") || userAgent.includes("Ipad") || userAgent.includes("iPod")) {
setTimeout(function() {
window.location = "https://apps.apple.com/tr/app/emlak-kat%C4%B1l%C4%B1m/id1467874818?l=tr";
}, 25);
window.location("https://apps.apple.com/tr/app/emlak-kat%C4%B1l%C4%B1m/id1467874818?l=tr");
//If the second line of code gives a result then the first row is never executed.
} else {
//cant be sure about device, so redirect to home page
// window.location.replace("https://google.ro");
}
</script>