Device Class

In some scenerios, it is beneficial for an Omni Automation script to derive information about the device running the script. For example, a plug-in that creates new views might need to adjust its actions based upon whether the device running the script is an iPad or an iPhone. The Device class can be used to derive information about the device and operating system on which the script is executed.

Class Properties

Instance Properties

Device.Type Class

Class properties for the Device.Type class:

Examples

Here are some examples of the use of the Device class:

Device.current
if (Device.current.iOS && !Device.current.iPad){ console.log("This device is an iPhone.") } else if (Device.current.iPad){ console.log("This device is an iPad.") } else if (Device.current.mac){ console.log("This device is a Mac.") }
var OSversion = Device.current.operatingSystemVersion OSversion.versionString
if (Device.current.mac){ var curVers = Device.current.operatingSystemVersion var versToCheck = new Version("10.5") var result = versToCheck.atLeast(curVers) if (result === false){ var title = "INCOMPATIBLE PLUG-IN" var msg = "This plug-in requires macOS 10.5 or newer. " msg = msg.concat("The current operating system version is: " + curVers.versionString) new Alert(title, msg).show() } } else { var title = "INCOMPATIBLE PLUG-IN" var msg = "This plug-in requires a device running macOS 10.5 or newer." new Alert(title, msg).show() }
UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER