← Back to PRs

#9926: fix(macos): guard UNUserNotificationCenter when no bundle identifier

by webcpu open 2026-02-05 21:57 View on GitHub →
app: macos size: XS
## Summary - `UNUserNotificationCenter.current()` crashes when the process lacks a bundle identifier (e.g. `swift run`) - Add `notificationCenterIfAvailable()` helper that returns `nil` when `Bundle.main.bundleIdentifier` is absent - Update all three call sites to bail out gracefully instead of crashing ## Test plan - [x] Run macOS app normally — notifications work as before - [x] Run via `swift run` — no crash, notifications silently skipped <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a small macOS-only guard around `UNUserNotificationCenter.current()` by introducing `notificationCenterIfAvailable()`, which returns `nil` when `Bundle.main.bundleIdentifier` is missing (e.g. `swift run`). It then updates the notification-related call sites in `NotificationManager`, `PermissionManager`, and `NodePairingApprovalPrompter` to bail out instead of crashing when notifications are unavailable. <h3>Confidence Score: 3/5</h3> - This PR is likely safe, but verify it builds across all macOS targets. - Change is small and localized, but the new file-scope helper must be visible to every call site in the target; if any file is compiled in a different target/module, this will fail to compile. Once confirmed, behavior change is straightforward (skip notifications when no bundle id). - apps/macos/Sources/OpenClaw/NotificationManager.swift (helper placement/visibility), apps/macos/Sources/OpenClaw/NodePairingApprovalPrompter.swift (call site compile/link visibility) <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs