diff --git a/.github/workflows/ci-example-android.yml b/.github/workflows/ci-example-android.yml index fafe1314e..259a66f90 100644 --- a/.github/workflows/ci-example-android.yml +++ b/.github/workflows/ci-example-android.yml @@ -27,8 +27,8 @@ jobs: - uses: actions/setup-java@v3 with: - distribution: 'adopt' - java-version: "14.x" + distribution: 'zulu' + java-version: "17.x" - name: Setup Node.js uses: actions/setup-node@v3 diff --git a/.github/workflows/ci-example-ios.yml b/.github/workflows/ci-example-ios.yml index 60f91f446..3fbe73394 100644 --- a/.github/workflows/ci-example-ios.yml +++ b/.github/workflows/ci-example-ios.yml @@ -52,6 +52,9 @@ jobs: bundler-cache: true ruby-version: '2.7' + - name: Install SwiftLint + run: brew install swiftlint + - name: SwiftLint run: swiftlint lint --fix --format --path ios/*.swift --config .swiftlint.yml diff --git a/IapExample/Gemfile.lock b/IapExample/Gemfile.lock index 5c50bdc2a..54285cb51 100644 --- a/IapExample/Gemfile.lock +++ b/IapExample/Gemfile.lock @@ -72,8 +72,10 @@ GEM nap (1.1.0) netrc (0.11.0) public_suffix (4.0.7) - rexml (3.2.6) + rexml (3.2.8) + strscan (>= 3.0.9) ruby-macho (2.5.1) + strscan (3.1.0) typhoeus (1.4.1) ethon (>= 0.9.0) tzinfo (2.0.6) diff --git a/README.md b/README.md index 9e10b9941..127b5da97 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,14 @@ --- +## Announcement +Announcing the Migration of react-native-iap to an Expo Module for Improved Maintenance and Compatibility in [discussion #2754](https://github.com/dooboolab-community/react-native-iap/discussions/2754). + ## Documentation Read the [documentation](https://react-native-iap.dooboolab.com). See the [troubleshooting](https://react-native-iap.dooboolab.com/docs/guides/troubleshooting#common-issues) for the common issues to avoid. -## Announcement +## Logs - Version `12.0.0`: Implements Amazon 3.x SDK including the new DRM verification. @@ -55,11 +58,9 @@ Follow [this guide](./IapExample/README.md) to get the example running. | | -###

Silver Tier

+## Past Sponsors -| [Revenuecat](https://www.revenuecat.com) | -|:--:| -| | + Support this project by becoming a sponsor. Your logo will show up here with diff --git a/android/gradle.properties b/android/gradle.properties index b8db3823f..b2d076b75 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,12 +1,12 @@ -RNIap_kotlinVersion=1.7.21 +RNIap_kotlinVersion=1.8.0 RNIap_minSdkVersion=21 -RNIap_targetSdkVersion=31 -RNIap_compileSdkVersion=31 -RNIap_buildToolsVersion=30.0.2 -RNIap_ndkversion=21.4.7075529 +RNIap_targetSdkVersion=33 +RNIap_compileSdkVersion=33 +RNIap_buildToolsVersion=33.0.0 +RNIap_ndkversion=23.1.7779620 RNIap_playServicesVersion=18.1.0 RNIap_amazonSdkVersion=3.0.4 -RNIap_playBillingSdkVersion=6.0.1 +RNIap_playBillingSdkVersion=6.1.0 android.useAndroidX=true android.enableJetifier=true diff --git a/android/src/play/java/com/dooboolab/rniap/RNIapModule.kt b/android/src/play/java/com/dooboolab/rniap/RNIapModule.kt index 2d1a3b4fa..862068a6b 100644 --- a/android/src/play/java/com/dooboolab/rniap/RNIapModule.kt +++ b/android/src/play/java/com/dooboolab/rniap/RNIapModule.kt @@ -504,19 +504,14 @@ class RNIapModule( if (obfuscatedProfileId != null) { builder.setObfuscatedProfileId(obfuscatedProfileId) } - if (prorationMode != -1) { - if (prorationMode - == BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE - ) { - subscriptionUpdateParamsBuilder.setReplaceProrationMode( - BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_PRORATED_PRICE, + when (prorationMode) { + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.CHARGE_PRORATED_PRICE -> { + subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode( + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.CHARGE_PRORATED_PRICE, ) if (type != BillingClient.ProductType.SUBS) { val debugMessage = - ( - "IMMEDIATE_AND_CHARGE_PRORATED_PRICE for proration mode only works in" + - " subscription purchase." - ) + "IMMEDIATE_AND_CHARGE_PRORATED_PRICE for proration mode only works in subscription purchase." val error = Arguments.createMap() error.putString("debugMessage", debugMessage) error.putString("code", PROMISE_BUY_ITEM) @@ -526,31 +521,30 @@ class RNIapModule( promise.safeReject(PROMISE_BUY_ITEM, debugMessage) return@ensureConnection } - } else if (prorationMode - == BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION - ) { - subscriptionUpdateParamsBuilder.setReplaceProrationMode( - BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION, + } + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.WITHOUT_PRORATION -> { + subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode( + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.WITHOUT_PRORATION, ) - } else if (prorationMode == BillingFlowParams.ProrationMode.DEFERRED) { - subscriptionUpdateParamsBuilder.setReplaceProrationMode( - BillingFlowParams.ProrationMode.DEFERRED, + } + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.DEFERRED -> { + subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode( + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.DEFERRED, ) - } else if (prorationMode - == BillingFlowParams.ProrationMode.IMMEDIATE_WITH_TIME_PRORATION - ) { - subscriptionUpdateParamsBuilder.setReplaceProrationMode( - BillingFlowParams.ProrationMode.IMMEDIATE_WITHOUT_PRORATION, + } + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.WITH_TIME_PRORATION -> { + subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode( + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.WITH_TIME_PRORATION, ) - } else if (prorationMode - == BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE - ) { - subscriptionUpdateParamsBuilder.setReplaceProrationMode( - BillingFlowParams.ProrationMode.IMMEDIATE_AND_CHARGE_FULL_PRICE, + } + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.CHARGE_FULL_PRICE -> { + subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode( + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.CHARGE_FULL_PRICE, ) - } else { - subscriptionUpdateParamsBuilder.setReplaceProrationMode( - BillingFlowParams.ProrationMode.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, + } + else -> { + subscriptionUpdateParamsBuilder.setSubscriptionReplacementMode( + BillingFlowParams.SubscriptionUpdateParams.ReplacementMode.UNKNOWN_REPLACEMENT_MODE, ) } } diff --git a/docs/docs/guides/troubleshooting.mdx b/docs/docs/guides/troubleshooting.mdx index 720d2b677..7c878934d 100644 --- a/docs/docs/guides/troubleshooting.mdx +++ b/docs/docs/guides/troubleshooting.mdx @@ -10,13 +10,16 @@ import AdFitTopFixed from "@site/src/uis/AdFitTopFixed"; # Troubleshooting +## Recommendations + +- Before continuing any coding, ensure that you have successfully completed all forms related to agreements, bank accounts, or tax information (any bureaucratic processes associated with the app store you are using). + ## Common issues Most of the issues encountered by users are caused by: - A device simulator. Use a real device for testing! - An incorrect usage of the library. Read the [documentation](https://react-native-iap.dooboolab.com). -- For `Android`, a hold in your payment profile on Google Play Console. Check for any warnings. ## `getProducts` returns an empty array diff --git a/docs/docs/support-us.mdx b/docs/docs/support-us.mdx index 551f42b2a..091899c13 100644 --- a/docs/docs/support-us.mdx +++ b/docs/docs/support-us.mdx @@ -13,7 +13,7 @@ import AdFitTopFixed from "@site/src/uis/AdFitTopFixed"; maintain this repository to support devs to monetize around the world. Since `IAP` itself is not perfect on each platform, we desperately need -this project to be maintained. If you'd like to help us, please contact the [maintainer: dooboolab@gmail.com](dooboolab@gmail.com). +this project to be maintained. If you'd like to help us, please contact the [maintainer: dooboolab@gmail.com](mailto:dooboolab@gmail.com). ## Our Sponsors @@ -24,10 +24,8 @@ this project to be maintained. If you'd like to help us, please contact the [mai | | -### Silver Tier +## Past Sponsors -| [Revenuecat](https://www.revenuecat.com) | -|:--:| -| | + After 6 years of maintenance, we finally have an official sponsor. I am deeply grateful. 🙇🏻‍♂️ diff --git a/ios/RNIapIosSk2.swift b/ios/RNIapIosSk2.swift index 6cb644f33..8c9b73219 100644 --- a/ios/RNIapIosSk2.swift +++ b/ios/RNIapIosSk2.swift @@ -597,7 +597,7 @@ class RNIapIosSk2iOS15: Sk2Delegate { func addTransaction(transaction: Transaction) { purchasedItems.append( transaction) if alsoPublishToEventListener { - self.sendEvent?("purchase-update", serialize(transaction)) + self.sendEvent?("purchase-updated", serialize(transaction)) } } func addError( error: Error, errorDict: [String: String]) { diff --git a/package.json b/package.json index 046a2d04c..10dd5a37a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-iap", - "version": "12.13.0", + "version": "12.13.2", "description": "React Native In App Purchase Module.", "repository": "https://github.com/dooboolab-community/react-native-iap", "author": "hyochan (https://github.com/hyochan)", @@ -117,6 +117,6 @@ "@types/react": "17.0.59" }, "dependencies": { - "@expo/config-plugins": "^7.8.4" + "@expo/config-plugins": "^8.0.4" } } diff --git a/src/hooks/useIAP.ts b/src/hooks/useIAP.ts index 1e3ad8468..d2fe4d3f9 100644 --- a/src/hooks/useIAP.ts +++ b/src/hooks/useIAP.ts @@ -1,4 +1,4 @@ -import {useCallback} from 'react'; +import {useCallback, useEffect} from 'react'; import { finishTransaction as iapFinishTransaction, @@ -118,6 +118,13 @@ export const useIAP = (): IAP_STATUS => { ], ); + useEffect(() => { + return () => { + setCurrentPurchaseError(undefined); + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + return { connected, products, diff --git a/yarn.lock b/yarn.lock index 4ddf7f206..ce40eb027 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1316,24 +1316,22 @@ resolved "https://registry.npmjs.org/@eslint/js/-/js-8.43.0.tgz" integrity sha512-s2UHCoiXfxMvmfzqoN+vrQ84ahUSYde9qNO1MdxmoEhyHWsfmwOpFlwYV+ePJEVc7gFnATGUi376WowX1N7tFg== -"@expo/config-plugins@^7.8.4", "@expo/config-plugins@~7.8.2": - version "7.8.4" - resolved "https://registry.npmjs.org/@expo/config-plugins/-/config-plugins-7.8.4.tgz" - integrity sha512-hv03HYxb/5kX8Gxv/BTI8TLc9L06WzqAfHRRXdbar4zkLcP2oTzvsLEF4/L/TIpD3rsnYa0KU42d0gWRxzPCJg== +"@expo/config-plugins@^8.0.4": + version "8.0.4" + resolved "https://registry.yarnpkg.com/@expo/config-plugins/-/config-plugins-8.0.4.tgz#1e781cd971fab27409ed2f8d621db6d29cce3036" + integrity sha512-Hi+xuyNWE2LT4LVbGttHJgl9brnsdWAhEB42gWKb5+8ae86Nr/KwUBQJsJppirBYTeLjj5ZlY0glYnAkDa2jqw== dependencies: - "@expo/config-types" "^50.0.0-alpha.1" - "@expo/fingerprint" "^0.6.0" + "@expo/config-types" "^51.0.0-unreleased" "@expo/json-file" "~8.3.0" "@expo/plist" "^0.1.0" "@expo/sdk-runtime-versions" "^1.0.0" - "@react-native/normalize-color" "^2.0.0" chalk "^4.1.2" debug "^4.3.1" find-up "~5.0.0" getenv "^1.0.0" glob "7.1.6" resolve-from "^5.0.0" - semver "^7.5.3" + semver "^7.5.4" slash "^3.0.0" slugify "^1.6.6" xcode "^3.0.1" @@ -1344,6 +1342,11 @@ resolved "https://registry.npmjs.org/@expo/config-types/-/config-types-50.0.1.tgz" integrity sha512-EZHMgzkWRB9SMHO1e9m8s+OMahf92XYTnsCFjxhSfcDrcEoSdFPyJWDJVloHZPMGhxns7Fi2+A+bEVN/hD4NKA== +"@expo/config-types@^51.0.0-unreleased": + version "51.0.0" + resolved "https://registry.yarnpkg.com/@expo/config-types/-/config-types-51.0.0.tgz#f5df238cd1237d7e4d9cc8217cdef3383c2a00cf" + integrity sha512-acn03/u8mQvBhdTQtA7CNhevMltUhbSrpI01FYBJwpVntufkU++ncQujWKlgY/OwIajcfygk1AY4xcNZ5ImkRA== + "@expo/config@~8.5.0": version "8.5.2" resolved "https://registry.npmjs.org/@expo/config/-/config-8.5.2.tgz" @@ -10449,9 +10452,9 @@ undici-types@~5.26.4: integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== undici@^5.25.4: - version "5.28.3" - resolved "https://registry.npmjs.org/undici/-/undici-5.28.3.tgz" - integrity sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA== + version "5.28.4" + resolved "https://registry.yarnpkg.com/undici/-/undici-5.28.4.tgz#6b280408edb6a1a604a9b20340f45b422e373068" + integrity sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g== dependencies: "@fastify/busboy" "^2.0.0"