I am trying to identify iPhones with the notch programmatically. I am aware of the screen.size method, but when you have a universal app supporting all interface orientations, it becomes a mess (counting all the possible variations). So I am looking for a simpler and more elegant way to detect the newer iPhones X models.

I have stumbled upon a method online that is supposed to work. In it, you measure the bottom inset of the safe area and if it is not zero, you have an iPhone X model. This makes sense in theory since, the safe area does not reach the bottom of the screen on the iPhone X handsets but does on all other devices. I do the check this way:

```
if (@available( iOS 11.0, * )) {
    if ([[[UIApplication sharedApplication] keyWindow] safeAreaInsets].bottom > 0) {
        // iPhone with notch
    }
} else {
    // Regular iPhone
}

```

This, however, does not work. Can someone point out my mistake in the implementation or confirm if this method is even viable?