Skip to content

feat: [SDK-5473] send onesignal_id with confirmed receipts and notification opened - #1790

Draft
nan-li wants to merge 3 commits into
mainfrom
nan/sdk-5473
Draft

nan-li wants to merge 3 commits into
mainfrom
nan/sdk-5473

Conversation

@nan-li

@nan-li nan-li commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Description

One Line Summary

Send the user's onesignal_id with confirmed receipts and notification opened. SDK-5473.

Details

Motivation

The server resolves the user behind a receipt from the subscription id. On a cache miss that lookup scans every partition of the user store, and large sends turned it into 500s on report_received (UD-4748). With the onesignal_id in the body the server can query one partition and verify that the subscription belongs to that user.

Scope

  • The NSE confirmed receipt, the Live Activities receipt and the notification opened request add a top-level onesignal_id string. The key is left out when the id is nil or empty, never sent as null.
  • The value comes from a new OneSignalIdentifiers.onesignalId accessor, which reads the OS_SNAPSHOT_ONESIGNAL_ID shared UserDefaults key the user module writes once the server assigns an id. The NSE reads it the same way it reads the app id and subscription id.
  • OSRequestReceiveReceipts and OSRequestSubmitNotificationOpened gain an onesignalId: parameter. Both are internal request classes.
  • player_id, app_id and device_type are unchanged. Outcomes already send the field and are untouched.

Deploy order

The server's report_received handler rejects unknown JSON fields today, so this must not release before the server accepts the field. The opened endpoint ignores unknown fields. Neither handler reads the field yet. The server side is tracked under UD-4748.

Freshness

The key lags login() and logout() by the Create User round trip. During that window a receipt names the previous user, which matches what the server resolves from the subscription in the same window, since the subscription moves to the new user when that same Create User lands. logout() under identity verification clears the key synchronously, so receipts omit the field until the next login.

Testing

Unit testing

Twelve new tests: three for the accessor in OneSignalIdentifiersFallbackTests, three for the Live Activities receipt in OSLiveActivitiesExecutorTests, three for the NSE path in the new ReceiveReceiptsRequestTests (UnitTests target, driving OneSignalReceiveReceiptsController through a recording client), and three for the opened request in OneSignalCoreTests. Each set covers a known id, a missing id and an empty string.

Manual testing

The four test classes run locally, 47 tests, on an iPhone 17 Pro (iOS 26.5) simulator with Xcode 27.1. Not tested against a server that accepts the field, and not run on a device.

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

The NSE runs in its own process, so the id is read from the
OS_SNAPSHOT_ONESIGNAL_ID shared UserDefaults key that the user module
writes once the server has assigned one.
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