Skip to content

feat(device-utils): report SKAdNetwork conversion values - #336

Merged
huhuanming merged 3 commits into
mainfrom
feat/device-utils-skan-conversion
Nov 26, 2026
Merged

huhuanming merged 3 commits into
mainfrom
feat/device-utils-skan-conversion

Conversation

@huhuanming

@huhuanming huhuanming commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds markSkanMilestones(bits, coarseRule) to @onekeyfe/react-native-device-utils so the OneKey app can report SKAdNetwork 4 conversion values without an ad SDK or MMP.

  • iOS 16.1+: ORs bits (0-63) with pending bits and the last accepted fine conversion value, derives the coarse value from the caller's highMask / mediumMask, and calls SKAdNetwork.updatePostbackConversionValue(_:coarseValue:lockWindow:false). Resolves { fineValue, coarseValue, updated }.
  • Repeated values are submitted. Each conversion window needs its own update. The app calls the API in each window it wants to update. A successful call returns the submitted values and updated: true. StoreKit uses coarse values in the second and third SKAdNetwork 4 windows.
  • Cross-runtime ordering: the main and background runtimes share one process-wide serial queue. Each submission includes the bits from previous successful submissions.
  • Failure and timeout: valid bits are kept in UserDefaults until 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.
  • Android and iOS below 16.1 resolve to undefined.
  • The pod now links 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

  • iOS: ReactNativeDeviceUtils-Unit-Tests passed 19 tests on an iPhone 17 Pro simulator with iOS 26.0. The 10 tests in SkanConversionTests cover:
    • bit merging and coarse mapping
    • submitting unchanged values in consecutive simulated windows
    • reporting 0 on repeated calls
    • reporting again when the coarse rule changes
    • a rejected milestone that is retained and retried after store recreation
    • input validation
    • timeout, including late success and late failure
    • concurrent callers only ever reporting increasing values
  • tsc passes. yarn lint:test-integrity passes.
  • Podfile.lock changes only the ReactNativeDeviceUtils checksum.

Not verified:

  • Android build: the Kotlin stub matches the nitrogen-generated signature, but I did not build it locally. This relies on Android native CI.
  • Real SKAdNetwork postback: needs an eligible SKAdNetwork attribution on a test device.

🤖 Generated with Claude Code


Devin Review

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>

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 potential issue.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

@sidmorizon

Copy link
Copy Markdown
Contributor

@codex review

@sidmorizon

Copy link
Copy Markdown
Contributor

@codex security review

@sidmorizon

Copy link
Copy Markdown
Contributor

Cursor review failed.

Remote error: cursor_permission_denied: HTTP 403 Forbidden: Cloud Agent is not available for free users. Please upgrade to Pro.

@cursor

cursor Bot commented Nov 26, 2026

Copy link
Copy Markdown

Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T09:49:24.210148Z b296761 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sidmorizon

Copy link
Copy Markdown
Contributor

Devin Cloud review ↗

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: b2967612ce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Copilot AI 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.

🔵 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 to undefined.
  • 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

@huhuanming
huhuanming merged commit b29e33e into main Nov 26, 2026
16 checks passed
@huhuanming
huhuanming deleted the feat/device-utils-skan-conversion branch November 26, 2026 10:10
self.timedOutReport = nil
}
}
guard semaphore.wait(timeout: .now() + reportTimeout) == .success else {

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.

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

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.

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.

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.

5 participants