Skip to content

Dismiss tapped notifications from Notification Center#371

Open
briankeane wants to merge 1 commit into
developfrom
briankeane/notification-dismiss-on-tap
Open

Dismiss tapped notifications from Notification Center#371
briankeane wants to merge 1 commit into
developfrom
briankeane/notification-dismiss-on-tap

Conversation

@briankeane

@briankeane briankeane commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Remove the tapped notification request from Notification Center before routing its payload.
  • Expose delivered-notification removal through PushNotificationsClient and extract response handling into a testable helper.
  • Add regression coverage verifying the exact identifier is removed and completion still runs.

Testing

  • PushNotificationsTests: 21 tests passed; repository-wide Swift format check passed.

Summary by CodeRabbit

  • New Features

    • Delivered notifications are now automatically removed from Notification Center when opened.
    • Notification interactions continue routing to the appropriate in-app experience.
  • Bug Fixes

    • Ensured notification completion handling occurs after related actions finish.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds delivered-notification removal to the push notification dependency and invokes it from AppDelegate when handling notification responses, while preserving routing and completion behavior. Tests verify the identifier and completion callback.

Changes

Delivered notification removal

Layer / File(s) Summary
Push notification removal operation
PlayolaRadio/Core/PushNotifications/PushNotifications.swift
PushNotificationsClient adds removeDeliveredNotification, with the live implementation calling UNUserNotificationCenter using the notification identifier.
Notification response integration and validation
PlayolaRadio/PlayolaRadioApp.swift, PlayolaRadio/Core/PushNotifications/PushNotificationsTests.swift
AppDelegate delegates response handling to a helper that removes the delivered notification before routing; tests verify identifier forwarding and completion execution.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AppDelegate
  participant PushNotificationsClient
  participant UNUserNotificationCenter
  AppDelegate->>PushNotificationsClient: removeDeliveredNotification(identifier)
  PushNotificationsClient->>UNUserNotificationCenter: removeDeliveredNotifications(withIdentifiers:)
  AppDelegate->>AppDelegate: continue notification routing
  AppDelegate->>AppDelegate: invoke completion handler
Loading

Poem

A rabbit tapped a notice bright,
Then cleared it from the moonlit night.
The identifier led the way,
While callbacks hopped without delay.
“Clean inboxes!” the bunny sings.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: removing tapped notifications from Notification Center.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch briankeane/notification-dismiss-on-tap

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.

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR dismisses tapped push notifications from Notification Center. The main changes are:

  • Added a delivered-notification removal hook to PushNotificationsClient.
  • Wired the live client to remove the tapped request identifier.
  • Extracted notification response handling into a testable app delegate helper.
  • Added a test for exact identifier removal and completion invocation.

Confidence Score: 4/5

The notification tap path needs a fix before merging.

  • The new removal call runs before payload validation and station lookup.
  • Some reachable tap handlers can return without changing app state.
  • In those cases, the notification is gone and the user cannot retry from Notification Center.

PlayolaRadio/PlayolaRadioApp.swift

Important Files Changed

Filename Overview
PlayolaRadio/Core/PushNotifications/PushNotifications.swift Adds a client hook and live implementation for removing delivered notifications by identifier.
PlayolaRadio/PlayolaRadioApp.swift Extracts tapped-notification routing and removes the delivered notification before handling succeeds.
PlayolaRadio/Core/PushNotifications/PushNotificationsTests.swift Adds coverage for exact notification identifier removal and completion invocation.

Reviews (1): Last reviewed commit: "Dismiss delivered notification after tap" | Re-trigger Greptile

userInfo: [String: any Sendable],
completionHandler: @escaping () -> Void
) {
pushNotifications.removeDeliveredNotification(identifier)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Notification Removed Before Handling

When a tapped notification has a malformed giveaway payload, a missing stationId, or a station that is not yet loaded in stationLists, this line removes it before routing can produce any in-app effect. Those handlers can then return silently, so the user sees the notification disappear with no winner sheet or station playback and no notification left to retry.

Knowledge Base Used: Push Notifications

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@PlayolaRadio/Core/PushNotifications/PushNotificationsTests.swift`:
- Around line 120-142: Update
testHandleNotificationResponseRemovesDeliveredNotification to record calls made
through the injected pushNotifications.handleNotificationTap dependency,
including the provided userInfo payload. Assert that the tap handler is called
with the expected payload alongside the existing removal and completion
assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fc3a7ae5-69a4-4648-a65c-6bb4a8c47b5d

📥 Commits

Reviewing files that changed from the base of the PR and between ae8eee3 and 782c419.

📒 Files selected for processing (3)
  • PlayolaRadio/Core/PushNotifications/PushNotifications.swift
  • PlayolaRadio/Core/PushNotifications/PushNotificationsTests.swift
  • PlayolaRadio/PlayolaRadioApp.swift

Comment on lines +120 to +142
@Test
func testHandleNotificationResponseRemovesDeliveredNotification() {
let removedIdentifiers = LockIsolated<[String]>([])
let completionCalled = LockIsolated(false)

withDependencies {
$0.pushNotifications.removeDeliveredNotification = { identifier in
removedIdentifiers.withValue { $0.append(identifier) }
}
$0.pushNotifications.handleNotificationTap = { _ in }
} operation: {
let appDelegate = AppDelegate()
appDelegate.handleNotificationResponse(
identifier: "notification-123",
userInfo: [:]
) {
completionCalled.setValue(true)
}
}

expectNoDifference(removedIdentifiers.value, ["notification-123"])
#expect(completionCalled.value)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert that notification responses are still routed.

handleNotificationTap is stubbed with a no-op, so this test passes even if handleNotificationResponse removes the notification but never routes the payload. Record and assert the injected tap call (including its payload) so this regression test covers the preserved routing behavior.

As per coding guidelines, add regression tests for bug fixes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PlayolaRadio/Core/PushNotifications/PushNotificationsTests.swift` around
lines 120 - 142, Update
testHandleNotificationResponseRemovesDeliveredNotification to record calls made
through the injected pushNotifications.handleNotificationTap dependency,
including the provided userInfo payload. Assert that the tap handler is called
with the expected payload alongside the existing removal and completion
assertions.

Source: Coding guidelines

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.

1 participant