react-native-iap 15.2.3 → 15.3.0
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 +31 -51
- package/android/build.gradle +92 -22
- package/android/gradle.properties +5 -1
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +24 -8
- package/android/src/main/java/com/margelo/nitro/iap/RnIapLog.kt +3 -1
- package/ios/HybridRnIap.swift +172 -73
- package/lib/module/hooks/useIAP.js +1 -1
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/index.js +138 -165
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts +22 -16
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +61 -90
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +5 -16
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +63 -49
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitro.json +0 -1
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +11 -6
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +2 -2
- package/nitrogen/generated/android/c++/JPurchaseUpdatedListenerOptions.hpp +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +4 -9
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseUpdatedListenerOptions.kt +38 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +9 -4
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +2 -2
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +8 -12
- package/nitrogen/generated/ios/swift/PurchaseUpdatedListenerOptions.swift +61 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +5 -2
- package/nitrogen/generated/shared/c++/PurchaseUpdatedListenerOptions.hpp +85 -0
- package/openiap-versions.json +3 -3
- package/package.json +4 -6
- package/src/hooks/useIAP.ts +23 -15
- package/src/index.ts +198 -215
- package/src/specs/RnIap.nitro.ts +10 -18
- package/src/types.ts +66 -49
package/nitro.json
CHANGED
|
@@ -125,6 +125,8 @@ namespace margelo::nitro::iap { struct NitroFinishTransactionParams; }
|
|
|
125
125
|
namespace margelo::nitro::iap { struct NitroFinishTransactionIosParams; }
|
|
126
126
|
// Forward declaration of `NitroFinishTransactionAndroidParams` to properly resolve imports.
|
|
127
127
|
namespace margelo::nitro::iap { struct NitroFinishTransactionAndroidParams; }
|
|
128
|
+
// Forward declaration of `PurchaseUpdatedListenerOptions` to properly resolve imports.
|
|
129
|
+
namespace margelo::nitro::iap { struct PurchaseUpdatedListenerOptions; }
|
|
128
130
|
// Forward declaration of `NitroReceiptValidationParams` to properly resolve imports.
|
|
129
131
|
namespace margelo::nitro::iap { struct NitroReceiptValidationParams; }
|
|
130
132
|
// Forward declaration of `NitroReceiptValidationAppleOptions` to properly resolve imports.
|
|
@@ -329,6 +331,8 @@ namespace margelo::nitro::iap { enum class ExternalPurchaseCustomLinkNoticeTypeI
|
|
|
329
331
|
#include <functional>
|
|
330
332
|
#include "JFunc_void_NitroPurchase.hpp"
|
|
331
333
|
#include <NitroModules/JNICallable.hpp>
|
|
334
|
+
#include "PurchaseUpdatedListenerOptions.hpp"
|
|
335
|
+
#include "JPurchaseUpdatedListenerOptions.hpp"
|
|
332
336
|
#include "JFunc_void_NitroPurchaseResult.hpp"
|
|
333
337
|
#include "JFunc_void_NitroProduct.hpp"
|
|
334
338
|
#include "NitroReceiptValidationParams.hpp"
|
|
@@ -587,17 +591,18 @@ namespace margelo::nitro::iap {
|
|
|
587
591
|
return __promise;
|
|
588
592
|
}();
|
|
589
593
|
}
|
|
590
|
-
|
|
591
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<
|
|
592
|
-
method(_javaPart, JFunc_void_NitroPurchase_cxx::fromCpp(listener));
|
|
594
|
+
double JHybridRnIapSpec::addPurchaseUpdatedListener(const std::function<void(const NitroPurchase& /* purchase */)>& listener, const std::optional<PurchaseUpdatedListenerOptions>& options) {
|
|
595
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<double(jni::alias_ref<JFunc_void_NitroPurchase::javaobject> /* listener */, jni::alias_ref<JPurchaseUpdatedListenerOptions> /* options */)>("addPurchaseUpdatedListener_cxx");
|
|
596
|
+
auto __result = method(_javaPart, JFunc_void_NitroPurchase_cxx::fromCpp(listener), options.has_value() ? JPurchaseUpdatedListenerOptions::fromCpp(options.value()) : nullptr);
|
|
597
|
+
return __result;
|
|
593
598
|
}
|
|
594
599
|
void JHybridRnIapSpec::addPurchaseErrorListener(const std::function<void(const NitroPurchaseResult& /* error */)>& listener) {
|
|
595
600
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_NitroPurchaseResult::javaobject> /* listener */)>("addPurchaseErrorListener_cxx");
|
|
596
601
|
method(_javaPart, JFunc_void_NitroPurchaseResult_cxx::fromCpp(listener));
|
|
597
602
|
}
|
|
598
|
-
void JHybridRnIapSpec::removePurchaseUpdatedListener(
|
|
599
|
-
static const auto method = _javaPart->javaClassStatic()->getMethod<void(
|
|
600
|
-
method(_javaPart,
|
|
603
|
+
void JHybridRnIapSpec::removePurchaseUpdatedListener(double token) {
|
|
604
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* token */)>("removePurchaseUpdatedListener");
|
|
605
|
+
method(_javaPart, token);
|
|
601
606
|
}
|
|
602
607
|
void JHybridRnIapSpec::removePurchaseErrorListener(const std::function<void(const NitroPurchaseResult& /* error */)>& listener) {
|
|
603
608
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_NitroPurchaseResult::javaobject> /* listener */)>("removePurchaseErrorListener_cxx");
|
|
@@ -62,9 +62,9 @@ namespace margelo::nitro::iap {
|
|
|
62
62
|
std::shared_ptr<Promise<std::vector<NitroActiveSubscription>>> getActiveSubscriptions(const std::optional<std::vector<std::string>>& subscriptionIds) override;
|
|
63
63
|
std::shared_ptr<Promise<bool>> hasActiveSubscriptions(const std::optional<std::vector<std::string>>& subscriptionIds) override;
|
|
64
64
|
std::shared_ptr<Promise<std::variant<bool, NitroPurchaseResult>>> finishTransaction(const NitroFinishTransactionParams& params) override;
|
|
65
|
-
|
|
65
|
+
double addPurchaseUpdatedListener(const std::function<void(const NitroPurchase& /* purchase */)>& listener, const std::optional<PurchaseUpdatedListenerOptions>& options) override;
|
|
66
66
|
void addPurchaseErrorListener(const std::function<void(const NitroPurchaseResult& /* error */)>& listener) override;
|
|
67
|
-
void removePurchaseUpdatedListener(
|
|
67
|
+
void removePurchaseUpdatedListener(double token) override;
|
|
68
68
|
void removePurchaseErrorListener(const std::function<void(const NitroPurchaseResult& /* error */)>& listener) override;
|
|
69
69
|
void addPromotedProductListenerIOS(const std::function<void(const NitroProduct& /* product */)>& listener) override;
|
|
70
70
|
void removePromotedProductListenerIOS(const std::function<void(const NitroProduct& /* product */)>& listener) override;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JPurchaseUpdatedListenerOptions.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "PurchaseUpdatedListenerOptions.hpp"
|
|
12
|
+
|
|
13
|
+
#include "JVariant_NullType_Boolean.hpp"
|
|
14
|
+
#include <NitroModules/JNull.hpp>
|
|
15
|
+
#include <NitroModules/Null.hpp>
|
|
16
|
+
#include <optional>
|
|
17
|
+
#include <variant>
|
|
18
|
+
|
|
19
|
+
namespace margelo::nitro::iap {
|
|
20
|
+
|
|
21
|
+
using namespace facebook;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The C++ JNI bridge between the C++ struct "PurchaseUpdatedListenerOptions" and the the Kotlin data class "PurchaseUpdatedListenerOptions".
|
|
25
|
+
*/
|
|
26
|
+
struct JPurchaseUpdatedListenerOptions final: public jni::JavaClass<JPurchaseUpdatedListenerOptions> {
|
|
27
|
+
public:
|
|
28
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/PurchaseUpdatedListenerOptions;";
|
|
29
|
+
|
|
30
|
+
public:
|
|
31
|
+
/**
|
|
32
|
+
* Convert this Java/Kotlin-based struct to the C++ struct PurchaseUpdatedListenerOptions by copying all values to C++.
|
|
33
|
+
*/
|
|
34
|
+
[[maybe_unused]]
|
|
35
|
+
[[nodiscard]]
|
|
36
|
+
PurchaseUpdatedListenerOptions toCpp() const {
|
|
37
|
+
static const auto clazz = javaClassStatic();
|
|
38
|
+
static const auto fieldDedupeTransactionIOS = clazz->getField<JVariant_NullType_Boolean>("dedupeTransactionIOS");
|
|
39
|
+
jni::local_ref<JVariant_NullType_Boolean> dedupeTransactionIOS = this->getFieldValue(fieldDedupeTransactionIOS);
|
|
40
|
+
return PurchaseUpdatedListenerOptions(
|
|
41
|
+
dedupeTransactionIOS != nullptr ? std::make_optional(dedupeTransactionIOS->toCpp()) : std::nullopt
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
/**
|
|
47
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
48
|
+
*/
|
|
49
|
+
[[maybe_unused]]
|
|
50
|
+
static jni::local_ref<JPurchaseUpdatedListenerOptions::javaobject> fromCpp(const PurchaseUpdatedListenerOptions& value) {
|
|
51
|
+
using JSignature = JPurchaseUpdatedListenerOptions(jni::alias_ref<JVariant_NullType_Boolean>);
|
|
52
|
+
static const auto clazz = javaClassStatic();
|
|
53
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
54
|
+
return create(
|
|
55
|
+
clazz,
|
|
56
|
+
value.dedupeTransactionIOS.has_value() ? JVariant_NullType_Boolean::fromCpp(value.dedupeTransactionIOS.value()) : nullptr
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::iap
|
|
@@ -62,12 +62,12 @@ abstract class HybridRnIapSpec: HybridObject() {
|
|
|
62
62
|
@Keep
|
|
63
63
|
abstract fun finishTransaction(params: NitroFinishTransactionParams): Promise<Variant_Boolean_NitroPurchaseResult>
|
|
64
64
|
|
|
65
|
-
abstract fun addPurchaseUpdatedListener(listener: (purchase: NitroPurchase) -> Unit):
|
|
65
|
+
abstract fun addPurchaseUpdatedListener(listener: (purchase: NitroPurchase) -> Unit, options: PurchaseUpdatedListenerOptions?): Double
|
|
66
66
|
|
|
67
67
|
@DoNotStrip
|
|
68
68
|
@Keep
|
|
69
|
-
private fun addPurchaseUpdatedListener_cxx(listener: Func_void_NitroPurchase):
|
|
70
|
-
val __result = addPurchaseUpdatedListener(listener)
|
|
69
|
+
private fun addPurchaseUpdatedListener_cxx(listener: Func_void_NitroPurchase, options: PurchaseUpdatedListenerOptions?): Double {
|
|
70
|
+
val __result = addPurchaseUpdatedListener(listener, options)
|
|
71
71
|
return __result
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -80,14 +80,9 @@ abstract class HybridRnIapSpec: HybridObject() {
|
|
|
80
80
|
return __result
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
abstract fun removePurchaseUpdatedListener(listener: (purchase: NitroPurchase) -> Unit): Unit
|
|
84
|
-
|
|
85
83
|
@DoNotStrip
|
|
86
84
|
@Keep
|
|
87
|
-
|
|
88
|
-
val __result = removePurchaseUpdatedListener(listener)
|
|
89
|
-
return __result
|
|
90
|
-
}
|
|
85
|
+
abstract fun removePurchaseUpdatedListener(token: Double): Unit
|
|
91
86
|
|
|
92
87
|
abstract fun removePurchaseErrorListener(listener: (error: NitroPurchaseResult) -> Unit): Unit
|
|
93
88
|
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseUpdatedListenerOptions.kt
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PurchaseUpdatedListenerOptions.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.iap
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import com.margelo.nitro.core.NullType
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "PurchaseUpdatedListenerOptions".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class PurchaseUpdatedListenerOptions(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val dedupeTransactionIOS: Variant_NullType_Boolean?
|
|
23
|
+
) {
|
|
24
|
+
/* primary constructor */
|
|
25
|
+
|
|
26
|
+
companion object {
|
|
27
|
+
/**
|
|
28
|
+
* Constructor called from C++
|
|
29
|
+
*/
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
@Suppress("unused")
|
|
33
|
+
@JvmStatic
|
|
34
|
+
private fun fromCpp(dedupeTransactionIOS: Variant_NullType_Boolean?): PurchaseUpdatedListenerOptions {
|
|
35
|
+
return PurchaseUpdatedListenerOptions(dedupeTransactionIOS)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -128,6 +128,8 @@ namespace margelo::nitro::iap { struct PurchaseIOS; }
|
|
|
128
128
|
namespace margelo::nitro::iap { struct PurchaseOfferIOS; }
|
|
129
129
|
// Forward declaration of `PurchaseState` to properly resolve imports.
|
|
130
130
|
namespace margelo::nitro::iap { enum class PurchaseState; }
|
|
131
|
+
// Forward declaration of `PurchaseUpdatedListenerOptions` to properly resolve imports.
|
|
132
|
+
namespace margelo::nitro::iap { struct PurchaseUpdatedListenerOptions; }
|
|
131
133
|
// Forward declaration of `PurchaseVerificationProvider` to properly resolve imports.
|
|
132
134
|
namespace margelo::nitro::iap { enum class PurchaseVerificationProvider; }
|
|
133
135
|
// Forward declaration of `RenewalInfoIOS` to properly resolve imports.
|
|
@@ -206,6 +208,7 @@ namespace NitroIap { class HybridRnIapSpec_cxx; }
|
|
|
206
208
|
#include "PurchaseIOS.hpp"
|
|
207
209
|
#include "PurchaseOfferIOS.hpp"
|
|
208
210
|
#include "PurchaseState.hpp"
|
|
211
|
+
#include "PurchaseUpdatedListenerOptions.hpp"
|
|
209
212
|
#include "PurchaseVerificationProvider.hpp"
|
|
210
213
|
#include "RenewalInfoIOS.hpp"
|
|
211
214
|
#include "SubscriptionProductReplacementParamsAndroid.hpp"
|
|
@@ -2112,6 +2115,21 @@ namespace margelo::nitro::iap::bridge::swift {
|
|
|
2112
2115
|
return Func_void_NitroPurchase_Wrapper(std::move(value));
|
|
2113
2116
|
}
|
|
2114
2117
|
|
|
2118
|
+
// pragma MARK: std::optional<PurchaseUpdatedListenerOptions>
|
|
2119
|
+
/**
|
|
2120
|
+
* Specialized version of `std::optional<PurchaseUpdatedListenerOptions>`.
|
|
2121
|
+
*/
|
|
2122
|
+
using std__optional_PurchaseUpdatedListenerOptions_ = std::optional<PurchaseUpdatedListenerOptions>;
|
|
2123
|
+
inline std::optional<PurchaseUpdatedListenerOptions> create_std__optional_PurchaseUpdatedListenerOptions_(const PurchaseUpdatedListenerOptions& value) noexcept {
|
|
2124
|
+
return std::optional<PurchaseUpdatedListenerOptions>(value);
|
|
2125
|
+
}
|
|
2126
|
+
inline bool has_value_std__optional_PurchaseUpdatedListenerOptions_(const std::optional<PurchaseUpdatedListenerOptions>& optional) noexcept {
|
|
2127
|
+
return optional.has_value();
|
|
2128
|
+
}
|
|
2129
|
+
inline PurchaseUpdatedListenerOptions get_std__optional_PurchaseUpdatedListenerOptions_(const std::optional<PurchaseUpdatedListenerOptions>& optional) noexcept {
|
|
2130
|
+
return optional.value();
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2115
2133
|
// pragma MARK: std::function<void(const NitroPurchaseResult& /* error */)>
|
|
2116
2134
|
/**
|
|
2117
2135
|
* Specialized version of `std::function<void(const NitroPurchaseResult&)>`.
|
|
@@ -3291,6 +3309,15 @@ namespace margelo::nitro::iap::bridge::swift {
|
|
|
3291
3309
|
return Result<std::shared_ptr<Promise<std::variant<bool, NitroPurchaseResult>>>>::withError(error);
|
|
3292
3310
|
}
|
|
3293
3311
|
|
|
3312
|
+
// pragma MARK: Result<double>
|
|
3313
|
+
using Result_double_ = Result<double>;
|
|
3314
|
+
inline Result_double_ create_Result_double_(double value) noexcept {
|
|
3315
|
+
return Result<double>::withValue(std::move(value));
|
|
3316
|
+
}
|
|
3317
|
+
inline Result_double_ create_Result_double_(const std::exception_ptr& error) noexcept {
|
|
3318
|
+
return Result<double>::withError(error);
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3294
3321
|
// pragma MARK: Result<void>
|
|
3295
3322
|
using Result_void_ = Result<void>;
|
|
3296
3323
|
inline Result_void_ create_Result_void_() noexcept {
|
|
@@ -148,6 +148,8 @@ namespace margelo::nitro::iap { struct PurchaseIOS; }
|
|
|
148
148
|
namespace margelo::nitro::iap { struct PurchaseOfferIOS; }
|
|
149
149
|
// Forward declaration of `PurchaseState` to properly resolve imports.
|
|
150
150
|
namespace margelo::nitro::iap { enum class PurchaseState; }
|
|
151
|
+
// Forward declaration of `PurchaseUpdatedListenerOptions` to properly resolve imports.
|
|
152
|
+
namespace margelo::nitro::iap { struct PurchaseUpdatedListenerOptions; }
|
|
151
153
|
// Forward declaration of `PurchaseVerificationProvider` to properly resolve imports.
|
|
152
154
|
namespace margelo::nitro::iap { enum class PurchaseVerificationProvider; }
|
|
153
155
|
// Forward declaration of `RenewalInfoIOS` to properly resolve imports.
|
|
@@ -232,6 +234,7 @@ namespace margelo::nitro::iap { struct WinBackOfferInputIOS; }
|
|
|
232
234
|
#include "PurchaseIOS.hpp"
|
|
233
235
|
#include "PurchaseOfferIOS.hpp"
|
|
234
236
|
#include "PurchaseState.hpp"
|
|
237
|
+
#include "PurchaseUpdatedListenerOptions.hpp"
|
|
235
238
|
#include "PurchaseVerificationProvider.hpp"
|
|
236
239
|
#include "RenewalInfoIOS.hpp"
|
|
237
240
|
#include "SubscriptionProductReplacementParamsAndroid.hpp"
|
|
@@ -98,6 +98,8 @@ namespace margelo::nitro::iap { struct NitroFinishTransactionParams; }
|
|
|
98
98
|
namespace margelo::nitro::iap { struct NitroFinishTransactionIosParams; }
|
|
99
99
|
// Forward declaration of `NitroFinishTransactionAndroidParams` to properly resolve imports.
|
|
100
100
|
namespace margelo::nitro::iap { struct NitroFinishTransactionAndroidParams; }
|
|
101
|
+
// Forward declaration of `PurchaseUpdatedListenerOptions` to properly resolve imports.
|
|
102
|
+
namespace margelo::nitro::iap { struct PurchaseUpdatedListenerOptions; }
|
|
101
103
|
// Forward declaration of `NitroSubscriptionStatus` to properly resolve imports.
|
|
102
104
|
namespace margelo::nitro::iap { struct NitroSubscriptionStatus; }
|
|
103
105
|
// Forward declaration of `NitroSubscriptionRenewalInfo` to properly resolve imports.
|
|
@@ -214,6 +216,7 @@ namespace margelo::nitro::iap { enum class ExternalPurchaseCustomLinkNoticeTypeI
|
|
|
214
216
|
#include "NitroFinishTransactionIosParams.hpp"
|
|
215
217
|
#include "NitroFinishTransactionAndroidParams.hpp"
|
|
216
218
|
#include <functional>
|
|
219
|
+
#include "PurchaseUpdatedListenerOptions.hpp"
|
|
217
220
|
#include "NitroSubscriptionStatus.hpp"
|
|
218
221
|
#include "NitroSubscriptionRenewalInfo.hpp"
|
|
219
222
|
#include "NitroReceiptValidationResultIOS.hpp"
|
|
@@ -361,11 +364,13 @@ namespace margelo::nitro::iap {
|
|
|
361
364
|
auto __value = std::move(__result.value());
|
|
362
365
|
return __value;
|
|
363
366
|
}
|
|
364
|
-
inline
|
|
365
|
-
auto __result = _swiftPart.addPurchaseUpdatedListener(listener);
|
|
367
|
+
inline double addPurchaseUpdatedListener(const std::function<void(const NitroPurchase& /* purchase */)>& listener, const std::optional<PurchaseUpdatedListenerOptions>& options) override {
|
|
368
|
+
auto __result = _swiftPart.addPurchaseUpdatedListener(listener, options);
|
|
366
369
|
if (__result.hasError()) [[unlikely]] {
|
|
367
370
|
std::rethrow_exception(__result.error());
|
|
368
371
|
}
|
|
372
|
+
auto __value = std::move(__result.value());
|
|
373
|
+
return __value;
|
|
369
374
|
}
|
|
370
375
|
inline void addPurchaseErrorListener(const std::function<void(const NitroPurchaseResult& /* error */)>& listener) override {
|
|
371
376
|
auto __result = _swiftPart.addPurchaseErrorListener(listener);
|
|
@@ -373,8 +378,8 @@ namespace margelo::nitro::iap {
|
|
|
373
378
|
std::rethrow_exception(__result.error());
|
|
374
379
|
}
|
|
375
380
|
}
|
|
376
|
-
inline void removePurchaseUpdatedListener(
|
|
377
|
-
auto __result = _swiftPart.removePurchaseUpdatedListener(
|
|
381
|
+
inline void removePurchaseUpdatedListener(double token) override {
|
|
382
|
+
auto __result = _swiftPart.removePurchaseUpdatedListener(std::forward<decltype(token)>(token));
|
|
378
383
|
if (__result.hasError()) [[unlikely]] {
|
|
379
384
|
std::rethrow_exception(__result.error());
|
|
380
385
|
}
|
|
@@ -21,9 +21,9 @@ public protocol HybridRnIapSpec_protocol: HybridObject {
|
|
|
21
21
|
func getActiveSubscriptions(subscriptionIds: [String]?) throws -> Promise<[NitroActiveSubscription]>
|
|
22
22
|
func hasActiveSubscriptions(subscriptionIds: [String]?) throws -> Promise<Bool>
|
|
23
23
|
func finishTransaction(params: NitroFinishTransactionParams) throws -> Promise<Variant_Bool_NitroPurchaseResult>
|
|
24
|
-
func addPurchaseUpdatedListener(listener: @escaping (_ purchase: NitroPurchase) -> Void) throws ->
|
|
24
|
+
func addPurchaseUpdatedListener(listener: @escaping (_ purchase: NitroPurchase) -> Void, options: PurchaseUpdatedListenerOptions?) throws -> Double
|
|
25
25
|
func addPurchaseErrorListener(listener: @escaping (_ error: NitroPurchaseResult) -> Void) throws -> Void
|
|
26
|
-
func removePurchaseUpdatedListener(
|
|
26
|
+
func removePurchaseUpdatedListener(token: Double) throws -> Void
|
|
27
27
|
func removePurchaseErrorListener(listener: @escaping (_ error: NitroPurchaseResult) -> Void) throws -> Void
|
|
28
28
|
func addPromotedProductListenerIOS(listener: @escaping (_ product: NitroProduct) -> Void) throws -> Void
|
|
29
29
|
func removePromotedProductListenerIOS(listener: @escaping (_ product: NitroProduct) -> Void) throws -> Void
|
|
@@ -359,18 +359,19 @@ open class HybridRnIapSpec_cxx {
|
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
@inline(__always)
|
|
362
|
-
public final func addPurchaseUpdatedListener(listener: bridge.Func_void_NitroPurchase) -> bridge.
|
|
362
|
+
public final func addPurchaseUpdatedListener(listener: bridge.Func_void_NitroPurchase, options: bridge.std__optional_PurchaseUpdatedListenerOptions_) -> bridge.Result_double_ {
|
|
363
363
|
do {
|
|
364
|
-
try self.__implementation.addPurchaseUpdatedListener(listener: { () -> (NitroPurchase) -> Void in
|
|
364
|
+
let __result = try self.__implementation.addPurchaseUpdatedListener(listener: { () -> (NitroPurchase) -> Void in
|
|
365
365
|
let __wrappedFunction = bridge.wrap_Func_void_NitroPurchase(listener)
|
|
366
366
|
return { (__purchase: NitroPurchase) -> Void in
|
|
367
367
|
__wrappedFunction.call(__purchase)
|
|
368
368
|
}
|
|
369
|
-
}())
|
|
370
|
-
|
|
369
|
+
}(), options: options.value)
|
|
370
|
+
let __resultCpp = __result
|
|
371
|
+
return bridge.create_Result_double_(__resultCpp)
|
|
371
372
|
} catch (let __error) {
|
|
372
373
|
let __exceptionPtr = __error.toCpp()
|
|
373
|
-
return bridge.
|
|
374
|
+
return bridge.create_Result_double_(__exceptionPtr)
|
|
374
375
|
}
|
|
375
376
|
}
|
|
376
377
|
|
|
@@ -391,14 +392,9 @@ open class HybridRnIapSpec_cxx {
|
|
|
391
392
|
}
|
|
392
393
|
|
|
393
394
|
@inline(__always)
|
|
394
|
-
public final func removePurchaseUpdatedListener(
|
|
395
|
+
public final func removePurchaseUpdatedListener(token: Double) -> bridge.Result_void_ {
|
|
395
396
|
do {
|
|
396
|
-
try self.__implementation.removePurchaseUpdatedListener(
|
|
397
|
-
let __wrappedFunction = bridge.wrap_Func_void_NitroPurchase(listener)
|
|
398
|
-
return { (__purchase: NitroPurchase) -> Void in
|
|
399
|
-
__wrappedFunction.call(__purchase)
|
|
400
|
-
}
|
|
401
|
-
}())
|
|
397
|
+
try self.__implementation.removePurchaseUpdatedListener(token: token)
|
|
402
398
|
return bridge.create_Result_void_()
|
|
403
399
|
} catch (let __error) {
|
|
404
400
|
let __exceptionPtr = __error.toCpp()
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PurchaseUpdatedListenerOptions.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `PurchaseUpdatedListenerOptions`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias PurchaseUpdatedListenerOptions = margelo.nitro.iap.PurchaseUpdatedListenerOptions
|
|
14
|
+
|
|
15
|
+
public extension PurchaseUpdatedListenerOptions {
|
|
16
|
+
private typealias bridge = margelo.nitro.iap.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `PurchaseUpdatedListenerOptions`.
|
|
20
|
+
*/
|
|
21
|
+
init(dedupeTransactionIOS: Variant_NullType_Bool?) {
|
|
22
|
+
self.init({ () -> bridge.std__optional_std__variant_nitro__NullType__bool__ in
|
|
23
|
+
if let __unwrappedValue = dedupeTransactionIOS {
|
|
24
|
+
return bridge.create_std__optional_std__variant_nitro__NullType__bool__({ () -> bridge.std__variant_nitro__NullType__bool_ in
|
|
25
|
+
switch __unwrappedValue {
|
|
26
|
+
case .first(let __value):
|
|
27
|
+
return bridge.create_std__variant_nitro__NullType__bool_(margelo.nitro.NullType.null)
|
|
28
|
+
case .second(let __value):
|
|
29
|
+
return bridge.create_std__variant_nitro__NullType__bool_(__value)
|
|
30
|
+
}
|
|
31
|
+
}().variant)
|
|
32
|
+
} else {
|
|
33
|
+
return .init()
|
|
34
|
+
}
|
|
35
|
+
}())
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@inline(__always)
|
|
39
|
+
var dedupeTransactionIOS: Variant_NullType_Bool? {
|
|
40
|
+
return { () -> Variant_NullType_Bool? in
|
|
41
|
+
if bridge.has_value_std__optional_std__variant_nitro__NullType__bool__(self.__dedupeTransactionIOS) {
|
|
42
|
+
let __unwrapped = bridge.get_std__optional_std__variant_nitro__NullType__bool__(self.__dedupeTransactionIOS)
|
|
43
|
+
return { () -> Variant_NullType_Bool in
|
|
44
|
+
let __variant = bridge.std__variant_nitro__NullType__bool_(__unwrapped)
|
|
45
|
+
switch __variant.index() {
|
|
46
|
+
case 0:
|
|
47
|
+
let __actual = __variant.get_0()
|
|
48
|
+
return .first(NullType.null)
|
|
49
|
+
case 1:
|
|
50
|
+
let __actual = __variant.get_1()
|
|
51
|
+
return .second(__actual)
|
|
52
|
+
default:
|
|
53
|
+
fatalError("Variant can never have index \(__variant.index())!")
|
|
54
|
+
}
|
|
55
|
+
}()
|
|
56
|
+
} else {
|
|
57
|
+
return nil
|
|
58
|
+
}
|
|
59
|
+
}()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -33,6 +33,8 @@ namespace margelo::nitro::iap { struct NitroActiveSubscription; }
|
|
|
33
33
|
namespace margelo::nitro::iap { struct NitroPurchaseResult; }
|
|
34
34
|
// Forward declaration of `NitroFinishTransactionParams` to properly resolve imports.
|
|
35
35
|
namespace margelo::nitro::iap { struct NitroFinishTransactionParams; }
|
|
36
|
+
// Forward declaration of `PurchaseUpdatedListenerOptions` to properly resolve imports.
|
|
37
|
+
namespace margelo::nitro::iap { struct PurchaseUpdatedListenerOptions; }
|
|
36
38
|
// Forward declaration of `NitroSubscriptionStatus` to properly resolve imports.
|
|
37
39
|
namespace margelo::nitro::iap { struct NitroSubscriptionStatus; }
|
|
38
40
|
// Forward declaration of `NitroReceiptValidationResultIOS` to properly resolve imports.
|
|
@@ -89,6 +91,7 @@ namespace margelo::nitro::iap { enum class ExternalPurchaseCustomLinkNoticeTypeI
|
|
|
89
91
|
#include "NitroPurchaseResult.hpp"
|
|
90
92
|
#include "NitroFinishTransactionParams.hpp"
|
|
91
93
|
#include <functional>
|
|
94
|
+
#include "PurchaseUpdatedListenerOptions.hpp"
|
|
92
95
|
#include "NitroSubscriptionStatus.hpp"
|
|
93
96
|
#include "NitroReceiptValidationResultIOS.hpp"
|
|
94
97
|
#include "NitroReceiptValidationResultAndroid.hpp"
|
|
@@ -148,9 +151,9 @@ namespace margelo::nitro::iap {
|
|
|
148
151
|
virtual std::shared_ptr<Promise<std::vector<NitroActiveSubscription>>> getActiveSubscriptions(const std::optional<std::vector<std::string>>& subscriptionIds) = 0;
|
|
149
152
|
virtual std::shared_ptr<Promise<bool>> hasActiveSubscriptions(const std::optional<std::vector<std::string>>& subscriptionIds) = 0;
|
|
150
153
|
virtual std::shared_ptr<Promise<std::variant<bool, NitroPurchaseResult>>> finishTransaction(const NitroFinishTransactionParams& params) = 0;
|
|
151
|
-
virtual
|
|
154
|
+
virtual double addPurchaseUpdatedListener(const std::function<void(const NitroPurchase& /* purchase */)>& listener, const std::optional<PurchaseUpdatedListenerOptions>& options) = 0;
|
|
152
155
|
virtual void addPurchaseErrorListener(const std::function<void(const NitroPurchaseResult& /* error */)>& listener) = 0;
|
|
153
|
-
virtual void removePurchaseUpdatedListener(
|
|
156
|
+
virtual void removePurchaseUpdatedListener(double token) = 0;
|
|
154
157
|
virtual void removePurchaseErrorListener(const std::function<void(const NitroPurchaseResult& /* error */)>& listener) = 0;
|
|
155
158
|
virtual void addPromotedProductListenerIOS(const std::function<void(const NitroProduct& /* product */)>& listener) = 0;
|
|
156
159
|
virtual void removePromotedProductListenerIOS(const std::function<void(const NitroProduct& /* product */)>& listener) = 0;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PurchaseUpdatedListenerOptions.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#include <NitroModules/Null.hpp>
|
|
34
|
+
#include <variant>
|
|
35
|
+
#include <optional>
|
|
36
|
+
|
|
37
|
+
namespace margelo::nitro::iap {
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A struct which can be represented as a JavaScript object (PurchaseUpdatedListenerOptions).
|
|
41
|
+
*/
|
|
42
|
+
struct PurchaseUpdatedListenerOptions final {
|
|
43
|
+
public:
|
|
44
|
+
std::optional<std::variant<nitro::NullType, bool>> dedupeTransactionIOS SWIFT_PRIVATE;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
PurchaseUpdatedListenerOptions() = default;
|
|
48
|
+
explicit PurchaseUpdatedListenerOptions(std::optional<std::variant<nitro::NullType, bool>> dedupeTransactionIOS): dedupeTransactionIOS(dedupeTransactionIOS) {}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
friend bool operator==(const PurchaseUpdatedListenerOptions& lhs, const PurchaseUpdatedListenerOptions& rhs) = default;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
} // namespace margelo::nitro::iap
|
|
55
|
+
|
|
56
|
+
namespace margelo::nitro {
|
|
57
|
+
|
|
58
|
+
// C++ PurchaseUpdatedListenerOptions <> JS PurchaseUpdatedListenerOptions (object)
|
|
59
|
+
template <>
|
|
60
|
+
struct JSIConverter<margelo::nitro::iap::PurchaseUpdatedListenerOptions> final {
|
|
61
|
+
static inline margelo::nitro::iap::PurchaseUpdatedListenerOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
62
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
63
|
+
return margelo::nitro::iap::PurchaseUpdatedListenerOptions(
|
|
64
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dedupeTransactionIOS")))
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::PurchaseUpdatedListenerOptions& arg) {
|
|
68
|
+
jsi::Object obj(runtime);
|
|
69
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "dedupeTransactionIOS"), JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::toJSI(runtime, arg.dedupeTransactionIOS));
|
|
70
|
+
return obj;
|
|
71
|
+
}
|
|
72
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
73
|
+
if (!value.isObject()) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
jsi::Object obj = value.getObject(runtime);
|
|
77
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dedupeTransactionIOS")))) return false;
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
} // namespace margelo::nitro
|
package/openiap-versions.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-iap",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.3.0",
|
|
4
4
|
"description": "React Native In-App Purchases module for iOS and Android using Nitro",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -41,18 +41,16 @@
|
|
|
41
41
|
],
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build:plugin": "tsc --build plugin",
|
|
44
|
-
"setup:expo": "cd example-expo && bun setup",
|
|
45
44
|
"example": "yarn workspace rn-iap-example",
|
|
46
45
|
"example:ios": "yarn workspace rn-iap-example ios",
|
|
47
46
|
"example:android": "yarn workspace rn-iap-example android",
|
|
48
47
|
"example:start": "yarn workspace rn-iap-example start",
|
|
49
|
-
"typecheck": "yarn typecheck:lib
|
|
48
|
+
"typecheck": "yarn typecheck:lib",
|
|
50
49
|
"typecheck:lib": "yarn tsc --noEmit",
|
|
51
|
-
"typecheck:expo": "cd example-expo && bun run typecheck",
|
|
52
50
|
"clean": "rm -rf android/build node_modules/**/android/build lib nitrogen/generated",
|
|
53
51
|
"lint": "eslint --ext .ts,.tsx,.js,.jsx src",
|
|
54
52
|
"lint:eslint": "eslint --fix 'src/**/*.{ts,tsx}' 'plugin/src/**/*.{ts,tsx}'",
|
|
55
|
-
"lint:prettier": "prettier --write \"**/*.{md,js,jsx,ts,tsx}\"
|
|
53
|
+
"lint:prettier": "prettier --write \"**/*.{md,js,jsx,ts,tsx}\"",
|
|
56
54
|
"lint:tsc": "tsc -p tsconfig.json --noEmit --skipLibCheck",
|
|
57
55
|
"lint:ci": "yarn lint:tsc && yarn lint:eslint && yarn lint:prettier",
|
|
58
56
|
"prepare": "npx tsx scripts/check-nitro-versions.ts && bob build && yarn nitrogen && yarn build:plugin",
|
|
@@ -61,7 +59,7 @@
|
|
|
61
59
|
"test": "jest --coverage",
|
|
62
60
|
"test:library": "jest --coverage",
|
|
63
61
|
"test:example": "yarn workspace rn-iap-example test --coverage",
|
|
64
|
-
"test:plugin": "
|
|
62
|
+
"test:plugin": "jest plugin --coverage",
|
|
65
63
|
"test:all": "yarn test:library && yarn test:example",
|
|
66
64
|
"test:ci": "jest --maxWorkers=2 --coverage",
|
|
67
65
|
"test:ci:example": "yarn workspace rn-iap-example test --coverage",
|