Skip to content

fix(android): delegate fetchProducts type 'all' to native query on Android - #239

Merged
hyochan merged 3 commits into
mainfrom
claude/issue-238-review-ab0tmv
Jul 20, 2026
Merged

hyochan merged 3 commits into
mainfrom
claude/issue-238-review-ab0tmv

Conversation

@hyochan

@hyochan hyochan commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Fixes fetchProducts({ type: 'all' }) on Android returning subscriptions as in-app with productStatusAndroid: 'not-found'.
  • Root cause: the react-native-iap Android bridge expanded all into separate in-app and subs queries and merged them with putIfAbsent. Since openiap-google 2.4.x, each per-type query returns a not-found placeholder row for every requested sku of the other type, so the in-app placeholder shadowed the real subscription from the subs query.
  • Fix: pass the query type through unchanged so the native module resolves ProductQueryType.All itself (all three store flavors — play/horizon/amazon — already handle it correctly, matching each sku as in-app first, then subs, then a typed unavailable placeholder). This also stops the productTypeBySku cache from being poisoned with in-app for subscription skus, which previously broke subsequent requestPurchase type hints.
  • Removes the now-unused collectAllQueryProducts helper and its tests (one test baked the buggy first-match-wins semantics in as expected behavior).
  • Adds a release-note entry to packages/docs documenting the fix as the react-native-iap 15.5.4 release (assumed-published mode; the release-tag link goes live once 15.5.4 is deployed).
  • Other SDKs (expo-iap, flutter_inapp_purchase, godot-iap, maui-iap, kmp-iap) already delegate all to the native layer and are unaffected.

Closes #238

Test plan

  • yarn typecheck passes (react-native-iap)
  • yarn lint passes (react-native-iap)
  • bunx prettier --check, bun run build, bun run audit:docs, git diff --check pass (packages/docs)
  • Android CI build passes

🤖 Generated with Claude Code

https://claude.ai/code/session_0154xivm4YeCVS9yxk54bHL6

Summary by CodeRabbit

  • Bug Fixes
    • Improved Android fetchProducts({ type: 'all' }) behavior to fetch products more consistently and align closer to native handling.
    • Preserves the requested SKU order and includes additional fetched products without dropping unmatched results.
  • Documentation
    • Added a react-native-iap 15.5.4 release note describing the Android fetchProducts({ type: 'all' }) fix and updated the package release links.
  • Tests
    • Removed Android product-query helper tests that covered the previous multi-part “all” query behavior.

…droid

The Android bridge expanded ProductQueryType.All into separate in-app and
subs queries and merged them with putIfAbsent. Since openiap-google 2.4.x,
each per-type query returns a not-found placeholder row for every requested
sku of the other type, so the in-app placeholder shadowed the real
subscription and subscriptions came back as type 'in-app' with
productStatusAndroid 'not-found'. Pass the query type through unchanged so
the native module resolves 'all' itself and each sku keeps its real product
type and status.

Closes #238

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0154xivm4YeCVS9yxk54bHL6
@hyochan hyochan added 🐛 bug Something isn't working 🤖 android Related to android react-native-iap react-native-iap library labels Jul 20, 2026 — with Claude
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f89bf8f7-61a9-4fe0-8c25-8eddb9df695a

📥 Commits

Reviewing files that changed from the base of the PR and between 34e478b and 276c0d8.

📒 Files selected for processing (1)
  • libraries/react-native-iap/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • libraries/react-native-iap/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt

📝 Walkthrough

Walkthrough

Android fetchProducts now sends ProductQueryType.All directly to OpenIAP, removes the combined-query helper and its tests, preserves input SKU order while appending extra results, and documents the react-native-iap 15.5.4 release.

Changes

Android product fetching

Layer / File(s) Summary
Direct native query and ordered results
libraries/react-native-iap/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt, libraries/react-native-iap/android/src/main/java/com/margelo/nitro/iap/ProductQueryHelpers.kt, libraries/react-native-iap/android/src/test/java/com/margelo/nitro/iap/ProductQueryHelpersTest.kt
fetchProducts performs one OpenIAP request for every query type, assembles de-duplicated results in input order, and removes the decomposed all-query helper and its tests.
Release note and package links
packages/docs/src/pages/docs/updates/releases.tsx
Adds the July 20, 2026 react-native-iap 15.5.4 release note and renders package release links from a release-tag mapping.

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

Possibly related PRs

Suggested labels: 📖 documentation

🚥 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 states the Android fetchProducts all-query fix and matches the main code change.
Linked Issues check ✅ Passed The code now queries native Android for type 'all' and returns correctly ordered products, addressing #238.
Out of Scope Changes check ✅ Passed The docs release note and test/helper removals are directly tied to the Android fetchProducts fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 claude/issue-238-review-ab0tmv

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.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request simplifies product fetching in the React Native IAP Android library by passing the queryType directly to the native module, allowing it to resolve ProductQueryType.All natively. This change ensures SKUs retain their correct product types and eliminates the need for the collectAllQueryProducts helper function and its associated unit tests, which have been removed. I have no feedback to provide as there are no review comments to assess.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Documents the Android fetchProducts type 'all' fix (issue #238, PR #239)
as an assumed-published 15.5.4 release entry.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0154xivm4YeCVS9yxk54bHL6

@coderabbitai coderabbitai Bot 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.

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
`@libraries/react-native-iap/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt`:
- Around line 418-420: Update the result-building logic in HybridRnIap around
fetched, byId, and skusList to deduplicate requested IDs while preserving their
input order, then append fetched products not requested by skusList in
native-return order. Match the iOS result shape and run bun audit:parity after
making the platform-parity change.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 36dcdd30-3ac0-4a8f-bda9-0e19a062b99e

📥 Commits

Reviewing files that changed from the base of the PR and between 8b2c385 and be0672e.

📒 Files selected for processing (3)
  • libraries/react-native-iap/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt
  • libraries/react-native-iap/android/src/main/java/com/margelo/nitro/iap/ProductQueryHelpers.kt
  • libraries/react-native-iap/android/src/test/java/com/margelo/nitro/iap/ProductQueryHelpersTest.kt
💤 Files with no reviewable changes (2)
  • libraries/react-native-iap/android/src/main/java/com/margelo/nitro/iap/ProductQueryHelpers.kt
  • libraries/react-native-iap/android/src/test/java/com/margelo/nitro/iap/ProductQueryHelpersTest.kt

Deduplicate repeated skus and append fetched products that were not
requested, mirroring the iOS bridge (PR #239 review).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0154xivm4YeCVS9yxk54bHL6
@hyochan
hyochan merged commit b4e5fcc into main Jul 20, 2026
12 checks passed
@hyochan
hyochan deleted the claude/issue-238-review-ab0tmv branch July 20, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 android Related to android 🐛 bug Something isn't working react-native-iap react-native-iap library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Android: fetchProducts({ type: 'all' }) consider subscriptions to be in-app

2 participants