Mac hosting guide

Testing macOS Focus Mode Notification Blocking

Toggle Do Not Disturb with two one-action Shortcuts, fire one notification per interruption level from your real app, and log banner versus delivered-list results. This works on any Mac with a login session.

Figment editorial teamPublished Updated Facts checked November 10, 2026

Figment Mac plans

US East. Pay before use. Hourly and daily too.

Intel Mac VM4 shared vCPUs, 4GB RAM, 80GB SSD$25per monthApple Silicon Mac VM4 shared vCPUs, 4GB RAM, 65GB SSD$39per monthDedicated M4 Pro12-core CPU, 24GB RAM, 512GB SSD$199per month

Minimum first purchase: $25 of account credit, used for your rental.

Build two one-action Shortcuts that turn Do Not Disturb on and off, add a small UNUserNotificationCenter call to your real app (not the UI-test runner), fire one notification per interruption level, and record what the Mac does: a banner, a silent entry in Notification Center, or nothing. Run it on any Mac with a login session and Notification Center running.

What does macOS Focus expose to my app?

Very little. Focus is a user-controlled system state: your app cannot turn it on from code and cannot read its full configuration. INFocusStatusCenter in the Intents framework is available on iOS 15+, iPadOS 15+, Mac Catalyst 15+, macOS 12.0+, visionOS 1.0+ and watchOS 8+, so it is a native macOS API. Call requestAuthorization once. After the user approves Focus Status access for your bundle, focusStatus.isFocused returns a Bool?.

Apple defines that property as the user's preference for receiving communication notifications. Treat it as a hint that notifications are silenced, not as an authoritative "any Focus is on" flag, and not as a lookup for which Focus (Work, Personal, Sleep, Driving, custom) is active. For per-Focus detail the user must configure a Focus filter and your app must opt into it.

Focus filters and notification-suppression rules are different things. A Focus filter can change in-app content, hide accounts or alter UI. Notification-delivery rules decide whether banners, sounds and list entries get through. Test each separately so a pass on one does not mask a regression in the other.

How do I toggle Do Not Disturb from the command line?

Create two one-action Shortcuts and run them with the shortcuts tool. Apple documents the syntax in Run shortcuts from the command line: shortcuts run "Name" to execute, shortcuts list to enumerate and shortcuts view "Name" to open in the editor.

Build these in the Shortcuts app on the test host:

  1. Focus DND On: Set Focus → Do Not Disturb → Turn On.
  2. Focus DND Off: Set Focus → Do Not Disturb → Turn Off.

Then, from Terminal:

shortcuts run "Focus DND On"
sleep 2
shortcuts run "Focus DND Off"

Watch for the Control Center moon indicator to appear and clear. Record the exact Shortcut names in your test README so anyone rebuilding the host reproduces the same toggles. Use a dedicated test-only macOS login that owns these Shortcuts, has notification permission pre-granted for your test build and is not anyone's daily account, so a stuck DND state cannot bleed into personal work.

How do I schedule a test notification from my app?

Put the code in your app target, because an XCUITest process has its own bundle identifier and its own notification authorization, and whatever you grant it is not what ships to users. Add a debug-only menu command or #if DEBUG AppKit button that calls:

import UserNotifications

enum FocusProbe {
    static func request(level: UNNotificationInterruptionLevel, id: String) {
        let center = UNUserNotificationCenter.current()
        var opts: UNAuthorizationOptions = [.alert, .sound, .badge]
        if level == .critical { opts.insert(.criticalAlert) }

        center.requestAuthorization(options: opts) { granted, error in
            guard granted, error == nil else { return }
            let content = UNMutableNotificationContent()
            content.title = "Focus probe \(id)"
            content.body  = "level=\(level.rawValue)"
            content.interruptionLevel = level
            if level == .critical { content.sound = .defaultCritical }

            let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 2, repeats: false)
            center.add(UNNotificationRequest(identifier: id, content: content, trigger: trigger))
        }
    }
}

.criticalAlert in the authorization request is the piece most first drafts omit: without it the system drops .critical content even when the entitlement is present. .critical also requires the Apple-approved com.apple.developer.usernotifications.critical-alerts entitlement, which is a separate application you make to Apple. No hosting choice grants it.

Target requirements: macOS 12+ for interruptionLevel, a code-signed app bundle so the authorization prompt appears, and a login session with Notification Center running. A remote desktop session is a login session. A headless terminal-only connection is not.

What should the evidence log record?

Run the probe once per interruption level inside a single DND window, log the outcome and attach a Notification Center screenshot. Apple documents .critical as "The system always presents this notification, even when Do Not Disturb is active" (see UNNotificationInterruptionLevel.critical). The other levels depend on the user's per-app Focus choices, so record what you see rather than what you expected.

LevelDND on, banner?DND on, in Notification Center list?EntitlementAuthorization option
.passiveNo (silent by design)YesNone.alert
.activeUsually suppressedOften yesNone.alert
.timeSensitiveUser-controllable per app per FocusYescom.apple.developer.usernotifications.time-sensitive.alert
.criticalYes, per Apple docsYescom.apple.developer.usernotifications.critical-alerts.criticalAlert

The useful distinction is banner observation versus delivered state. getDeliveredNotifications can return a notification whose banner was suppressed, and a visible banner is not proof the entry persisted in the list, so log both in the same row. Repeat the matrix on each macOS point release you support, because behavior drifts between Ventura, Sonoma, Sequoia and Tahoe, and catching that drift is the point of the test.

What Mac does a Focus mode notification matrix need?

Any plan with remote desktop gives you the login session this test needs, and we have not run this matrix on any plan. The Intel Mac VM ($25 a month, $2 a day) runs macOS Sequoia with Xcode 26.3 or earlier, which is enough for UNUserNotificationCenter code. For Xcode 26.4 or later, or macOS Tahoe, use the Apple Silicon Mac VM ($39 a month, $6 a day) and check the macOS version shown before purchase. Critical alerts and time-sensitive entitlements do not depend on the plan. See the Mac hosting plans.

Related testing guides:

Which Figment Mac fits this work?

Intel Mac VM from $25 a month, Apple Silicon Mac VM from $39, or a Dedicated M4 Pro for $199. Hourly and daily plans too. You pay before use, starting with at least $25 of account credit.

Choose a Mac plan