Platform
Use this module to access information about the current device such as screen resolution, operating system, model, manufacturer,etc.
Usage
import { Device, Screen, isAndroid, isIOS } from '@nativescript/core'
console.log(`Running on Android? ${isAndroid}`) // true if app is running on Android. False otherwise
console.log(`Running on iOS? ${isIOS}`) // true if app is running on iOS. False otherwise
console.log(`Device.model ${Device.model}`) // For example: "Nexus 5" or "iPhone".
console.log(`Device.deviceType ${Device.deviceType}`) // "Phone" | "Tablet"
console.log(`Device.os ${Device.os}`) // For example: "Android" or "iOS".
console.log(`Device.osVersion ${Device.osVersion}`) // For example: 4.4.4(android), 8.1(ios)
console.log(`Device.sdkVersion ${Device.sdkVersion}`) // For example: 19(android), 8.1(ios).
console.log(`Device.language ${Device.language}`) // For example "en" or "en-US".
console.log(`Device.manufacturer ${Device.manufacturer}`) // For example: "Apple" or "HTC" or "Samsung".
console.log(`Device.uuid ${Device.uuid}`) // The unique identification number
console.log(`Device.region ${Device.region}`) // For example "US".
console.log(`Screen.mainScreen.heightDIPs ${Screen.mainScreen.heightDIPs}`) // The absolute height of the screen in density independent pixels.
console.log(`Screen.mainScreen.heightPixels ${Screen.mainScreen.heightPixels}`) // The absolute height of the screen in pixels.
console.log(`Screen.mainScreen.scale ${Screen.mainScreen.scale}`) // The logical density of the display.
console.log(`Screen.mainScreen.widthDIPs ${Screen.mainScreen.widthDIPs}`) // The absolute width of the screen in density independent pixels.
console.log(`Screen.mainScreen.widthPixels ${Screen.mainScreen.widthPixels}`) // The absolute width of the screen in pixel
Device class
Provides the current device information.
Properties
Name | Type | Description |
---|---|---|
|
|
Gets the manufacturer of the device. |
|
|
Gets the model of the device. |
|
|
Gets the OS of the device. |
|
|
Gets the OS version. |
|
|
Gets the SDK version. |
|
|
Gets the type of the current device. |
|
|
Gets the uuid. On iOS this will return a new uuid if the application is re-installed on the device. If you need to receive the same uuid even after the application has been re-installed on the device, use this plugin. |
|
|
Gets the device preferred language. |
|
|
Gets the device region. |
Screen.mainScreen properties
Gets information about the main screen of the current device.
Properties
Name | Type | Description |
---|---|---|
|
|
Gets the absolute width of the screen in pixels. |
|
|
Gets the absolute height of the screen in pixels. |
|
|
Gets the absolute width of the screen in density independent pixels. |
|
|
Gets the absolute height of the screen in density independent pixels. |
|
|
This is a scaling factor for the Density Independent Pixel unit. |