HardwareInformation

open class HardwareInformation

Defines a set of convenience properties and functions when working on Apple devices, such as checking the device model name (iPhone10,3), getting the device type (iPhoneX), getting the OS version, the current device orientation and internet connection state.

Examples:

if HardwareInformation.deviceType == .iPhoneX {
// The app is running on an iPhone X
...
}

if HardwareInformation.isConnectedToNetwork {
// The device has an internet connection
...
}
  • Returns true if the app is running on an iPhone, else returns false.

    Declaration

    Swift

    public static var isPhone: Bool
  • Returns true if the app is running on an iPad, else returns false.

    Declaration

    Swift

    public static var isPad: Bool
  • Returns true if the app is runnin on an Apple TV, else returns false.

    Declaration

    Swift

    public static var isTV: Bool
  • Returns true if the app is running in Apple CarPlay, else returns false.

    Declaration

    Swift

    public static var isCar: Bool
  • Returns true if the app is running on an Apple Watch, else returns false.

    Declaration

    Swift

    public static var isWatch: Bool
  • Returns true if the app is running on an Mac, else returns false.

    Declaration

    Swift

    public static var isMac: Bool
  • Returns the model name of the device the app is running on. For example, iPhone10,3 or iPhone10,6 for the iPhone X.

    Declaration

    Swift

    public static var modelName: String
  • Returns the human readable type of the device that the app is running on (for example iPhoneX) or unknown if the type cannot be discovered.

    Declaration

    Swift

    public static var deviceType: AppleHardwareType
  • Returns the version number (for example iOS 11.1) of the OS installed on the device that the app is running on.

    Declaration

    Swift

    public static var osVersion: String
  • Returns the current orientation of the device that the app is running on. If the orientation is unknown, a guess will be made based on the main screen’s bounds: if the width is less than the height, portrait is returned, else landscapeLeft is returned.

    Declaration

    Swift

    open class HardwareInformation
  • Returns true if the device the app is running on has a retina display, else returns false.

    Declaration

    Swift

    public static var isRetinaDisplay: Bool
  • Returns true if the device the app is running on has a HD display, else returns false.

    Declaration

    Swift

    public static var isHDDisplay: Bool
  • Returns the bounds of the main screen of the device that the app is running on.

    Remark

    As of iOS 8.0, these bounds will always be relative to the device’s orientation.

    Declaration

    Swift

    public static var screenBounds: CGRect
  • Returns the Root View Controller for the main window in the app.

    Declaration

    Swift

    open class HardwareInformation
  • Returns true if the device the app is running on is connected to the internet, else returns false.

    Declaration

    Swift

    public static var isConnectedToNetwork: Bool
  • Returns true if the device the app is running on is connected to the internet via a cellular connection, such as EDGE or GPRS, else returns false.

    Declaration

    Swift

    open class HardwareInformation