Repository navigation
feat(device-utils): report SKAdNetwork conversion values - #336
Conversation
Add markSkanMilestones(bits, coarseRule). On iOS 16.1+ it ORs the bits into the stored fine conversion value (0-63), derives the coarse value from the caller's masks, and calls SKAdNetwork.updatePostbackConversionValue with lockWindow false. The value only grows, and an unchanged value skips the system call. The main and background runtimes share one process-wide serial queue, so read, merge, report and persist run as one step and a smaller value is never reported after a larger one. The value is persisted to UserDefaults only after SKAdNetwork accepts it; an error or a 30 second timeout rejects and leaves it for the next call to retry. Android and older iOS resolve to undefined. The pod links StoreKit, and the XCTest suite covers merging, coarse mapping, skips, retries, validation, timeout and concurrent callers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Devin Review found 1 potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
|
@codex review |
|
@codex security review |
|
Cursor review failed. Remote error: |
|
Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
🔵 Needs a closer look
Multi-window SKAdNetwork behavior is covered only by injected reporters, with eligible-device attribution validation and Android native build confirmation still outstanding.
No open issues 🎉
What changed in this PR
Adds SKAdNetwork conversion reporting to @onekeyfe/react-native-device-utils, allowing the app to submit milestone values without an advertising SDK or measurement provider.
Changes:
- Introduces
markSkanMilestones(bits, coarseRule)for iOS 16.1+, with unsupported platforms resolving toundefined. - Serializes submissions across runtimes, persists pending bits, and handles errors, timeouts, and late callbacks.
- Adds native tests, documents the contract, and links StoreKit.
| File | Description |
|---|---|
| native-modules/react-native-device-utils/src/ReactNativeDeviceUtils.nitro.ts | Defines the API, coarse rules, and result types. |
| native-modules/react-native-device-utils/ReactNativeDeviceUtils.podspec | Links the StoreKit framework. |
| native-modules/react-native-device-utils/ios/tests/SkanConversionTests.swift | Tests merging, repeated submissions, validation, retries, timeouts, and concurrency. |
| native-modules/react-native-device-utils/ios/SkanConversionStore.swift | Implements serialized reporting and persistent milestone state. |
| native-modules/react-native-device-utils/ios/ReactNativeDeviceUtils.swift | Bridges reporting results to promises with an iOS availability guard. |
| native-modules/react-native-device-utils/docs/SPEC.md | Documents platform behavior, lifecycle, retention, and failures. |
| native-modules/react-native-device-utils/android/src/main/java/com/margelo/nitro/reactnativedeviceutils/ReactNativeDeviceUtils.kt | Adds the unsupported-platform stub. |
| example/react-native/ios/Podfile.lock | Updates the DeviceUtils pod checksum. |
Review effort: Balanced
| self.timedOutReport = nil | ||
| } | ||
| } | ||
| guard semaphore.wait(timeout: .now() + reportTimeout) == .success else { |
There was a problem hiding this comment.
P2: [Persist new milestones while a StoreKit report is in flight]
If one runtime submits bit 8 and another marks bit 1 while StoreKit is slow, the second call's pending write sits behind this semaphore wait for up to 30 seconds. If the app process exits during the wait, bit 1 exists only in the queued closure. A zero-bit retry after relaunch can recover 8 and omit the second milestone.
Please represent the in-flight report as state on the serial queue so the queue can validate and persist incoming bits during the wait and submit the next report only after reconciling the current callback.
| same fine and coarse values as the last report, subject to the validation and | ||
| in-flight rules below. | ||
| SKAdNetwork 4 requires an update during each conversion window for multiple | ||
| postbacks. StoreKit manages the windows, and the app must call this API during |
There was a problem hiding this comment.
P2: [Confirm SKAdNetwork registration on first launch]
docs/SPEC.md:635 tells the app to call this API in each window it wants to update. Apple also requires a conversion update on first launch to register attribution. I can't confirm which OneKey startup path makes that call for a fresh install with no milestones. Apple's advertised-app setup
If the first submission currently waits for a milestone, please add a first-launch call with bits: 0 and document that startup responsibility here. Please reply in this thread with the startup call site or an integration test that shows the first-launch update.
Summary
Adds
markSkanMilestones(bits, coarseRule)to@onekeyfe/react-native-device-utilsso the OneKey app can report SKAdNetwork 4 conversion values without an ad SDK or MMP.bits(0-63) with pending bits and the last accepted fine conversion value, derives the coarse value from the caller'shighMask/mediumMask, and callsSKAdNetwork.updatePostbackConversionValue(_:coarseValue:lockWindow:false). Resolves{ fineValue, coarseValue, updated }.updated: true. StoreKit uses coarse values in the second and third SKAdNetwork 4 windows.UserDefaultsuntil StoreKit accepts them. Each submission includes pending bits even after relaunch. After a 30-second timeout, new calls still record bits and reject until the outstanding callback arrives. A late success persists the fine value and clears its pending bits. A late failure leaves the bits pending.undefined.StoreKit. No ATT prompt, capability or entitlement is needed.The spec is updated under "DeviceUtils: SKAdNetwork conversion value" in
docs/SPEC.md. The bit schema and masks belong to the app and must match the conversion value schema configured for the ad network.Verification
ReactNativeDeviceUtils-Unit-Testspassed 19 tests on an iPhone 17 Pro simulator with iOS 26.0. The 10 tests inSkanConversionTestscover:tscpasses.yarn lint:test-integritypasses.Podfile.lockchanges only theReactNativeDeviceUtilschecksum.Not verified:
🤖 Generated with Claude Code