Screen Inches
Very simple Cordova plugin, used to get information related to device screen.
With this plugin you shoud be able to get: Screen width, screen height, screen diagonal screen size (in inches), screen resolution PPI (also known as DPI)
Installation
You can install screen inches plugin with Cordova CLI, from npm:
$ cordova plugin add screen-inches
$ cordova prepare
Values
width
height
screenDiagonal
Code
windowpluginsaboutScreen
Usage
Make yourself a function like this, and edit the MAX_INCHES_TEST_USER_AGENT variable to set the limit between tablet and mobile, the function will return a string in a promise with the value "tablet" or "smartphone"
var MAX_INCHES_TEST_USER_AGENT = 60; { var deferred = $; //No cordova found, navigator screen size if !windowcordova var w = width * windowdevicePixelRatio h = height * windowdevicePixelRatio diagonalSize = Math; console; var maxDiagonal = 1280; if diagonalSize >= maxDiagonal deferred; else deferred; //Test IOS devices based on userAgent else if navigatoruserAgent deferred; else if navigatoruserAgent || navigatoruserAgent deferred; //Android, retrieving size from plugin else windowpluginsaboutScreen; return deferred;};