Skip to content

Commit 4ffbb22

Browse files
authored
chore(openiap): bump ios/android libs (#212)
## Summary - Upgrade Android fallback/config plugin to use [openiap-google 1.1.10](https://github.com/hyodotdev/openiap-google/releases/tag/1.1.10) - Bump [iOS pod to openiap 1.1.12](https://github.com/hyodotdev/openiap-apple/releases/tag/1.1.12) and align native error codes with PascalCase constants ## Testing - bun run lint:tsc - bun run lint:eslint - bun run lint:prettier - bun run lint:kt - bun run test <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - iOS: Added promoted product event and returns full promoted product details. - iOS: Broader purchase/product input formats supported and more robust parsing. - Bug Fixes - iOS/Android: More consistent and clarified error reporting across purchase flows. - iOS: Improved subscription status shape and safer transaction completion flows. - Chores - Updated in-app purchase library versions for Android and iOS. - Updated build/plugin dependency handling and local example app paths. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent a388d51 commit 4ffbb22

File tree

8 files changed

+465
-249
lines changed

8 files changed

+465
-249
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ dependencies {
5858
implementation project(":openiap-google")
5959
} else {
6060
// Fallback to published artifact when local project isn't linked
61-
implementation "io.github.hyochan.openiap:openiap-google:1.1.0"
61+
implementation "io.github.hyochan.openiap:openiap-google:1.1.10"
6262
}
6363
}

android/src/main/java/expo/modules/iap/ExpoIapModule.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import dev.hyo.openiap.OpenIapError
66
import dev.hyo.openiap.OpenIapModule
77
import dev.hyo.openiap.models.DeepLinkOptions
88
import dev.hyo.openiap.models.ProductRequest
9-
import dev.hyo.openiap.models.RequestPurchaseAndroidProps
9+
import dev.hyo.openiap.models.RequestPurchaseParams
1010
import expo.modules.kotlin.Promise
1111
import expo.modules.kotlin.exception.Exceptions
1212
import expo.modules.kotlin.modules.Module
@@ -103,7 +103,7 @@ class ExpoIapModule : Module() {
103103
if (!ok) {
104104
// Clear any buffered events from a failed init
105105
pendingEvents.clear()
106-
promise.reject(OpenIapError.E_INIT_CONNECTION, "Failed to initialize connection", null)
106+
promise.reject(OpenIapError.InitConnection.CODE, "Failed to initialize connection", null)
107107
return@withLock
108108
}
109109

@@ -118,7 +118,7 @@ class ExpoIapModule : Module() {
118118

119119
promise.resolve(true)
120120
} catch (e: Exception) {
121-
promise.reject(OpenIapError.E_INIT_CONNECTION, e.message, e)
121+
promise.reject(OpenIapError.InitConnection.CODE, e.message, e)
122122
}
123123
}
124124
}
@@ -143,7 +143,7 @@ class ExpoIapModule : Module() {
143143
val products = openIap.fetchProducts(ProductRequest(skuArr.toList(), reqType))
144144
promise.resolve(products.map { it.toJSON() })
145145
} catch (e: Exception) {
146-
promise.reject(OpenIapError.E_QUERY_PRODUCT, e.message, null)
146+
promise.reject(OpenIapError.QueryProduct.CODE, e.message, null)
147147
}
148148
}
149149
}
@@ -154,7 +154,7 @@ class ExpoIapModule : Module() {
154154
val purchases = openIap.getAvailablePurchases(null)
155155
promise.resolve(purchases.map { it.toJSON() })
156156
} catch (e: Exception) {
157-
promise.reject(OpenIapError.E_SERVICE_ERROR, e.message, null)
157+
promise.reject(OpenIapError.ServiceUnavailable.CODE, e.message, null)
158158
}
159159
}
160160
}
@@ -168,7 +168,7 @@ class ExpoIapModule : Module() {
168168
openIap.deepLinkToSubscriptions(DeepLinkOptions(sku, packageName))
169169
promise.resolve(null)
170170
} catch (e: Exception) {
171-
promise.reject(OpenIapError.E_SERVICE_ERROR, e.message, null)
171+
promise.reject(OpenIapError.ServiceUnavailable.CODE, e.message, null)
172172
}
173173
}
174174
}
@@ -180,7 +180,7 @@ class ExpoIapModule : Module() {
180180
val code = openIap.getStorefront()
181181
promise.resolve(code)
182182
} catch (e: Exception) {
183-
promise.reject(OpenIapError.E_SERVICE_ERROR, e.message, e)
183+
promise.reject(OpenIapError.ServiceUnavailable.CODE, e.message, e)
184184
}
185185
}
186186
}
@@ -204,7 +204,7 @@ class ExpoIapModule : Module() {
204204
val reqType = ProductRequest.ProductRequestType.fromString(type)
205205
val result =
206206
openIap.requestPurchase(
207-
RequestPurchaseAndroidProps(
207+
RequestPurchaseParams(
208208
skus = skus,
209209
obfuscatedAccountIdAndroid = obfuscatedAccountId,
210210
obfuscatedProfileIdAndroid = obfuscatedProfileId,
@@ -223,7 +223,7 @@ class ExpoIapModule : Module() {
223223
} catch (e: Exception) {
224224
val errorMap =
225225
mapOf(
226-
"code" to OpenIapError.E_PURCHASE_ERROR,
226+
"code" to OpenIapError.PurchaseFailed.CODE,
227227
"message" to (e.message ?: "Purchase failed"),
228228
"platform" to "android",
229229
)
@@ -235,7 +235,7 @@ class ExpoIapModule : Module() {
235235
// Reject and clear any pending promises for this purchase flow
236236
PromiseUtils.rejectPromisesForKey(
237237
PromiseUtils.PROMISE_BUY_ITEM,
238-
OpenIapError.E_PURCHASE_ERROR,
238+
OpenIapError.PurchaseFailed.CODE,
239239
e.message,
240240
null,
241241
)
@@ -249,7 +249,7 @@ class ExpoIapModule : Module() {
249249
openIap.acknowledgePurchaseAndroid(token)
250250
promise.resolve(mapOf("responseCode" to 0))
251251
} catch (e: Exception) {
252-
promise.reject(OpenIapError.E_SERVICE_ERROR, e.message, null)
252+
promise.reject(OpenIapError.ServiceUnavailable.CODE, e.message, null)
253253
}
254254
}
255255
}
@@ -261,7 +261,7 @@ class ExpoIapModule : Module() {
261261
openIap.consumePurchaseAndroid(token)
262262
promise.resolve(mapOf("responseCode" to 0, "purchaseToken" to token))
263263
} catch (e: Exception) {
264-
promise.reject(OpenIapError.E_SERVICE_ERROR, e.message, null)
264+
promise.reject(OpenIapError.ServiceUnavailable.CODE, e.message, null)
265265
}
266266
}
267267
}

android/src/main/java/expo/modules/iap/PromiseUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ object PromiseUtils {
3232
fun rejectAllPendingPromises() {
3333
// Snapshot to avoid concurrent modification
3434
promises.values.flatMap { it.toList() }.forEach { promise ->
35-
promise.safeReject(OpenIapError.E_CONNECTION_CLOSED, "Connection has been closed", null)
35+
promise.safeReject(OpenIapError.ServiceDisconnected.CODE, "Connection has been closed", null)
3636
}
3737
promises.clear()
3838
}
@@ -60,7 +60,7 @@ fun Promise.safeResolve(value: Any?) {
6060
}
6161
}
6262

63-
fun Promise.safeReject(message: String) = this.safeReject("E_UNKNOWN", message, null)
63+
fun Promise.safeReject(message: String) = this.safeReject(OpenIapError.UnknownError.CODE, message, null)
6464

6565
fun Promise.safeReject(
6666
code: String,

0 commit comments

Comments
 (0)