Are isKeyWindow property and didBecomeKeyNotification event deprecated?

Hi.

I know that UIApplication#keyWindow is deprecated since iOS/iPadOS 13.0.

But now (iOS/iPadOS 16.5), UIWindow#isKeyWindow and didBecomeKeyNotification seem deprecated, too. isKeyWindow is always true and didBecomeKeyNotification is never triggered.

Is my understanding right? And if so, since what version of iOS/iPadOS are they deprecated?

Replies

As of iOS 15 UIWindow.isKeyWindow and UIWindow.didBecomeKeyNotification are both relative to the scene the window is in. If the scene only has 1 window, it is likely that it will always be key, and that the notification will never be sent (or more specifically, it was sent before you added any observers).

Rincewind san,

Thank you for your comment!

However, I confirmed that both windows' isKeyWindow are true and no didBecomeKeyNotification are triggered even when the app has two scenes. I think that they are deprecated.

  • This is correct – each window is key within its own scene and unless you installed your notification handler before you made the window key, you won't see it called. Neither of these API are deprecated as of iOS 17.

Add a Comment