react-native-iap 10.0.1 → 10.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/android/src/amazon/java/com/dooboolab/RNIap/RNIapAmazonListener.kt +4 -0
- package/android/src/amazon/java/com/dooboolab/RNIap/RNIapAmazonModule.kt +7 -1
- package/android/src/main/java/com/dooboolab/RNIap/DoobooUtils.kt +8 -0
- package/android/src/{play → main}/java/com/dooboolab/RNIap/PromiseUtlis.kt +4 -2
- package/android/src/play/java/com/dooboolab/RNIap/RNIapModule.kt +2 -0
- package/ios/RNIapIos.swift +875 -850
- package/lib/commonjs/purchaseError.js +1 -0
- package/lib/commonjs/purchaseError.js.map +1 -1
- package/lib/module/purchaseError.js +1 -0
- package/lib/module/purchaseError.js.map +1 -1
- package/lib/typescript/purchaseError.d.ts +2 -1
- package/package.json +1 -1
- package/src/purchaseError.ts +1 -0
package/README.md
CHANGED
|
@@ -34,20 +34,20 @@ Please [fund the project](https://opencollective.com/react-native-iap) if you ar
|
|
|
34
34
|
|
|
35
35
|
## Announcement
|
|
36
36
|
|
|
37
|
-
- Version `
|
|
37
|
+
- Version `11.0.0` is currently in alpha candidate. The module migrates OS sdk to [storekit2](https://developer.apple.com/videos/play/wwdc2021/10114). [andresesfm](https://github.com/andresesfm) is working hard on this.
|
|
38
38
|
|
|
39
39
|
```
|
|
40
40
|
yarn add react-native-iap@next
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
- Version `10.0.0` is a maitenance build. Many internal refactorings and clean up of the code. Special thanks to [jeremybarbet](https://github.com/jeremybarbet) for his contributions. Most notably all methods now take an object parameter instead of separate parameters. Please help us test
|
|
44
|
+
|
|
45
|
+
- Version `9.0.0` The module migrates android sdk to [play billing library v5](https://qonversion.io/blog/google-play-billing-library-5-0). Our core maintainers [andresesfm](https://github.com/andresesfm) and [jeremybarbet](https://github.com/jeremybarbet) worked hard on this.
|
|
46
|
+
|
|
43
47
|
- Version `8.0.0` has finally landed in Jan 28th. Since this is early release, please use it with caution 🚧. We recommend user to use `>=8.0.0` with react-native `>=0.65.1`. The `next` package is no longer updated until we organize the roadmap for `9.0.0`.
|
|
44
48
|
|
|
45
49
|
- Version `8.0.0` is currently in release candidate. The module is completely rewritten with `Kotlin` and `Swift` for maintenenance issue by [andresesfm](https://github.com/andresesfm) 🔆. You may install this for early preview.
|
|
46
50
|
|
|
47
|
-
```
|
|
48
|
-
yarn add react-native-iap@next
|
|
49
|
-
```
|
|
50
|
-
|
|
51
51
|
- React Native IAP hook is out. You can see [medium post](https://medium.com/dooboolab/announcing-react-native-iap-hooks-96c7ffd3f19a) on how to use it.
|
|
52
52
|
|
|
53
53
|
- The `react-native-iap` module hasn't been maintained well recently. We are thinking of participating again and make the module healthier. Please refer to [2021 Maintenance plan](https://github.com/dooboolab/react-native-iap/issues/1241) and share with us how you or your organization is using it. Happy new year 🎉
|
|
@@ -15,6 +15,7 @@ import java.util.HashSet
|
|
|
15
15
|
class RNIapAmazonModule(reactContext: ReactApplicationContext) :
|
|
16
16
|
ReactContextBaseJavaModule(reactContext) {
|
|
17
17
|
var hasListener = false
|
|
18
|
+
private var amazonListener: RNIapAmazonListener? = null
|
|
18
19
|
override fun getName(): String {
|
|
19
20
|
return TAG
|
|
20
21
|
}
|
|
@@ -22,7 +23,9 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
|
|
|
22
23
|
@ReactMethod
|
|
23
24
|
fun initConnection(promise: Promise) {
|
|
24
25
|
val context = reactApplicationContext
|
|
25
|
-
|
|
26
|
+
val amazonListener = RNIapAmazonListener(context)
|
|
27
|
+
this.amazonListener = amazonListener
|
|
28
|
+
PurchasingService.registerListener(context, amazonListener)
|
|
26
29
|
hasListener = true
|
|
27
30
|
// Prefetch user and purchases as per Amazon SDK documentation:
|
|
28
31
|
PurchasingService.getUserData()
|
|
@@ -32,6 +35,9 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
|
|
|
32
35
|
|
|
33
36
|
@ReactMethod
|
|
34
37
|
fun endConnection(promise: Promise) {
|
|
38
|
+
DoobooUtils.instance.rejectAllPendingPromises()
|
|
39
|
+
amazonListener?.clear()
|
|
40
|
+
hasListener = false
|
|
35
41
|
promise.resolve(true)
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -49,6 +49,13 @@ class DoobooUtils {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
fun rejectAllPendingPromises() {
|
|
53
|
+
promises.flatMap { it.value }.forEach { promise ->
|
|
54
|
+
promise.safeReject(E_CONNECTION_CLOSED, "Connection has been closed", null)
|
|
55
|
+
}
|
|
56
|
+
promises.clear()
|
|
57
|
+
}
|
|
58
|
+
|
|
52
59
|
fun rejectPromisesForKey(
|
|
53
60
|
key: String,
|
|
54
61
|
code: String?,
|
|
@@ -175,6 +182,7 @@ class DoobooUtils {
|
|
|
175
182
|
const val E_USER_ERROR = "E_USER_ERROR"
|
|
176
183
|
const val E_DEVELOPER_ERROR = "E_DEVELOPER_ERROR"
|
|
177
184
|
const val E_BILLING_RESPONSE_JSON_PARSE_ERROR = "E_BILLING_RESPONSE_JSON_PARSE_ERROR"
|
|
185
|
+
const val E_CONNECTION_CLOSED = "E_CONNECTION_CLOSED"
|
|
178
186
|
val instance = DoobooUtils()
|
|
179
187
|
}
|
|
180
188
|
}
|
|
@@ -9,11 +9,13 @@ import com.facebook.react.bridge.Promise
|
|
|
9
9
|
* want to crash in the case of it being resolved/rejected more than once
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
const val TAG = "IapPromises"
|
|
13
|
+
|
|
12
14
|
fun Promise.safeResolve(value: Any) {
|
|
13
15
|
try {
|
|
14
16
|
this.resolve(value)
|
|
15
17
|
} catch (oce: ObjectAlreadyConsumedException) {
|
|
16
|
-
Log.d(
|
|
18
|
+
Log.d(TAG, "Already consumed ${oce.message}")
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -28,6 +30,6 @@ fun Promise.safeReject(code: String?, message: String?, throwable: Throwable?) {
|
|
|
28
30
|
try {
|
|
29
31
|
this.reject(code, message, throwable)
|
|
30
32
|
} catch (oce: ObjectAlreadyConsumedException) {
|
|
31
|
-
Log.d(
|
|
33
|
+
Log.d(TAG, "Already consumed ${oce.message}")
|
|
32
34
|
}
|
|
33
35
|
}
|