Skip to content

Instantly share code, notes, and snippets.

@Loonz806
Created November 20, 2020 18:18
Show Gist options
  • Save Loonz806/f53ff8fe59af6ee8f50a2276d99ee4f7 to your computer and use it in GitHub Desktop.
Save Loonz806/f53ff8fe59af6ee8f50a2276d99ee4f7 to your computer and use it in GitHub Desktop.
How to detect type of iPad model.
// iPad model checks.
const getiPadModel = () => {
if (window.screen.height / window.screen.width == 1024 / 768) {
// iPad, iPad 2, iPad Mini
if (window.devicePixelRatio == 1) {
return "iPad 1, iPad 2, iPad Mini 1";
}
// iPad 3, 4, 5, Mini 2, Mini 3, Mini 4, Air, Air 2, Pro 9.7
else {
return "iPad 3, iPad 4, iPad 5, iPad Air 1, iPad Air 2, iPad Mini 2, iPad Mini 3, iPad Mini 4, iPad Pro 9.7";
}
}
// iPad Pro 10.5
else if (window.screen.height / window.screen.width == 1112 / 834) {
return "iPad Pro 10.5";
}
// iPad Pro 12.9, Pro 12.9 (2nd Gen)
else if (window.screen.height / window.screen.width == 1366 / 1024) {
return "iPad Pro 12.9, Pro 12.9 (2nd Gen)";
}
// Not an ipad
else {
return "Not an iPad";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment