Fundamental Concepts
Device
The Device
class (singleton) contains information about the current device, such as os
, manufacturer
, uuid
and more.
Using the Device class
To use the Device class, import it from @nativescript/core
.
import { Device } from '@nativescript/core'
Getting the device type
To check if the device is a phone or tablet, use the deviceType property.
const deviceType: string = Device.deviceType // Phone
Getting the device language
const language: string = Device.language // "en"
Getting the device manufacturer
The device manufacturer is accessed using the manufacturer property.
const manufacturer: string = Device.manufacturer // "Samsung"
Getting the device model
const model: string = Device.model
Getting the device operating system name
To get the device operating system name, use the os property:
const os: string = Device.os // Android
Getting the device operating system version
To access the operating system version of the device, use the osVersion property:
const osVersion: string = Device.osVersion // 13
Getting the device region
To get the country or region of the device, use the region property:
const region: string = Device.region // ES
Getting the device SDK version
Use the sdkVersion property to get the SDK version:
const sdkVersion: string = Device.sdkVersion // 33
Getting the device uuid
To access the device's universally unique identifier(uuid), use the uuid property:
const uuid: string = Device.uuid // cb83c3347392bfe2
API
deviceType
Gets current device type. Available types: "Phone" | "Tablet"
language
Gets the device language.
manufacturer
Gets the manufacturer of the device.
model
Gets the model of the device.
os
Gets the OS of the device.
osVersion
Gets the OS version.
region
Gets the device region/country.
sdkVersion
Gets the SDK version.
uuid
Gets the uuid for the device.
Note
If you need to receive the same uuid after the application is re-installed, consider using a plugin instead.
- Previous
- Connectivity
- Next
- FileSystem