Device


super: Object

Use a Device object to get information about the device such as assigned name, device model, operating-system name and version, battery state and device orientation.

Events

  • None

Properties

  • var version: DeviceVersion Returns a value from the DeviceVersion enum identifying the type of device (for example iPhone7, iPhone7Plus, iPadPro12Dot9Inch2Gen, etc.). (read-only)

  • var versionName: String Returns a string representation of the deviceVersion property. (read-only)

  • var size: DeviceSize Returns a value from the DeviceSize enum identifying the screen size of the device (for example Screen4inch, Screen4Dot7inch, etc.). To get a human readable string representation or the numeric diagonal size in inches you can use the conversion methods sizeName or sizeInches. (read-only)

  • var systemName: String The name of the operating system running on the device. (read-only)

  • var systemVersion: String The current version of the operating system. (read-only)

  • var systemMajorVersion: Int The current major version of the operating system. For example in iOS 11.4.1 this value is 11. (read-only)

  • var systemMinorVersion: Int The current minor version of the operating system. For example in iOS 11.4.1 this value is 4. (read-only)

  • var systemPatchVersion: Int The current patch version of the operating system. For example in iOS 11.4.1 this value is 1. (read-only)

  • var name: String The name identifying the device. (read-only)

  • var model: String The model of the device. (read-only)

  • var orientation: DeviceOrientation The physical orientation of the device. (read-only)

  • var batteryLevel: Float The battery charge level for the device.Battery level ranges from 0.0 (fully discharged) to 1.0 (100% charged). Before accessing this property, ensure that battery monitoring is enabled. If battery monitoring is not enabled, battery state is unknown and the value of this property is –1.0. (read-only)

  • var batteryMonitoringEnabled: Bool A Boolean value indicating whether battery monitoring is enabled (true) or not (false).

  • var batteryState: DeviceBatteryState The battery state for the device. If battery monitoring is not enabled, the value of this property is unknown

  • var language: String Users choose a primary language when configuring a device. Use this property to obtain the current user's primary device language. (read-only)

  • var isPhone: Bool Check if current device is an iPhone. (read-only)

  • var isPad: Bool Check if current device is an iPad. (read-only)

  • var isCreoKit: Bool Check if current app is running on CreoKit. (read-only)

  • var isCreoPlayer: Bool Check if current app is running on CreoPlayer. (read-only)

  • var isAppleSimulator: Bool Check if current app is running on Apple Simulator. (read-only)

  • var isRealDevice: Bool Check if current app is running on a real iOS device. (read-only)

Methods

  • func sizeInches(size: DeviceSize): Float Convert a value from the DeviceSize enum to the numeric value of the screen size (diagonal).

  • func sizeName(size: DeviceSize): String Convert a value from the DeviceSize enum to its string representation.

  • func vibrate() Invoke a brief device vibration.

Enumeration

DeviceVersion

  • .Simulator
  • .Unknown
  • .iPad1
  • .iPad2
  • .iPad3
  • .iPad4
  • .iPad5
  • .iPadAir
  • .iPadAir2
  • .iPadMini
  • .iPadMini2
  • .iPadMini3
  • .iPadMini4
  • .iPadPro10Dot5Inch
  • .iPadPro12Dot9Inch
  • .iPadPro12Dot9Inch2Gen
  • .iPadPro9Dot7Inch
  • .iPhone4
  • .iPhone4S
  • .iPhone5
  • .iPhone5C
  • .iPhone5S
  • .iPhone6
  • .iPhone6Plus
  • .iPhone6S
  • .iPhone6SPlus
  • .iPhone7
  • .iPhone7Plus
  • .iPhone8
  • .iPhone8Plus
  • .iPhoneSE
  • .iPhoneX
  • .iPhoneXR
  • .iPhoneXS
  • .iPhoneXSMax

DeviceSize

  • .Screen10Dot5inch
  • .Screen12Dot9inch
  • .Screen3Dot5inch
  • .Screen4Dot7inch
  • .Screen4inch
  • .Screen5Dot5inch
  • .Screen5Dot8inch
  • .Screen6Dot1inch
  • .Screen6Dot5inch
  • .Screen7Dot9inch
  • .Screen9Dot7inch
  • .Unknown

DeviceOrientation

  • .FaceDown
  • .FaceUp
  • .LandscapeLeft
  • .LandscapeRight
  • .Portrait
  • .PortraitUpsideDown
  • .Unknown

DeviceBatteryState

  • .Charging
  • .Full
  • .Unknown
  • .Unplugged

Examples

Log Device information:

Device.batteryMonitoringEnabled = true;

var string = "Device Version Name: " +  Device.deviceVersionName;
string += "\nDevice Version Code: " + Device.deviceVersion;
string += "\nDevice Size: " + 
Device.deviceSizeName(Device.deviceSize);
string += "\nSystem Version: " + Device.systemVersion;
string += "\nSystem Name: " + Device.systemName;
string += "\nDevice Name: " + Device.name;
string += "\nDevice Model: " + Device.model;
string += "\nBattery: Enabled=" + Device.batteryMonitoringEnabled + ", State=" + Device.batteryState + ", Charge=" + Int(Device.batteryLevel*100) + "%";

Console.write(string);

Result:

Device Version Name: iPhone 5S
Device Version Code: 7
Device Size: 4.0 in
System Version: 8.0.0
System Name: iOS
Device Name: Xinantécatl
Device Model: iPhone
Battery: Enabled=true, State=3, Charge=100%