Skip to content

fix: [SDK-5315] send one confirmed delivery per notification ID - #1786

Merged
nan-li merged 1 commit into
mainfrom
nan/sdk-5315
Nov 20, 2026
Merged

nan-li merged 1 commit into
mainfrom
nan/sdk-5315

Conversation

@nan-li

@nan-li nan-li commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

One Line Summary

Send one confirmed delivery per notification ID from the Notification Service Extension. SDK-5315

Details

Motivation

iOS can run the Notification Service Extension more than once for a single notification, seen on an iOS 27 beta where the system also displayed the notification twice. Each run reported a confirmed delivery, so one send showed two receipts on the subscription timeline.

Scope

  • A duplicate run skips the influence record as well as the receipt, on purpose. Android drops a duplicate FCM message before display and records neither, so this matches it.
  • The in-process list exists because shared defaults are unreadable before first unlock, and the iOS 27 duplicate runs land in one extension process seconds apart.
  • The second notification still displays. The extension cannot drop a notification.
  • A duplicate handled by a separate extension process before first unlock still reports. That gap is left in.
  • The notification ID is recorded before the receipt is sent. If that send fails, a duplicate run does not resend it, because a retry could report the same delivery twice.
  • Two extension processes handling the same notification at the same moment can each report. That gap is left in.

Testing

Unit testing

Six tests in OneSignalNotificationServiceExtensionHandlerTests drive the extension entry point twice, ten times concurrently, across a simulated process restart, and past the list cap, and count report_received requests through a recording client.

Manual testing

Test class run locally on an iPhone 17 Pro (iOS 26.5) simulator with Xcode 27.1.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

🤖 Generated with Claude Code

The notification service extension can run more than once for one notification, and each run sent a confirmed delivery.

Co-authored-by: Cursor <cursoragent@cursor.com>
@nan-li
nan-li marked this pull request as ready for review October 29, 2026 16:14
@nan-li
nan-li requested a review from a team November 13, 2026 17:25

@abdulraqeeb33 abdulraqeeb33 left a comment

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.

The same-process dedup matches the iOS 27 double run, and the notification still displays. Two things should change before this lands: the id is recorded before the send is known to have succeeded, and the shared list is a read-modify-write that two extension processes can clobber.

@nan-li

nan-li commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

I replied in each thread. I'm keeping the record-before-send order, because a duplicate run almost never gets a usable retry and a retry risks double-counting again. I'm leaving the cross-process race as a known gap, since its worst case is today's behavior. Both are now in the Scope section. The log line stays at DEBUG.

@abdulraqeeb33 abdulraqeeb33 left a comment

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.

Approving. The replies on record-before-send, the two-process race, the DEBUG line, and the badge stand.

Known gap, same class as the ones already in Scope: the id is recorded before the checks that return without a request (no app id, receipts read as off). Before first unlock those reads are empty unless OSResilientStorage already has them. The failure block does not clear the id, so a later extension process after unlock will not send. No change requested.

@nan-li
nan-li merged commit 3b82457 into main Nov 20, 2026
7 of 9 checks passed
@nan-li
nan-li deleted the nan/sdk-5315 branch November 20, 2026 17:45
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.

3 participants