Skip to content

Commit 53efc83

Browse files
authored
refactor: migrate to recent openiap modules (#3019)
Organize OpenIAP module with `openiap-versions.json`. ```json { "apple": "1.2.2", "google": "1.2.6", "gql": "1.0.8" } ``` Migrate to `openiap-apple`, `openiap-google`, and `openiap-gql` to following version. Updates genuinely follows https://github.com/hyochan/expo-iap/releases <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * iOS: fetch promoted product, get/refresh App Store receipt, deep-link to subscriptions. Android: storefront and deep-link helpers. Example app: Loading, PurchaseDetails, PurchaseSummaryRow, revamped Purchase/Subscription screens. * **Refactor** * Improved structured, redacted diagnostics and more consistent cross‑platform error handling and deduplication. * **Documentation** * Clarified Android dependency guidance; bumped OpenIAP versions. * **Chores** * Added centralized OpenIAP version file and dynamic version resolution; package script update. * **Tests** * Added/updated tests for receipts, deeplink fallbacks, dynamic versions, and example flows. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent be0fe36 commit 53efc83

39 files changed

+5771
-4387
lines changed

NitroIap.podspec

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
require "json"
22

33
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4+
versions_path = File.join(__dir__, "openiap-versions.json")
5+
unless File.exist?(versions_path)
6+
raise "NitroIap: Missing openiap-versions.json. Add the file to manage native dependency versions."
7+
end
8+
9+
versions = JSON.parse(File.read(versions_path))
10+
apple_version = versions["apple"]
11+
unless apple_version.is_a?(String) && !apple_version.strip.empty?
12+
raise "NitroIap: 'apple' version missing or invalid in openiap-versions.json"
13+
end
414

515
Pod::Spec.new do |s|
616
s.name = "NitroIap"
@@ -32,7 +42,7 @@ Pod::Spec.new do |s|
3242
s.dependency 'React-jsi'
3343
s.dependency 'React-callinvoker'
3444
# OpenIAP Apple for StoreKit 2 integration
35-
s.dependency 'openiap', '1.1.12'
45+
s.dependency 'openiap', apple_version
3646

3747
install_modules_dependencies(s)
3848
end

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ Before installing React Native IAP, make sure you have:
9090

9191
#### Android Configuration
9292

93-
Add the OpenIAP Google library to your `android/app/build.gradle` dependencies:
93+
Add the OpenIAP Google library to your `android/app/build.gradle` dependencies. React Native IAP pins the native module versions in `openiap-versions.json` so Android, iOS, and tooling stay in sync:
9494

9595
```gradle
9696
dependencies {
97-
implementation "io.github.hyochan.openiap:openiap-google:1.1.12"
97+
implementation "io.github.hyochan.openiap:openiap-google:1.2.6"
9898
}
9999
```
100100

android/build.gradle

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import groovy.json.JsonSlurper
2+
13
buildscript {
24
repositories {
35
google()
@@ -19,6 +21,27 @@ def isNewArchitectureEnabled() {
1921
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
2022
}
2123

24+
def resolveOpenIapVersionsFile() {
25+
def candidates = [
26+
new File(projectDir.parentFile, 'openiap-versions.json'),
27+
new File(rootDir.parentFile ?: rootDir, 'openiap-versions.json'),
28+
new File(rootProject.projectDir.parentFile ?: rootProject.projectDir, 'openiap-versions.json')
29+
]
30+
return candidates.find { it.exists() }
31+
}
32+
33+
def openiapVersionsFile = resolveOpenIapVersionsFile()
34+
if (openiapVersionsFile == null) {
35+
throw new GradleException("react-native-iap: Unable to locate openiap-versions.json")
36+
}
37+
38+
def openiapVersions = new JsonSlurper().parse(openiapVersionsFile)
39+
def googleVersion = (openiapVersions instanceof Map) ? openiapVersions.google : null
40+
if (!(googleVersion instanceof String) || !googleVersion.trim()) {
41+
throw new GradleException("react-native-iap: 'google' version missing or invalid in openiap-versions.json")
42+
}
43+
def googleVersionString = googleVersion.trim()
44+
2245
apply plugin: "com.android.library"
2346
apply plugin: 'org.jetbrains.kotlin.android'
2447

@@ -155,7 +178,7 @@ dependencies {
155178

156179
// Kotlin coroutines
157180
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0'
158-
implementation 'io.github.hyochan.openiap:openiap-google:1.1.12'
181+
implementation "io.github.hyochan.openiap:openiap-google:${googleVersionString}"
159182
}
160183

161184
configurations.all {

0 commit comments

Comments
 (0)