Skip to content

Commit

Permalink
Merge branch 'main' into fix/storekit1-thread-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
hyochan authored Jun 11, 2024
2 parents 0b0fa5b + 567ae41 commit 14699d7
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 66 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-example-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci-example-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion IapExample/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -55,11 +58,9 @@ Follow [this guide](./IapExample/README.md) to get the example running.
| <a href="https://namiml.com"><img src="https://github.com/dooboolab-community/react-native-iap/assets/27461460/89d71f61-bb73-400a-83bd-fe0f96eb726e" width="450"/></a> |


### <p style="color: silver;">Silver Tier</p>
## Past Sponsors

| [Revenuecat](https://www.revenuecat.com) |
|:--:|
| <a href="https://www.revenuecat.com"><img src="https://github.com/dooboolab-community/react-native-iap/assets/27461460/1e387a47-afe0-4b85-ad78-1064ca6623fa" width="300"/></a> |
<a href="https://www.revenuecat.com"><img src="https://github.com/dooboolab-community/react-native-iap/assets/27461460/1e387a47-afe0-4b85-ad78-1064ca6623fa" width="200"/></a>


Support this project by becoming a sponsor. Your logo will show up here with
Expand Down
12 changes: 6 additions & 6 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
56 changes: 25 additions & 31 deletions android/src/play/java/com/dooboolab/rniap/RNIapModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
)
}
}
Expand Down
5 changes: 4 additions & 1 deletion docs/docs/guides/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 3 additions & 5 deletions docs/docs/support-us.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]]([email protected]).
this project to be maintained. If you'd like to help us, please contact the [maintainer: [email protected]](mailto:[email protected]).

## Our Sponsors

Expand All @@ -24,10 +24,8 @@ this project to be maintained. If you'd like to help us, please contact the [mai
| <a href="https://namiml.com"><img src="https://github.com/dooboolab-community/react-native-iap/assets/27461460/89d71f61-bb73-400a-83bd-fe0f96eb726e" width="450"/></a> |


### Silver Tier
## Past Sponsors

| [Revenuecat](https://www.revenuecat.com) |
|:--:|
| <a href="https://www.revenuecat.com"><img src="https://github.com/dooboolab-community/react-native-iap/assets/27461460/1e387a47-afe0-4b85-ad78-1064ca6623fa" width="300"/></a> |
<a href="https://www.revenuecat.com"><img src="https://github.com/dooboolab-community/react-native-iap/assets/27461460/1e387a47-afe0-4b85-ad78-1064ca6623fa" width="200"/></a>

After 6 years of maintenance, we finally have an official sponsor. I am deeply grateful. 🙇🏻‍♂️
2 changes: 1 addition & 1 deletion ios/RNIapIosSk2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> (https://github.com/hyochan)",
Expand Down Expand Up @@ -117,6 +117,6 @@
"@types/react": "17.0.59"
},
"dependencies": {
"@expo/config-plugins": "^7.8.4"
"@expo/config-plugins": "^8.0.4"
}
}
9 changes: 8 additions & 1 deletion src/hooks/useIAP.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useCallback} from 'react';
import {useCallback, useEffect} from 'react';

import {
finishTransaction as iapFinishTransaction,
Expand Down Expand Up @@ -118,6 +118,13 @@ export const useIAP = (): IAP_STATUS => {
],
);

useEffect(() => {
return () => {
setCurrentPurchaseError(undefined);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return {
connected,
products,
Expand Down
25 changes: 14 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 14699d7

Please sign in to comment.