access NSNotifications from iOS app on M1 Mac

I'm working on an iPad app, which I want to be able to run properly on the M1 Mac. I am not using Mac Catalyst because I am using OpenGL, which is not available for Catalyst. Instead, I am targeting "My Mac(Designed for iPad) when I build for the M1 Mac.

I would like to know when my app has been placed in full screen mode (when running on the M1 Mac). MacOS (AppKit?) provides the "NSWindowDidEnterFullScreenNotification" to help with this.

In general, I'd love to be able to access these "NSWindow*" notifications from within my iOS app, but specifically, I get the error: "Use of undeclared identifier 'NSWindowDidEnterFullScreenNotification' when I use "[NSNotificationCenter defaultCenter] addObserver" to get notified when my app goes full screen.

Any ideas as to how I can bridge this gap between iOS and MacOS and get notifications from MacOS, without resorting to Mac Catalyst? This capability would be extremely useful.

Replies

What actions do you expect your app to take when it enters full screen?

I use cmdKey to create custom keyboard and menu shortcuts. I wanted to use the escape key to switch between two screens, but this disabled the default behavior for the escape key on the Mac (exiting fullscreen mode). Detecting fullscreen mode would offer a chance to temporally disable the custom shortcut, restoring default behavior (escaping from fullscreen mode with the escape key). My workaround so far is to compare the updated size.height to mainScreen.nativeBounds.height within viewWillTransitionToSize(). If size.height >= nativeBounds.height, then I assume we're in fullscreen mode. I set a boolean isFullScreen, which disables the custom shortcut within the validateCommand() method.