Programmatically disable all Notification Center banners on Mac - objective-c

Can a Mac app temporarily disable Notification Center, for example while it is doing a full-screen presentation? Apple says alerts are "automatically disabled while you’re presenting in Keynote. They also won’t appear if your display is mirrored on an external monitor." Do third-party apps also have the ability to temporary disable notifications?

I don't think so, but my assumptions are base on iOS, where you can't turn off notification center at all.

You can enable Focus (aka Do Not Disturb) which will hide current notifications and prevent new ones from popping up. See https://support.apple.com/guide/mac-help/turn-a-focus-on-or-off-mchl999b7c1a/mac for how to enable/disable it.
I do not know if applications themselves have control over enabling/disabling Focus.
I use the Touch Bar and add the Focus button to quickly enable it if I need to present or share screen. I do not see a keyboard shortcut you can set in Monterrey like you could in Big Sur.

Related

Is Desktop Mode Accessible When Using Bluetooth Keyboards in ChromeOs v69?

I just found a great bluetooth keyboard by Brydge for the Pixel Slate and am wondering if current ChromeOs devices can manually transfer from "tablet" to "desktop" mode when you attach a bluetooth keyboard?
It seems like this is feasible by enabling a setting in developer mode. Thanks to #Skawtnyc's response on Reddit!
You can switch back and forth on the fly. Enable chrome://flags/#ash-debug-shortcuts and then you can use CTRL+SHIFT+ALT+T to switch back and forth between desktop and tablet mode.
If you connect a mouse it will automatically switch to desktop mode, but using this method you can still switch back and forth.
#Skawtnyc also points out a bug to watch out for when using an external display such as a monitor.
Keep in mind that when connected to a dock with an external display, this setup can trigger a crash/restart error. The cause is the virtual keyboard. Anything that causes the virtual keyboard to appear on screen will trigger it. The workaround is to go into Accessibility settings and turn off the on-screen keyboard. You don't need it anyway when using a physical keyboard.

How do you hide the menu bar in a Cocoa app?

How do you programmatically hide the menu bar in a cocoa app? I would like to make full use of the screen area.
There are two good ways I know of to do this.
1
In Cocoa, you can call the NSMenu class method setMenuBarVisible: to show or hide the menu bar.
As of this writing, the documentation for the NSMenu class does not tell you the following additional information.
The menu bar will only be hidden for the app that calls this method.
The Dock will also be hidden at the same time.
(This is true at least in 10.9 and I have not tested any other versions.)
This is useful when you want to use an app in a full screen way where you have a cover window, a borderless window the size of the screen.
The nice feature of this (as opposed to playing with LSUIElement settings) is that your app can continue to be in the application switcher cycling, as well as visible in the Dock when other apps are active.
This allows users to still activate a full screen app through the Dock or application switcher.
That means you can still use your app's Dock menu to access a preferences window for your app or other features.
This is incredibly convenient if your app is indeed a full screen cover window that runs at a window level higher than other apps, but you still want to make preferences and the ability to quit your app available, and you want your app's visual functionality available when other apps are active.
2
Another option is via NSApplication's method setPresentationOptions: with the arguments from NSApplicationPresentationOptions enum, such as option NSApplicationPresentationHideMenuBar
With this approach be very wary of reading the documentation, although it gives you additional options, and is still app-specific only, you need to know that some of the options are mutually exclusive. There are rules you must follow, or you get nothing but exceptions spewed to the console.
3 There is a 3rd and crappy option. If you have a helper app that is a daemon, you can use it to change your app's LSUIElement state and basically relaunch your app. It's dumb and it takes you out of the app switcher completely, which is great if you really are writing something that should not be there, but that is rare.
There is also the NSView enterFullScreenMode:withOptions: method, although most apps for which that would be appropriate prior to 10.7 should probably use the modern full-screen-window API on 10.7 and later.

iOS : Disable Push Notifications drop down tray programatically

In my app design, I have a dropdown menu from the top as the user swipes down the top edge of the screen. This interferes with the Push notification tray. Is there any way to disable the default tray dropdown when my app is in the foreground?
Currently, there is no public API for manipulating the behavior of the notification center or how to prevent it.
I think it is a design decision to keep a consistent user experience at the price of developer freedom. I do not think it's not likely that an app will ever be able to block a notification's appearance, and only slightly less unlikely that an app would be able to prevent the notification center from appearing.
After all, it is what made iOS so successful. The consistency between the operating system and apps in general.

Disable the "Notification Center" on iPad (phonegap) application

Is there any way to remove the swipe event that pulls in the notification center from the top of the ipad when developing an ipad app? If there is an easy way in PhoneGap, that would be best, if not - I can manually implement any Objective-C solution.
The app is already in full screen, and there are some gestures that including swiping at the top. These iPads are distributed to the sales force of this company, and they want that feature (top swipe notification center) disabled.
Cheers!
When your app is in fullscreen mode, Notification Center switches to a two-swipe system: swipe once to bring up a little handle, and swipe down on the handle to bring up Notification Center. This should avoid most interference.
Other than that, there's no public way to disable this gesture.
Of course not. At least not without a jailbroken phone. Notification Center is built into the OS and cannot be disabled by third party apps. As #jtbandes pointed out, their is the "handle" option, but there is no way to completely disable the functionality.

Can I monitor other windows' event like resizing, hiding etc from NSNotificationCenter?

I'd like to monitor all windows (include other applications' windows) changes like resizing, hiding, un-hiding etc. I found that if I use
[NotificationCenter defaultCenter]
, I just receive the event from my own application's window. But how about
NSWorkspace's notification center?
NSWorkspace doesn't have anything to do with windows, so no.
The distributed notification center won't work, either.
Keep in mind that a notification center is not merely a portal by which to observe things; things have to post notifications on it. An NSWindow object does that when the user resizes its window, but it does it only on the default local notification center, not the distributed one nor NSWorkspace's. Therefore, that's the only notification center on which you can observe for window notifications and get anything for it, and you'll only get them about your own windows.
You can use the Accessibility API to observe a property of a window in any process, but notifications won't come in during a drag, only after it, and the user will need to have “Access for assistive devices” turned on.