I am developing a personal web page and, using a JavaScript function, I identify if the page is being displayed on a smartphone, a tablet or a desktop computer. When I perform the tests on Android or Windows devices I see everything working correctly. The problem is when I use an Apple brand device, testing with Safari. In any of the three types of devices shows me as if it were a smartphone.
The function that I have is the following:
var deviceDetector = function(){
var b = navigator.userAgent.toLowerCase();
var a = function(a){
void 0!==a&&(b=a.toLowerCase());
return/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(b)?"tablet":
/(mobi|ipod|phone|blackberry|opera mini|fennec|minimo|symbian|psp|nintendo ds|archos|skyfire|puffin|blazer|bolt|gobrowser|iris|maemo|semc|teashark|uzard)/.test(b)?"phone":
"desktop"
};
return{
device:a(),detect:a,isMobile:"desktop"!=a()?!0:!1,userAgent:b
}
}();