I wrote some simple code to find the type of the device:
$(document).ready(detectDevice);
function detectDevice() {
if (window.innerWidth > 768) {
var device = "Desktop";
console.log('=======device======', device);
} else if (window.innerWidth < 767 && window.innerWidth > 481) {
var device = "iPad";
} else if (window.innerWidth < 480) {
var device = "Mobile Phone";
}
}
But I want to find the correct model name of the device from which the app is being used. I don't want to write the code using navigator.userAgent
which will find out using browsers.
Please can someone tell me if there is any way to find this using JavaScript or jQuery?