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.
| Property | Description |
|---|---|
systemName read-only | The operating system's name; 'iOS' on iPhone |
systemVersion read-only | The operating system's version, a string such as '26.1' |
model read-only | The kind of device; 'iPhone' on iPhone. Not the specific model |
localizedModel read-only | model translated into the system language |
name read-only | The device's name. The name the user gave the device can't be read |
userInterfaceIdiom read-only | The kind of interface; 'phone' on iPhone |
identifierForVendor read-only | A 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.
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
phoneThe 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
| ObjC | JS |
|---|---|
UIDevice.currentDevice | UIDevice.currentDevice |
device.systemVersion | device.systemVersion |
device.userInterfaceIdiom == UIUserInterfaceIdiomPhone | device.userInterfaceIdiom === 'phone' |
device.identifierForVendor.UUIDString | device.identifierForVendor |
if (@available(iOS 27.0, *)) | Compare the major version number from systemVersion |
See also
- Reading device and system information: comparing system versions, giving the device an identifier
application: information about the app itself, such as the version number and bundle IDcrypto:randomUUID(), for generating an identifier yourself- Local storage, Keychain: saving an identifier you generated
UITraitCollection: the screen scale and whether it's dark or light, which aren't onUIDevice