Skip to content

fix: Unable to enable Push Notifications (OS Settings disabled)#3939

Merged
johnnyluo merged 3 commits intomainfrom
fix/os-notifications-disabled
Mar 3, 2026
Merged

fix: Unable to enable Push Notifications (OS Settings disabled)#3939
johnnyluo merged 3 commits intomainfrom
fix/os-notifications-disabled

Conversation

@gastonm5
Copy link
Contributor

@gastonm5 gastonm5 commented Mar 3, 2026

Description

Please include a summary of the change and which issue is fixed.

Fixes #3935

Which feature is affected?

  • Create vault ( Secure / Fast) - Please ensure you created a Secure vault & fast vault
  • Sending - Please attach a tx link here
  • Swap - Please attach a tx link for the swap here
  • New Chain / Chain related feature - Please attach tx link here

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Screenshots (if applicable):

Additional context

Summary by CodeRabbit

  • New Features
    • Added notification permission alerts that appear when notifications are disabled
    • Users can now navigate directly to system settings to enable notifications
    • App re-checks notification status when returning from settings
    • Alerts display in eight languages: English, German, Spanish, Croatian, Italian, Portuguese, and Simplified Chinese

@gastonm5 gastonm5 changed the title [BUG] - Unable to enable Push Notifications fix: Unable to enable Push Notifications (OS Settings disabled) Mar 3, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

Walkthrough

This pull request adds localization strings for disabled notification messaging across seven languages, introduces an authorization status check method in PushNotificationManager, and enhances NotificationsSettingsScreen with scene phase tracking, permission verification, and a settings guidance alert to address macOS notification toggle responsiveness issues.

Changes

Cohort / File(s) Summary
Localization Entries
VultisigApp/VultisigApp/Localizables/de.lproj/Localizable.strings, en.lproj/Localizable.strings, es.lproj/Localizable.strings, hr.lproj/Localizable.strings, it.lproj/Localizable.strings, pt.lproj/Localizable.strings, zh-Hans.lproj/Localizable.strings
Added two new localization keys across seven language files: notificationsDisabledMessage and notificationsDisabledTitle, providing localized UI text for disabled notifications scenarios.
Notification Permission Checking
VultisigApp/VultisigApp/Services/Notification/PushNotificationManager.swift
Introduced new public async method authorizationStatus() -> UNAuthorizationStatus that queries UNUserNotificationCenter to return current notification authorization status.
Notification Settings UI
VultisigApp/VultisigApp/Views/Settings/Notifications/NotificationsSettingsScreen.swift
Added scenePhase environment tracking, showSettingsAlert state, and openSettings() method for OS settings navigation. Replaced onAppear with onLoad for permission checks on app activation. Enhanced permission handling to display alert when notifications are denied and prevent enabling without authorization. Added checkForPermissions() async method and UI transitions for vault list section.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: Unable to enable Push Notifications (OS Settings disabled)' directly addresses the main issue: restoring the ability to enable notifications when OS settings are disabled, which aligns with the changeset's focus.
Linked Issues check ✅ Passed The PR adds user-facing alerts to guide users to enable notifications in OS settings [NotificationsSettingsScreen.swift], introduces notification authorization status checking [PushNotificationManager.swift], and provides localized messages across 7 languages for the disabled-notifications flow.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the push notifications issue: localization strings for the new alert UI, authorization status method, and updated settings screen logic with scene phase handling for permission checks.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/os-notifications-disabled

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
VultisigApp/VultisigApp/Views/Settings/Notifications/NotificationsSettingsScreen.swift (2)

144-149: Potential redundant state update loop.

checkForPermissions() calls onNotificationsEnabled(isEnabled) which may trigger unnecessary logic. When the app becomes active and permissions are still denied, this will:

  1. Call onNotificationsEnabled(false)
  2. Which sets notificationsEnabled = false and calls unregisterForRemoteNotifications()

This could cause repeated unregister calls each time the app becomes active.

♻️ Proposed fix to avoid redundant updates
 `@MainActor`
 func checkForPermissions() async {
     await pushNotificationManager.checkPermissionStatus()
     let isEnabled = pushNotificationManager.isPermissionGranted
-    onNotificationsEnabled(isEnabled)
+    // Only update if state actually changed to avoid redundant side effects
+    if notificationsEnabled != isEnabled {
+        notificationsEnabled = isEnabled
+        if !isEnabled {
+            pushNotificationManager.setAllVaultsOptIn(vaults, enabled: false)
+        }
+    }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@VultisigApp/VultisigApp/Views/Settings/Notifications/NotificationsSettingsScreen.swift`
around lines 144 - 149, checkForPermissions() is causing redundant state updates
by always calling onNotificationsEnabled(isEnabled) even when
notificationsEnabled already equals that value; change the logic so you only
invoke onNotificationsEnabled when the permission state actually changes: after
awaiting pushNotificationManager.checkPermissionStatus() and reading
pushNotificationManager.isPermissionGranted, compare that boolean against the
current notificationsEnabled property and call onNotificationsEnabled(isEnabled)
(or early-return inside onNotificationsEnabled) only if they differ, thereby
preventing repeated calls to unregisterForRemoteNotifications() and unnecessary
side-effects.

134-142: Improve consistency in URL handling across platforms.

The macOS URL scheme x-apple.systempreferences:com.apple.preference.notifications is correct. However, consider adopting the safer URL handling pattern (with optional binding) used in the macOS branch for consistency across both platforms, even though UIApplication.openSettingsURLString is a system constant.

♻️ Suggested refactor for consistency
 private func openSettings() {
     `#if` os(iOS)
-    UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
+    if let url = URL(string: UIApplication.openSettingsURLString) {
+        UIApplication.shared.open(url)
+    }
     `#elseif` os(macOS)
     if let url = URL(string: "x-apple.systempreferences:com.apple.preference.notifications") {
         NSWorkspace.shared.open(url)
     }
     `#endif`
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@VultisigApp/VultisigApp/Views/Settings/Notifications/NotificationsSettingsScreen.swift`
around lines 134 - 142, Change the iOS branch in openSettings to mirror the
safer optional-URL handling used on macOS: instead of force-unwrapping
URL(string: UIApplication.openSettingsURLString)!, construct the URL with
optional binding (if let url = URL(string: UIApplication.openSettingsURLString)
{ UIApplication.shared.open(url) }) so the function uses consistent,
non-crashing URL handling (see openSettings,
UIApplication.openSettingsURLString, UIApplication.shared.open and the macOS
NSWorkspace.shared.open pattern).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@VultisigApp/VultisigApp/Views/Settings/Notifications/NotificationsSettingsScreen.swift`:
- Around line 144-149: checkForPermissions() is causing redundant state updates
by always calling onNotificationsEnabled(isEnabled) even when
notificationsEnabled already equals that value; change the logic so you only
invoke onNotificationsEnabled when the permission state actually changes: after
awaiting pushNotificationManager.checkPermissionStatus() and reading
pushNotificationManager.isPermissionGranted, compare that boolean against the
current notificationsEnabled property and call onNotificationsEnabled(isEnabled)
(or early-return inside onNotificationsEnabled) only if they differ, thereby
preventing repeated calls to unregisterForRemoteNotifications() and unnecessary
side-effects.
- Around line 134-142: Change the iOS branch in openSettings to mirror the safer
optional-URL handling used on macOS: instead of force-unwrapping URL(string:
UIApplication.openSettingsURLString)!, construct the URL with optional binding
(if let url = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(url) }) so the function uses consistent, non-crashing
URL handling (see openSettings, UIApplication.openSettingsURLString,
UIApplication.shared.open and the macOS NSWorkspace.shared.open pattern).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e9a051 and f492a6f.

📒 Files selected for processing (9)
  • VultisigApp/VultisigApp/Localizables/de.lproj/Localizable.strings
  • VultisigApp/VultisigApp/Localizables/en.lproj/Localizable.strings
  • VultisigApp/VultisigApp/Localizables/es.lproj/Localizable.strings
  • VultisigApp/VultisigApp/Localizables/hr.lproj/Localizable.strings
  • VultisigApp/VultisigApp/Localizables/it.lproj/Localizable.strings
  • VultisigApp/VultisigApp/Localizables/pt.lproj/Localizable.strings
  • VultisigApp/VultisigApp/Localizables/zh-Hans.lproj/Localizable.strings
  • VultisigApp/VultisigApp/Services/Notification/PushNotificationManager.swift
  • VultisigApp/VultisigApp/Views/Settings/Notifications/NotificationsSettingsScreen.swift

Copy link
Contributor

@johnnyluo johnnyluo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@johnnyluo johnnyluo merged commit e46e009 into main Mar 3, 2026
2 checks passed
@johnnyluo johnnyluo deleted the fix/os-notifications-disabled branch March 3, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] - Unable to enable Push Notifications in macOS Settings (toggle unresponsive)

2 participants