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.

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

I use cmdKey to create keyboard and menu shortcuts. The idea was to use the escape key to toggle between two windows. Of course, assigning the escape key to a custom shortcut interferes with its default behavior of "escaping" out of full screen mode. I wanted to avoid disturbing this default behavior. Detecting fullscreen mode, offers the chance to temporarily disable the custom shortcut, restoring the default behavior of the escape key.

I've got a workaround. Going fullscreen triggers viewWillTransitionToSize. I get the new size.height and compare it to mainScreen.nativeBounds.height. If the new size.height >= nativeBounds.height, then I assume the app has gone fullscreen. An isFullScreen boolean is set here, and when the escape key is pressed, the shortcut is temporarily disabled, allowing default behavior for the escape key.

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.

access NSNotifications from iOS app on M1 Mac
 
 
Q