In my app there is some logic for frameless devices (iPhoneX, Xs Xs max, Xr). Currently it works base on the model of the devices, so, I detect the model by DeviceKit framework.
This is valid for any orientation. No need to worry about iOS version before 11.0 since iPhone X minimum version is 11.0. Source
extension UIDevice { var hasNotch: Bool { if #available(iOS 11.0, *) { return UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0 > 0 } return false } }