react-native-iap 15.4.0-rc.3 → 15.4.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 +23 -25
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +250 -168
- package/android/src/main/java/com/margelo/nitro/iap/ProductSerialization.kt +98 -0
- package/ios/HybridRnIap.swift +19 -1
- package/ios/RnIapHelper.swift +30 -2
- package/lib/module/hooks/useIAP.js +19 -3
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/index.js +104 -18
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.kepler.js +3 -0
- package/lib/module/index.kepler.js.map +1 -1
- package/lib/module/types.js +67 -6
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/type-bridge.js +22 -3
- package/lib/module/utils/type-bridge.js.map +1 -1
- package/lib/module/vega-adapter.js +24 -2
- package/lib/module/vega-adapter.js.map +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts +25 -2
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +50 -10
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.kepler.d.ts +3 -0
- package/lib/typescript/src/index.kepler.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +79 -9
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +223 -35
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -1
- package/lib/typescript/src/vega-adapter.d.ts.map +1 -1
- package/nitrogen/generated/android/NitroIap+autolinking.cmake +3 -0
- package/nitrogen/generated/android/c++/JBillingChoiceImageLayoutAndroid.hpp +61 -0
- package/nitrogen/generated/android/c++/JBillingChoiceScreenTypeAndroid.hpp +61 -0
- package/nitrogen/generated/android/c++/JBillingProgramAndroid.hpp +3 -0
- package/nitrogen/generated/android/c++/JDeveloperBillingLaunchModeAndroid.hpp +61 -0
- package/nitrogen/generated/android/c++/JDeveloperBillingOptionParamsAndroid.hpp +78 -0
- package/nitrogen/generated/android/c++/JDeveloperBillingTypeAndroid.hpp +61 -0
- package/nitrogen/generated/android/c++/JDeveloperProvidedBillingDetailsAndroid.hpp +45 -5
- package/nitrogen/generated/android/c++/JDeveloperProvidedBillingProductAndroid.hpp +72 -0
- package/nitrogen/generated/android/c++/JFunc_void_DeveloperProvidedBillingDetailsAndroid.hpp +10 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +118 -3
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +4 -1
- package/nitrogen/generated/android/c++/JInAppMessageCategoryAndroid.hpp +58 -0
- package/nitrogen/generated/android/c++/JInAppMessageResponseCodeAndroid.hpp +58 -0
- package/nitrogen/generated/android/c++/JInitConnectionConfig.hpp +7 -1
- package/nitrogen/generated/android/c++/JNitroBillingChoiceInfoAndroid.hpp +66 -0
- package/nitrogen/generated/android/c++/JNitroBillingProgramAvailabilityResultAndroid.hpp +18 -3
- package/nitrogen/generated/android/c++/JNitroBillingProgramInformationDialogParamsAndroid.hpp +63 -0
- package/nitrogen/generated/android/c++/JNitroBillingResultAndroid.hpp +72 -0
- package/nitrogen/generated/android/c++/JNitroGetBillingChoiceInfoParamsAndroid.hpp +74 -0
- package/nitrogen/generated/android/c++/JNitroInAppMessageParamsAndroid.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroInAppMessageResultAndroid.hpp +68 -0
- package/nitrogen/generated/android/c++/JNitroLaunchExternalLinkParamsAndroid.hpp +10 -1
- package/nitrogen/generated/android/c++/JNitroOneTimePurchaseOfferDetail.hpp +5 -1
- package/nitrogen/generated/android/c++/JNitroProduct.hpp +13 -1
- package/nitrogen/generated/android/c++/JNitroPurchaseRequest.hpp +7 -0
- package/nitrogen/generated/android/c++/JNitroRequestPurchaseAndroid.hpp +16 -1
- package/nitrogen/generated/android/c++/JProductType.hpp +58 -0
- package/nitrogen/generated/android/c++/JSubResponseCodeAndroid.hpp +61 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_Array_InAppMessageCategoryAndroid_.cpp +35 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_Array_InAppMessageCategoryAndroid_.hpp +81 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_DeveloperBillingOptionParamsAndroid.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_DeveloperBillingOptionParamsAndroid.hpp +78 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_InitConnectionConfig.hpp +2 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_NitroInAppMessageParamsAndroid.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_NitroInAppMessageParamsAndroid.hpp +76 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_NitroRequestPurchaseAndroid.hpp +7 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/BillingChoiceImageLayoutAndroid.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/BillingChoiceScreenTypeAndroid.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/BillingProgramAndroid.kt +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/DeveloperBillingLaunchModeAndroid.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/DeveloperBillingOptionParamsAndroid.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/DeveloperBillingTypeAndroid.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/DeveloperProvidedBillingDetailsAndroid.kt +13 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/DeveloperProvidedBillingProductAndroid.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +13 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/InAppMessageCategoryAndroid.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/InAppMessageResponseCodeAndroid.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/InitConnectionConfig.kt +5 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroBillingChoiceInfoAndroid.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroBillingProgramAvailabilityResultAndroid.kt +10 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroBillingProgramInformationDialogParamsAndroid.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroBillingResultAndroid.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroGetBillingChoiceInfoParamsAndroid.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroInAppMessageParamsAndroid.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroInAppMessageResultAndroid.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroLaunchExternalLinkParamsAndroid.kt +6 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroOneTimePurchaseOfferDetail.kt +5 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroProduct.kt +11 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroRequestPurchaseAndroid.kt +8 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/ProductType.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/SubResponseCodeAndroid.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_Array_InAppMessageCategoryAndroid_.kt +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_DeveloperBillingOptionParamsAndroid.kt +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_NitroInAppMessageParamsAndroid.kt +53 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +24 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +382 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +48 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +74 -2
- package/nitrogen/generated/ios/swift/BillingChoiceImageLayoutAndroid.swift +44 -0
- package/nitrogen/generated/ios/swift/BillingChoiceScreenTypeAndroid.swift +44 -0
- package/nitrogen/generated/ios/swift/BillingProgramAndroid.swift +4 -0
- package/nitrogen/generated/ios/swift/DeveloperBillingLaunchModeAndroid.swift +44 -0
- package/nitrogen/generated/ios/swift/DeveloperBillingOptionParamsAndroid.swift +114 -0
- package/nitrogen/generated/ios/swift/DeveloperBillingTypeAndroid.swift +44 -0
- package/nitrogen/generated/ios/swift/DeveloperProvidedBillingDetailsAndroid.swift +121 -4
- package/nitrogen/generated/ios/swift/DeveloperProvidedBillingProductAndroid.swift +71 -0
- package/nitrogen/generated/ios/swift/Func_void_NitroBillingChoiceInfoAndroid.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_NitroBillingResultAndroid.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_NitroInAppMessageResultAndroid.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +4 -1
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +78 -2
- package/nitrogen/generated/ios/swift/InAppMessageCategoryAndroid.swift +40 -0
- package/nitrogen/generated/ios/swift/InAppMessageResponseCodeAndroid.swift +40 -0
- package/nitrogen/generated/ios/swift/InitConnectionConfig.swift +12 -1
- package/nitrogen/generated/ios/swift/NitroBillingChoiceInfoAndroid.swift +66 -0
- package/nitrogen/generated/ios/swift/NitroBillingProgramAvailabilityResultAndroid.swift +50 -2
- package/nitrogen/generated/ios/swift/NitroBillingProgramInformationDialogParamsAndroid.swift +34 -0
- package/nitrogen/generated/ios/swift/NitroBillingResultAndroid.swift +77 -0
- package/nitrogen/generated/ios/swift/NitroGetBillingChoiceInfoParamsAndroid.swift +71 -0
- package/nitrogen/generated/ios/swift/NitroInAppMessageParamsAndroid.swift +67 -0
- package/nitrogen/generated/ios/swift/NitroInAppMessageResultAndroid.swift +66 -0
- package/nitrogen/generated/ios/swift/NitroLaunchExternalLinkParamsAndroid.swift +39 -2
- package/nitrogen/generated/ios/swift/NitroOneTimePurchaseOfferDetail.swift +39 -2
- package/nitrogen/generated/ios/swift/NitroProduct.swift +113 -2
- package/nitrogen/generated/ios/swift/NitroRequestPurchaseAndroid.swift +75 -1
- package/nitrogen/generated/ios/swift/ProductType.swift +40 -0
- package/nitrogen/generated/ios/swift/SubResponseCodeAndroid.swift +44 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_DeveloperBillingOptionParamsAndroid.swift +18 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_NitroInAppMessageParamsAndroid.swift +18 -0
- package/nitrogen/generated/ios/swift/Variant_NullType__InAppMessageCategoryAndroid_.swift +18 -0
- package/nitrogen/generated/shared/c++/BillingChoiceImageLayoutAndroid.hpp +80 -0
- package/nitrogen/generated/shared/c++/BillingChoiceScreenTypeAndroid.hpp +80 -0
- package/nitrogen/generated/shared/c++/BillingProgramAndroid.hpp +4 -0
- package/nitrogen/generated/shared/c++/DeveloperBillingLaunchModeAndroid.hpp +80 -0
- package/nitrogen/generated/shared/c++/DeveloperBillingOptionParamsAndroid.hpp +103 -0
- package/nitrogen/generated/shared/c++/DeveloperBillingTypeAndroid.hpp +80 -0
- package/nitrogen/generated/shared/c++/DeveloperProvidedBillingDetailsAndroid.hpp +24 -6
- package/nitrogen/generated/shared/c++/DeveloperProvidedBillingProductAndroid.hpp +96 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +3 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +25 -1
- package/nitrogen/generated/shared/c++/InAppMessageCategoryAndroid.hpp +76 -0
- package/nitrogen/generated/shared/c++/InAppMessageResponseCodeAndroid.hpp +76 -0
- package/nitrogen/generated/shared/c++/InitConnectionConfig.hpp +8 -1
- package/nitrogen/generated/shared/c++/NitroBillingChoiceInfoAndroid.hpp +90 -0
- package/nitrogen/generated/shared/c++/NitroBillingProgramAvailabilityResultAndroid.hpp +16 -2
- package/nitrogen/generated/shared/c++/NitroBillingProgramInformationDialogParamsAndroid.hpp +89 -0
- package/nitrogen/generated/shared/c++/NitroBillingResultAndroid.hpp +96 -0
- package/nitrogen/generated/shared/c++/NitroGetBillingChoiceInfoParamsAndroid.hpp +99 -0
- package/nitrogen/generated/shared/c++/NitroInAppMessageParamsAndroid.hpp +88 -0
- package/nitrogen/generated/shared/c++/NitroInAppMessageResultAndroid.hpp +92 -0
- package/nitrogen/generated/shared/c++/NitroLaunchExternalLinkParamsAndroid.hpp +9 -2
- package/nitrogen/generated/shared/c++/NitroOneTimePurchaseOfferDetail.hpp +5 -1
- package/nitrogen/generated/shared/c++/NitroProduct.hpp +13 -1
- package/nitrogen/generated/shared/c++/NitroRequestPurchaseAndroid.hpp +12 -1
- package/nitrogen/generated/shared/c++/ProductType.hpp +76 -0
- package/nitrogen/generated/shared/c++/SubResponseCodeAndroid.hpp +80 -0
- package/openiap-versions.json +3 -3
- package/package.json +1 -1
- package/src/hooks/useIAP.ts +63 -0
- package/src/index.kepler.ts +9 -0
- package/src/index.ts +223 -95
- package/src/specs/RnIap.nitro.ts +116 -8
- package/src/types.ts +238 -35
- package/src/utils/type-bridge.ts +26 -2
- package/src/vega-adapter.ts +46 -11
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// DeveloperBillingTypeAndroid.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/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::iap {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (DeveloperBillingTypeAndroid).
|
|
30
|
+
*/
|
|
31
|
+
enum class DeveloperBillingTypeAndroid {
|
|
32
|
+
IN_APP SWIFT_NAME(inApp) = 0,
|
|
33
|
+
DEVELOPER_BILLING_TYPE_UNSPECIFIED SWIFT_NAME(developerBillingTypeUnspecified) = 1,
|
|
34
|
+
EXTERNAL_LINK SWIFT_NAME(externalLink) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::iap
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ DeveloperBillingTypeAndroid <> JS DeveloperBillingTypeAndroid (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::iap::DeveloperBillingTypeAndroid> final {
|
|
44
|
+
static inline margelo::nitro::iap::DeveloperBillingTypeAndroid fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
45
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
46
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
47
|
+
case hashString("in-app"): return margelo::nitro::iap::DeveloperBillingTypeAndroid::IN_APP;
|
|
48
|
+
case hashString("developer-billing-type-unspecified"): return margelo::nitro::iap::DeveloperBillingTypeAndroid::DEVELOPER_BILLING_TYPE_UNSPECIFIED;
|
|
49
|
+
case hashString("external-link"): return margelo::nitro::iap::DeveloperBillingTypeAndroid::EXTERNAL_LINK;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum DeveloperBillingTypeAndroid - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::DeveloperBillingTypeAndroid arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::iap::DeveloperBillingTypeAndroid::IN_APP: return JSIConverter<std::string>::toJSI(runtime, "in-app");
|
|
57
|
+
case margelo::nitro::iap::DeveloperBillingTypeAndroid::DEVELOPER_BILLING_TYPE_UNSPECIFIED: return JSIConverter<std::string>::toJSI(runtime, "developer-billing-type-unspecified");
|
|
58
|
+
case margelo::nitro::iap::DeveloperBillingTypeAndroid::EXTERNAL_LINK: return JSIConverter<std::string>::toJSI(runtime, "external-link");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert DeveloperBillingTypeAndroid to JS - invalid value: "
|
|
61
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
65
|
+
if (!value.isString()) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
69
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
70
|
+
case hashString("in-app"):
|
|
71
|
+
case hashString("developer-billing-type-unspecified"):
|
|
72
|
+
case hashString("external-link"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -28,9 +28,15 @@
|
|
|
28
28
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
29
|
#endif
|
|
30
30
|
|
|
31
|
+
// Forward declaration of `DeveloperProvidedBillingProductAndroid` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::iap { struct DeveloperProvidedBillingProductAndroid; }
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
#include <NitroModules/Null.hpp>
|
|
33
35
|
#include <string>
|
|
36
|
+
#include <variant>
|
|
37
|
+
#include <optional>
|
|
38
|
+
#include "DeveloperProvidedBillingProductAndroid.hpp"
|
|
39
|
+
#include <vector>
|
|
34
40
|
|
|
35
41
|
namespace margelo::nitro::iap {
|
|
36
42
|
|
|
@@ -39,11 +45,14 @@ namespace margelo::nitro::iap {
|
|
|
39
45
|
*/
|
|
40
46
|
struct DeveloperProvidedBillingDetailsAndroid final {
|
|
41
47
|
public:
|
|
42
|
-
std::string externalTransactionToken SWIFT_PRIVATE;
|
|
48
|
+
std::optional<std::variant<nitro::NullType, std::string>> externalTransactionToken SWIFT_PRIVATE;
|
|
49
|
+
std::optional<std::variant<nitro::NullType, std::string>> linkUri SWIFT_PRIVATE;
|
|
50
|
+
std::optional<std::variant<nitro::NullType, std::string>> originalExternalTransactionId SWIFT_PRIVATE;
|
|
51
|
+
std::vector<DeveloperProvidedBillingProductAndroid> products SWIFT_PRIVATE;
|
|
43
52
|
|
|
44
53
|
public:
|
|
45
54
|
DeveloperProvidedBillingDetailsAndroid() = default;
|
|
46
|
-
explicit DeveloperProvidedBillingDetailsAndroid(std::string externalTransactionToken): externalTransactionToken(externalTransactionToken) {}
|
|
55
|
+
explicit DeveloperProvidedBillingDetailsAndroid(std::optional<std::variant<nitro::NullType, std::string>> externalTransactionToken, std::optional<std::variant<nitro::NullType, std::string>> linkUri, std::optional<std::variant<nitro::NullType, std::string>> originalExternalTransactionId, std::vector<DeveloperProvidedBillingProductAndroid> products): externalTransactionToken(externalTransactionToken), linkUri(linkUri), originalExternalTransactionId(originalExternalTransactionId), products(products) {}
|
|
47
56
|
|
|
48
57
|
public:
|
|
49
58
|
friend bool operator==(const DeveloperProvidedBillingDetailsAndroid& lhs, const DeveloperProvidedBillingDetailsAndroid& rhs) = default;
|
|
@@ -59,12 +68,18 @@ namespace margelo::nitro {
|
|
|
59
68
|
static inline margelo::nitro::iap::DeveloperProvidedBillingDetailsAndroid fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
60
69
|
jsi::Object obj = arg.asObject(runtime);
|
|
61
70
|
return margelo::nitro::iap::DeveloperProvidedBillingDetailsAndroid(
|
|
62
|
-
JSIConverter<std::string
|
|
71
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "externalTransactionToken"))),
|
|
72
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "linkUri"))),
|
|
73
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "originalExternalTransactionId"))),
|
|
74
|
+
JSIConverter<std::vector<margelo::nitro::iap::DeveloperProvidedBillingProductAndroid>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "products")))
|
|
63
75
|
);
|
|
64
76
|
}
|
|
65
77
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::DeveloperProvidedBillingDetailsAndroid& arg) {
|
|
66
78
|
jsi::Object obj(runtime);
|
|
67
|
-
obj.setProperty(runtime, PropNameIDCache::get(runtime, "externalTransactionToken"), JSIConverter<std::string
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "externalTransactionToken"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.externalTransactionToken));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "linkUri"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.linkUri));
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "originalExternalTransactionId"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.originalExternalTransactionId));
|
|
82
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "products"), JSIConverter<std::vector<margelo::nitro::iap::DeveloperProvidedBillingProductAndroid>>::toJSI(runtime, arg.products));
|
|
68
83
|
return obj;
|
|
69
84
|
}
|
|
70
85
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -75,7 +90,10 @@ namespace margelo::nitro {
|
|
|
75
90
|
if (!nitro::isPlainObject(runtime, obj)) {
|
|
76
91
|
return false;
|
|
77
92
|
}
|
|
78
|
-
if (!JSIConverter<std::string
|
|
93
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "externalTransactionToken")))) return false;
|
|
94
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "linkUri")))) return false;
|
|
95
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "originalExternalTransactionId")))) return false;
|
|
96
|
+
if (!JSIConverter<std::vector<margelo::nitro::iap::DeveloperProvidedBillingProductAndroid>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "products")))) return false;
|
|
79
97
|
return true;
|
|
80
98
|
}
|
|
81
99
|
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// DeveloperProvidedBillingProductAndroid.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
|
+
// Forward declaration of `ProductType` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::iap { enum class ProductType; }
|
|
33
|
+
|
|
34
|
+
#include <string>
|
|
35
|
+
#include <NitroModules/Null.hpp>
|
|
36
|
+
#include <variant>
|
|
37
|
+
#include <optional>
|
|
38
|
+
#include "ProductType.hpp"
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro::iap {
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A struct which can be represented as a JavaScript object (DeveloperProvidedBillingProductAndroid).
|
|
44
|
+
*/
|
|
45
|
+
struct DeveloperProvidedBillingProductAndroid final {
|
|
46
|
+
public:
|
|
47
|
+
std::string id SWIFT_PRIVATE;
|
|
48
|
+
std::optional<std::variant<nitro::NullType, std::string>> offerToken SWIFT_PRIVATE;
|
|
49
|
+
ProductType type SWIFT_PRIVATE;
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
DeveloperProvidedBillingProductAndroid() = default;
|
|
53
|
+
explicit DeveloperProvidedBillingProductAndroid(std::string id, std::optional<std::variant<nitro::NullType, std::string>> offerToken, ProductType type): id(id), offerToken(offerToken), type(type) {}
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
friend bool operator==(const DeveloperProvidedBillingProductAndroid& lhs, const DeveloperProvidedBillingProductAndroid& rhs) = default;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
} // namespace margelo::nitro::iap
|
|
60
|
+
|
|
61
|
+
namespace margelo::nitro {
|
|
62
|
+
|
|
63
|
+
// C++ DeveloperProvidedBillingProductAndroid <> JS DeveloperProvidedBillingProductAndroid (object)
|
|
64
|
+
template <>
|
|
65
|
+
struct JSIConverter<margelo::nitro::iap::DeveloperProvidedBillingProductAndroid> final {
|
|
66
|
+
static inline margelo::nitro::iap::DeveloperProvidedBillingProductAndroid fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
67
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
68
|
+
return margelo::nitro::iap::DeveloperProvidedBillingProductAndroid(
|
|
69
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))),
|
|
70
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "offerToken"))),
|
|
71
|
+
JSIConverter<margelo::nitro::iap::ProductType>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::DeveloperProvidedBillingProductAndroid& arg) {
|
|
75
|
+
jsi::Object obj(runtime);
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter<std::string>::toJSI(runtime, arg.id));
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "offerToken"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.offerToken));
|
|
78
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter<margelo::nitro::iap::ProductType>::toJSI(runtime, arg.type));
|
|
79
|
+
return obj;
|
|
80
|
+
}
|
|
81
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
82
|
+
if (!value.isObject()) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
jsi::Object obj = value.getObject(runtime);
|
|
86
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id")))) return false;
|
|
90
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "offerToken")))) return false;
|
|
91
|
+
if (!JSIConverter<margelo::nitro::iap::ProductType>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false;
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
} // namespace margelo::nitro
|
|
@@ -65,7 +65,10 @@ namespace margelo::nitro::iap {
|
|
|
65
65
|
prototype.registerHybridMethod("removeSubscriptionBillingIssueListener", &HybridRnIapSpec::removeSubscriptionBillingIssueListener);
|
|
66
66
|
prototype.registerHybridMethod("enableBillingProgramAndroid", &HybridRnIapSpec::enableBillingProgramAndroid);
|
|
67
67
|
prototype.registerHybridMethod("isBillingProgramAvailableAndroid", &HybridRnIapSpec::isBillingProgramAvailableAndroid);
|
|
68
|
+
prototype.registerHybridMethod("getBillingChoiceInfoAndroid", &HybridRnIapSpec::getBillingChoiceInfoAndroid);
|
|
68
69
|
prototype.registerHybridMethod("createBillingProgramReportingDetailsAndroid", &HybridRnIapSpec::createBillingProgramReportingDetailsAndroid);
|
|
70
|
+
prototype.registerHybridMethod("showBillingProgramInformationDialogAndroid", &HybridRnIapSpec::showBillingProgramInformationDialogAndroid);
|
|
71
|
+
prototype.registerHybridMethod("showInAppMessagesAndroid", &HybridRnIapSpec::showInAppMessagesAndroid);
|
|
69
72
|
prototype.registerHybridMethod("launchExternalLinkAndroid", &HybridRnIapSpec::launchExternalLinkAndroid);
|
|
70
73
|
prototype.registerHybridMethod("canPresentExternalPurchaseNoticeIOS", &HybridRnIapSpec::canPresentExternalPurchaseNoticeIOS);
|
|
71
74
|
prototype.registerHybridMethod("presentExternalPurchaseNoticeSheetIOS", &HybridRnIapSpec::presentExternalPurchaseNoticeSheetIOS);
|
|
@@ -57,8 +57,22 @@ namespace margelo::nitro::iap { struct DeveloperProvidedBillingDetailsAndroid; }
|
|
|
57
57
|
namespace margelo::nitro::iap { enum class BillingProgramAndroid; }
|
|
58
58
|
// Forward declaration of `NitroBillingProgramAvailabilityResultAndroid` to properly resolve imports.
|
|
59
59
|
namespace margelo::nitro::iap { struct NitroBillingProgramAvailabilityResultAndroid; }
|
|
60
|
+
// Forward declaration of `NitroBillingChoiceInfoAndroid` to properly resolve imports.
|
|
61
|
+
namespace margelo::nitro::iap { struct NitroBillingChoiceInfoAndroid; }
|
|
62
|
+
// Forward declaration of `NitroGetBillingChoiceInfoParamsAndroid` to properly resolve imports.
|
|
63
|
+
namespace margelo::nitro::iap { struct NitroGetBillingChoiceInfoParamsAndroid; }
|
|
60
64
|
// Forward declaration of `NitroBillingProgramReportingDetailsAndroid` to properly resolve imports.
|
|
61
65
|
namespace margelo::nitro::iap { struct NitroBillingProgramReportingDetailsAndroid; }
|
|
66
|
+
// Forward declaration of `DeveloperBillingTypeAndroid` to properly resolve imports.
|
|
67
|
+
namespace margelo::nitro::iap { enum class DeveloperBillingTypeAndroid; }
|
|
68
|
+
// Forward declaration of `NitroBillingResultAndroid` to properly resolve imports.
|
|
69
|
+
namespace margelo::nitro::iap { struct NitroBillingResultAndroid; }
|
|
70
|
+
// Forward declaration of `NitroBillingProgramInformationDialogParamsAndroid` to properly resolve imports.
|
|
71
|
+
namespace margelo::nitro::iap { struct NitroBillingProgramInformationDialogParamsAndroid; }
|
|
72
|
+
// Forward declaration of `NitroInAppMessageResultAndroid` to properly resolve imports.
|
|
73
|
+
namespace margelo::nitro::iap { struct NitroInAppMessageResultAndroid; }
|
|
74
|
+
// Forward declaration of `NitroInAppMessageParamsAndroid` to properly resolve imports.
|
|
75
|
+
namespace margelo::nitro::iap { struct NitroInAppMessageParamsAndroid; }
|
|
62
76
|
// Forward declaration of `NitroLaunchExternalLinkParamsAndroid` to properly resolve imports.
|
|
63
77
|
namespace margelo::nitro::iap { struct NitroLaunchExternalLinkParamsAndroid; }
|
|
64
78
|
// Forward declaration of `ExternalPurchaseNoticeResultIOS` to properly resolve imports.
|
|
@@ -103,7 +117,14 @@ namespace margelo::nitro::iap { enum class ExternalPurchaseCustomLinkNoticeTypeI
|
|
|
103
117
|
#include "DeveloperProvidedBillingDetailsAndroid.hpp"
|
|
104
118
|
#include "BillingProgramAndroid.hpp"
|
|
105
119
|
#include "NitroBillingProgramAvailabilityResultAndroid.hpp"
|
|
120
|
+
#include "NitroBillingChoiceInfoAndroid.hpp"
|
|
121
|
+
#include "NitroGetBillingChoiceInfoParamsAndroid.hpp"
|
|
106
122
|
#include "NitroBillingProgramReportingDetailsAndroid.hpp"
|
|
123
|
+
#include "DeveloperBillingTypeAndroid.hpp"
|
|
124
|
+
#include "NitroBillingResultAndroid.hpp"
|
|
125
|
+
#include "NitroBillingProgramInformationDialogParamsAndroid.hpp"
|
|
126
|
+
#include "NitroInAppMessageResultAndroid.hpp"
|
|
127
|
+
#include "NitroInAppMessageParamsAndroid.hpp"
|
|
107
128
|
#include "NitroLaunchExternalLinkParamsAndroid.hpp"
|
|
108
129
|
#include "ExternalPurchaseNoticeResultIOS.hpp"
|
|
109
130
|
#include "ExternalPurchaseLinkResultIOS.hpp"
|
|
@@ -194,7 +215,10 @@ namespace margelo::nitro::iap {
|
|
|
194
215
|
virtual void removeSubscriptionBillingIssueListener(const std::function<void(const NitroPurchase& /* purchase */)>& listener) = 0;
|
|
195
216
|
virtual void enableBillingProgramAndroid(BillingProgramAndroid program) = 0;
|
|
196
217
|
virtual std::shared_ptr<Promise<NitroBillingProgramAvailabilityResultAndroid>> isBillingProgramAvailableAndroid(BillingProgramAndroid program) = 0;
|
|
197
|
-
virtual std::shared_ptr<Promise<
|
|
218
|
+
virtual std::shared_ptr<Promise<NitroBillingChoiceInfoAndroid>> getBillingChoiceInfoAndroid(const NitroGetBillingChoiceInfoParamsAndroid& params) = 0;
|
|
219
|
+
virtual std::shared_ptr<Promise<NitroBillingProgramReportingDetailsAndroid>> createBillingProgramReportingDetailsAndroid(BillingProgramAndroid program, std::optional<DeveloperBillingTypeAndroid> developerBillingType) = 0;
|
|
220
|
+
virtual std::shared_ptr<Promise<NitroBillingResultAndroid>> showBillingProgramInformationDialogAndroid(const NitroBillingProgramInformationDialogParamsAndroid& params) = 0;
|
|
221
|
+
virtual std::shared_ptr<Promise<NitroInAppMessageResultAndroid>> showInAppMessagesAndroid(const std::optional<std::variant<nitro::NullType, NitroInAppMessageParamsAndroid>>& params) = 0;
|
|
198
222
|
virtual std::shared_ptr<Promise<bool>> launchExternalLinkAndroid(const NitroLaunchExternalLinkParamsAndroid& params) = 0;
|
|
199
223
|
virtual std::shared_ptr<Promise<bool>> canPresentExternalPurchaseNoticeIOS() = 0;
|
|
200
224
|
virtual std::shared_ptr<Promise<ExternalPurchaseNoticeResultIOS>> presentExternalPurchaseNoticeSheetIOS() = 0;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// InAppMessageCategoryAndroid.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/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::iap {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (InAppMessageCategoryAndroid).
|
|
30
|
+
*/
|
|
31
|
+
enum class InAppMessageCategoryAndroid {
|
|
32
|
+
UNKNOWN_IN_APP_MESSAGE_CATEGORY_ID SWIFT_NAME(unknownInAppMessageCategoryId) = 0,
|
|
33
|
+
TRANSACTIONAL SWIFT_NAME(transactional) = 1,
|
|
34
|
+
} CLOSED_ENUM;
|
|
35
|
+
|
|
36
|
+
} // namespace margelo::nitro::iap
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro {
|
|
39
|
+
|
|
40
|
+
// C++ InAppMessageCategoryAndroid <> JS InAppMessageCategoryAndroid (union)
|
|
41
|
+
template <>
|
|
42
|
+
struct JSIConverter<margelo::nitro::iap::InAppMessageCategoryAndroid> final {
|
|
43
|
+
static inline margelo::nitro::iap::InAppMessageCategoryAndroid fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
44
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
45
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
46
|
+
case hashString("unknown-in-app-message-category-id"): return margelo::nitro::iap::InAppMessageCategoryAndroid::UNKNOWN_IN_APP_MESSAGE_CATEGORY_ID;
|
|
47
|
+
case hashString("transactional"): return margelo::nitro::iap::InAppMessageCategoryAndroid::TRANSACTIONAL;
|
|
48
|
+
default: [[unlikely]]
|
|
49
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum InAppMessageCategoryAndroid - invalid value!");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::InAppMessageCategoryAndroid arg) {
|
|
53
|
+
switch (arg) {
|
|
54
|
+
case margelo::nitro::iap::InAppMessageCategoryAndroid::UNKNOWN_IN_APP_MESSAGE_CATEGORY_ID: return JSIConverter<std::string>::toJSI(runtime, "unknown-in-app-message-category-id");
|
|
55
|
+
case margelo::nitro::iap::InAppMessageCategoryAndroid::TRANSACTIONAL: return JSIConverter<std::string>::toJSI(runtime, "transactional");
|
|
56
|
+
default: [[unlikely]]
|
|
57
|
+
throw std::invalid_argument("Cannot convert InAppMessageCategoryAndroid to JS - invalid value: "
|
|
58
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
62
|
+
if (!value.isString()) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
66
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
67
|
+
case hashString("unknown-in-app-message-category-id"):
|
|
68
|
+
case hashString("transactional"):
|
|
69
|
+
return true;
|
|
70
|
+
default:
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// InAppMessageResponseCodeAndroid.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/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::iap {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (InAppMessageResponseCodeAndroid).
|
|
30
|
+
*/
|
|
31
|
+
enum class InAppMessageResponseCodeAndroid {
|
|
32
|
+
NO_ACTION_NEEDED SWIFT_NAME(noActionNeeded) = 0,
|
|
33
|
+
SUBSCRIPTION_STATUS_UPDATED SWIFT_NAME(subscriptionStatusUpdated) = 1,
|
|
34
|
+
} CLOSED_ENUM;
|
|
35
|
+
|
|
36
|
+
} // namespace margelo::nitro::iap
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro {
|
|
39
|
+
|
|
40
|
+
// C++ InAppMessageResponseCodeAndroid <> JS InAppMessageResponseCodeAndroid (union)
|
|
41
|
+
template <>
|
|
42
|
+
struct JSIConverter<margelo::nitro::iap::InAppMessageResponseCodeAndroid> final {
|
|
43
|
+
static inline margelo::nitro::iap::InAppMessageResponseCodeAndroid fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
44
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
45
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
46
|
+
case hashString("no-action-needed"): return margelo::nitro::iap::InAppMessageResponseCodeAndroid::NO_ACTION_NEEDED;
|
|
47
|
+
case hashString("subscription-status-updated"): return margelo::nitro::iap::InAppMessageResponseCodeAndroid::SUBSCRIPTION_STATUS_UPDATED;
|
|
48
|
+
default: [[unlikely]]
|
|
49
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum InAppMessageResponseCodeAndroid - invalid value!");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::InAppMessageResponseCodeAndroid arg) {
|
|
53
|
+
switch (arg) {
|
|
54
|
+
case margelo::nitro::iap::InAppMessageResponseCodeAndroid::NO_ACTION_NEEDED: return JSIConverter<std::string>::toJSI(runtime, "no-action-needed");
|
|
55
|
+
case margelo::nitro::iap::InAppMessageResponseCodeAndroid::SUBSCRIPTION_STATUS_UPDATED: return JSIConverter<std::string>::toJSI(runtime, "subscription-status-updated");
|
|
56
|
+
default: [[unlikely]]
|
|
57
|
+
throw std::invalid_argument("Cannot convert InAppMessageResponseCodeAndroid to JS - invalid value: "
|
|
58
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
62
|
+
if (!value.isString()) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
66
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
67
|
+
case hashString("no-action-needed"):
|
|
68
|
+
case hashString("subscription-status-updated"):
|
|
69
|
+
return true;
|
|
70
|
+
default:
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro
|
|
@@ -30,11 +30,14 @@
|
|
|
30
30
|
|
|
31
31
|
// Forward declaration of `AlternativeBillingModeAndroid` to properly resolve imports.
|
|
32
32
|
namespace margelo::nitro::iap { enum class AlternativeBillingModeAndroid; }
|
|
33
|
+
// Forward declaration of `BillingChoiceScreenTypeAndroid` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::iap { enum class BillingChoiceScreenTypeAndroid; }
|
|
33
35
|
// Forward declaration of `BillingProgramAndroid` to properly resolve imports.
|
|
34
36
|
namespace margelo::nitro::iap { enum class BillingProgramAndroid; }
|
|
35
37
|
|
|
36
38
|
#include "AlternativeBillingModeAndroid.hpp"
|
|
37
39
|
#include <optional>
|
|
40
|
+
#include "BillingChoiceScreenTypeAndroid.hpp"
|
|
38
41
|
#include "BillingProgramAndroid.hpp"
|
|
39
42
|
|
|
40
43
|
namespace margelo::nitro::iap {
|
|
@@ -45,11 +48,12 @@ namespace margelo::nitro::iap {
|
|
|
45
48
|
struct InitConnectionConfig final {
|
|
46
49
|
public:
|
|
47
50
|
std::optional<AlternativeBillingModeAndroid> alternativeBillingModeAndroid SWIFT_PRIVATE;
|
|
51
|
+
std::optional<BillingChoiceScreenTypeAndroid> billingChoiceScreenTypeAndroid SWIFT_PRIVATE;
|
|
48
52
|
std::optional<BillingProgramAndroid> enableBillingProgramAndroid SWIFT_PRIVATE;
|
|
49
53
|
|
|
50
54
|
public:
|
|
51
55
|
InitConnectionConfig() = default;
|
|
52
|
-
explicit InitConnectionConfig(std::optional<AlternativeBillingModeAndroid> alternativeBillingModeAndroid, std::optional<BillingProgramAndroid> enableBillingProgramAndroid): alternativeBillingModeAndroid(alternativeBillingModeAndroid), enableBillingProgramAndroid(enableBillingProgramAndroid) {}
|
|
56
|
+
explicit InitConnectionConfig(std::optional<AlternativeBillingModeAndroid> alternativeBillingModeAndroid, std::optional<BillingChoiceScreenTypeAndroid> billingChoiceScreenTypeAndroid, std::optional<BillingProgramAndroid> enableBillingProgramAndroid): alternativeBillingModeAndroid(alternativeBillingModeAndroid), billingChoiceScreenTypeAndroid(billingChoiceScreenTypeAndroid), enableBillingProgramAndroid(enableBillingProgramAndroid) {}
|
|
53
57
|
|
|
54
58
|
public:
|
|
55
59
|
friend bool operator==(const InitConnectionConfig& lhs, const InitConnectionConfig& rhs) = default;
|
|
@@ -66,12 +70,14 @@ namespace margelo::nitro {
|
|
|
66
70
|
jsi::Object obj = arg.asObject(runtime);
|
|
67
71
|
return margelo::nitro::iap::InitConnectionConfig(
|
|
68
72
|
JSIConverter<std::optional<margelo::nitro::iap::AlternativeBillingModeAndroid>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "alternativeBillingModeAndroid"))),
|
|
73
|
+
JSIConverter<std::optional<margelo::nitro::iap::BillingChoiceScreenTypeAndroid>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "billingChoiceScreenTypeAndroid"))),
|
|
69
74
|
JSIConverter<std::optional<margelo::nitro::iap::BillingProgramAndroid>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enableBillingProgramAndroid")))
|
|
70
75
|
);
|
|
71
76
|
}
|
|
72
77
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::InitConnectionConfig& arg) {
|
|
73
78
|
jsi::Object obj(runtime);
|
|
74
79
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "alternativeBillingModeAndroid"), JSIConverter<std::optional<margelo::nitro::iap::AlternativeBillingModeAndroid>>::toJSI(runtime, arg.alternativeBillingModeAndroid));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "billingChoiceScreenTypeAndroid"), JSIConverter<std::optional<margelo::nitro::iap::BillingChoiceScreenTypeAndroid>>::toJSI(runtime, arg.billingChoiceScreenTypeAndroid));
|
|
75
81
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "enableBillingProgramAndroid"), JSIConverter<std::optional<margelo::nitro::iap::BillingProgramAndroid>>::toJSI(runtime, arg.enableBillingProgramAndroid));
|
|
76
82
|
return obj;
|
|
77
83
|
}
|
|
@@ -84,6 +90,7 @@ namespace margelo::nitro {
|
|
|
84
90
|
return false;
|
|
85
91
|
}
|
|
86
92
|
if (!JSIConverter<std::optional<margelo::nitro::iap::AlternativeBillingModeAndroid>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "alternativeBillingModeAndroid")))) return false;
|
|
93
|
+
if (!JSIConverter<std::optional<margelo::nitro::iap::BillingChoiceScreenTypeAndroid>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "billingChoiceScreenTypeAndroid")))) return false;
|
|
87
94
|
if (!JSIConverter<std::optional<margelo::nitro::iap::BillingProgramAndroid>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "enableBillingProgramAndroid")))) return false;
|
|
88
95
|
return true;
|
|
89
96
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroBillingChoiceInfoAndroid.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 <string>
|
|
34
|
+
#include <NitroModules/Null.hpp>
|
|
35
|
+
#include <variant>
|
|
36
|
+
#include <optional>
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro::iap {
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A struct which can be represented as a JavaScript object (NitroBillingChoiceInfoAndroid).
|
|
42
|
+
*/
|
|
43
|
+
struct NitroBillingChoiceInfoAndroid final {
|
|
44
|
+
public:
|
|
45
|
+
std::string playBillingChoiceImageUrl SWIFT_PRIVATE;
|
|
46
|
+
std::optional<std::variant<nitro::NullType, std::string>> playBillingLoyaltyInfo SWIFT_PRIVATE;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
NitroBillingChoiceInfoAndroid() = default;
|
|
50
|
+
explicit NitroBillingChoiceInfoAndroid(std::string playBillingChoiceImageUrl, std::optional<std::variant<nitro::NullType, std::string>> playBillingLoyaltyInfo): playBillingChoiceImageUrl(playBillingChoiceImageUrl), playBillingLoyaltyInfo(playBillingLoyaltyInfo) {}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
friend bool operator==(const NitroBillingChoiceInfoAndroid& lhs, const NitroBillingChoiceInfoAndroid& rhs) = default;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace margelo::nitro::iap
|
|
57
|
+
|
|
58
|
+
namespace margelo::nitro {
|
|
59
|
+
|
|
60
|
+
// C++ NitroBillingChoiceInfoAndroid <> JS NitroBillingChoiceInfoAndroid (object)
|
|
61
|
+
template <>
|
|
62
|
+
struct JSIConverter<margelo::nitro::iap::NitroBillingChoiceInfoAndroid> final {
|
|
63
|
+
static inline margelo::nitro::iap::NitroBillingChoiceInfoAndroid fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
64
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
65
|
+
return margelo::nitro::iap::NitroBillingChoiceInfoAndroid(
|
|
66
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "playBillingChoiceImageUrl"))),
|
|
67
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "playBillingLoyaltyInfo")))
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroBillingChoiceInfoAndroid& arg) {
|
|
71
|
+
jsi::Object obj(runtime);
|
|
72
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "playBillingChoiceImageUrl"), JSIConverter<std::string>::toJSI(runtime, arg.playBillingChoiceImageUrl));
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "playBillingLoyaltyInfo"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.playBillingLoyaltyInfo));
|
|
74
|
+
return obj;
|
|
75
|
+
}
|
|
76
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
77
|
+
if (!value.isObject()) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
jsi::Object obj = value.getObject(runtime);
|
|
81
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "playBillingChoiceImageUrl")))) return false;
|
|
85
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "playBillingLoyaltyInfo")))) return false;
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
} // namespace margelo::nitro
|