Skip to content

UIDevice ​

UIDevice represents the device the app is running on. From it you read the kind of device, the operating system's name and version, and an identifier for telling devices apart.

There is only one UIDevice object in the whole app, provided by the runtime and obtained from UIDevice.currentDevice.

All seven pieces of information are read-only and don't change while the app is running; read them once and keep them.

Inheritance: EventTarget → NSObject → UIDevice

For how to check the system version and give the device an identifier, see the guide Reading device and system information.

Constructor ​

It can't be created with new. new UIDevice() throws TypeError: Illegal constructor: UIDevice is created by the runtime, not by new. Get the instance from UIDevice.currentDevice.

Static properties ​

UIDevice.currentDevice read-only

The device the app is running on. Every read returns the same object.

Instance properties ​

Also inherits properties from NSObject. The properties below are all read-only and don't change while the app is running.

PropertyDescription
systemName read-onlyThe operating system's name; 'iOS' on iPhone
systemVersion read-onlyThe operating system's version, a string such as '26.1'
model read-onlyThe kind of device; 'iPhone' on iPhone. Not the specific model
localizedModel read-onlymodel translated into the system language
name read-onlyThe device's name. The name the user gave the device can't be read
userInterfaceIdiom read-onlyThe kind of interface; 'phone' on iPhone
identifierForVendor read-onlyA UUID shared on this device by apps from the same developer; may be null

Examples ​

The code below prints device and system information. It needs no UI and goes at the top level of main.js.

js
const device = UIDevice.currentDevice;

console.log(device.systemName + ' ' + device.systemVersion);
console.log(device.model);
console.log(device.userInterfaceIdiom);

Result: On iPhone, the console prints three lines like:

iOS 26.1
iPhone
phone

The acceptance tests read these properties in the sceneconnect callback. Reading them at the top level of a script is not verified in the simulator.

Corresponding iOS API ​

ObjCJS
UIDevice.currentDeviceUIDevice.currentDevice
device.systemVersiondevice.systemVersion
device.userInterfaceIdiom == UIUserInterfaceIdiomPhonedevice.userInterfaceIdiom === 'phone'
device.identifierForVendor.UUIDStringdevice.identifierForVendor
if (@available(iOS 27.0, *))Compare the major version number from systemVersion

See also ​