react-native-iap 16.1.0 → 16.2.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.
Files changed (46) hide show
  1. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +1 -1
  2. package/ios/RnIapHelper.swift +22 -0
  3. package/lib/module/index.js +4 -2
  4. package/lib/module/index.js.map +1 -1
  5. package/lib/module/types.js.map +1 -1
  6. package/lib/typescript/src/index.d.ts +4 -2
  7. package/lib/typescript/src/index.d.ts.map +1 -1
  8. package/lib/typescript/src/specs/RnIap.nitro.d.ts +4 -2
  9. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  10. package/lib/typescript/src/types.d.ts +23 -7
  11. package/lib/typescript/src/types.d.ts.map +1 -1
  12. package/nitrogen/generated/android/NitroIap+autolinking.cmake +1 -0
  13. package/nitrogen/generated/android/c++/JAdvancedCommerceInfoIOS.hpp +10 -1
  14. package/nitrogen/generated/android/c++/JFunc_void_NitroPurchase.hpp +5 -0
  15. package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +9 -0
  16. package/nitrogen/generated/android/c++/JNitroPurchase.hpp +5 -0
  17. package/nitrogen/generated/android/c++/JNitroPurchaseVerificationResultIOS.hpp +5 -0
  18. package/nitrogen/generated/android/c++/JPurchase.hpp +5 -0
  19. package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +5 -0
  20. package/nitrogen/generated/android/c++/JRequestPurchaseResult.hpp +5 -0
  21. package/nitrogen/generated/android/c++/JSubscriptionPeriodIOS.hpp +67 -0
  22. package/nitrogen/generated/android/c++/JSubscriptionPeriodValueIOS.hpp +62 -0
  23. package/nitrogen/generated/android/c++/JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid.hpp +5 -0
  24. package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceInfoIOS.hpp +5 -0
  25. package/nitrogen/generated/android/c++/JVariant_NullType_NitroPurchase.hpp +5 -0
  26. package/nitrogen/generated/android/c++/JVariant_NullType_SubscriptionPeriodValueIOS.cpp +26 -0
  27. package/nitrogen/generated/android/c++/JVariant_NullType_SubscriptionPeriodValueIOS.hpp +73 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceInfoIOS.kt +7 -2
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/SubscriptionPeriodIOS.kt +26 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/SubscriptionPeriodValueIOS.kt +56 -0
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_SubscriptionPeriodValueIOS.kt +62 -0
  32. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +50 -0
  33. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +6 -0
  34. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +6 -0
  35. package/nitrogen/generated/ios/swift/AdvancedCommerceInfoIOS.swift +38 -1
  36. package/nitrogen/generated/ios/swift/SubscriptionPeriodIOS.swift +52 -0
  37. package/nitrogen/generated/ios/swift/SubscriptionPeriodValueIOS.swift +34 -0
  38. package/nitrogen/generated/ios/swift/Variant_NullType_SubscriptionPeriodValueIOS.swift +30 -0
  39. package/nitrogen/generated/shared/c++/AdvancedCommerceInfoIOS.hpp +8 -1
  40. package/nitrogen/generated/shared/c++/SubscriptionPeriodIOS.hpp +88 -0
  41. package/nitrogen/generated/shared/c++/SubscriptionPeriodValueIOS.hpp +88 -0
  42. package/openiap-versions.json +3 -3
  43. package/package.json +1 -1
  44. package/src/index.ts +4 -2
  45. package/src/specs/RnIap.nitro.ts +9 -15
  46. package/src/types.ts +23 -7
@@ -0,0 +1,88 @@
1
+ ///
2
+ /// SubscriptionPeriodIOS.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 (SubscriptionPeriodIOS).
30
+ */
31
+ enum class SubscriptionPeriodIOS {
32
+ EMPTY SWIFT_NAME(empty) = 0,
33
+ DAY SWIFT_NAME(day) = 1,
34
+ WEEK SWIFT_NAME(week) = 2,
35
+ MONTH SWIFT_NAME(month) = 3,
36
+ YEAR SWIFT_NAME(year) = 4,
37
+ } CLOSED_ENUM;
38
+
39
+ } // namespace margelo::nitro::iap
40
+
41
+ namespace margelo::nitro {
42
+
43
+ // C++ SubscriptionPeriodIOS <> JS SubscriptionPeriodIOS (union)
44
+ template <>
45
+ struct JSIConverter<margelo::nitro::iap::SubscriptionPeriodIOS> final {
46
+ static inline margelo::nitro::iap::SubscriptionPeriodIOS fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
47
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
48
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
49
+ case hashString("empty"): return margelo::nitro::iap::SubscriptionPeriodIOS::EMPTY;
50
+ case hashString("day"): return margelo::nitro::iap::SubscriptionPeriodIOS::DAY;
51
+ case hashString("week"): return margelo::nitro::iap::SubscriptionPeriodIOS::WEEK;
52
+ case hashString("month"): return margelo::nitro::iap::SubscriptionPeriodIOS::MONTH;
53
+ case hashString("year"): return margelo::nitro::iap::SubscriptionPeriodIOS::YEAR;
54
+ default: [[unlikely]]
55
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum SubscriptionPeriodIOS - invalid value!");
56
+ }
57
+ }
58
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::SubscriptionPeriodIOS arg) {
59
+ switch (arg) {
60
+ case margelo::nitro::iap::SubscriptionPeriodIOS::EMPTY: return JSIConverter<std::string>::toJSI(runtime, "empty");
61
+ case margelo::nitro::iap::SubscriptionPeriodIOS::DAY: return JSIConverter<std::string>::toJSI(runtime, "day");
62
+ case margelo::nitro::iap::SubscriptionPeriodIOS::WEEK: return JSIConverter<std::string>::toJSI(runtime, "week");
63
+ case margelo::nitro::iap::SubscriptionPeriodIOS::MONTH: return JSIConverter<std::string>::toJSI(runtime, "month");
64
+ case margelo::nitro::iap::SubscriptionPeriodIOS::YEAR: return JSIConverter<std::string>::toJSI(runtime, "year");
65
+ default: [[unlikely]]
66
+ throw std::invalid_argument("Cannot convert SubscriptionPeriodIOS to JS - invalid value: "
67
+ + std::to_string(static_cast<int>(arg)) + "!");
68
+ }
69
+ }
70
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
71
+ if (!value.isString()) {
72
+ return false;
73
+ }
74
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
75
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
76
+ case hashString("empty"):
77
+ case hashString("day"):
78
+ case hashString("week"):
79
+ case hashString("month"):
80
+ case hashString("year"):
81
+ return true;
82
+ default:
83
+ return false;
84
+ }
85
+ }
86
+ };
87
+
88
+ } // namespace margelo::nitro
@@ -0,0 +1,88 @@
1
+ ///
2
+ /// SubscriptionPeriodValueIOS.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 `SubscriptionPeriodIOS` to properly resolve imports.
32
+ namespace margelo::nitro::iap { enum class SubscriptionPeriodIOS; }
33
+
34
+ #include "SubscriptionPeriodIOS.hpp"
35
+
36
+ namespace margelo::nitro::iap {
37
+
38
+ /**
39
+ * A struct which can be represented as a JavaScript object (SubscriptionPeriodValueIOS).
40
+ */
41
+ struct SubscriptionPeriodValueIOS final {
42
+ public:
43
+ SubscriptionPeriodIOS unit SWIFT_PRIVATE;
44
+ double value SWIFT_PRIVATE;
45
+
46
+ public:
47
+ SubscriptionPeriodValueIOS() = default;
48
+ explicit SubscriptionPeriodValueIOS(SubscriptionPeriodIOS unit, double value): unit(unit), value(value) {}
49
+
50
+ public:
51
+ friend bool operator==(const SubscriptionPeriodValueIOS& lhs, const SubscriptionPeriodValueIOS& rhs) = default;
52
+ };
53
+
54
+ } // namespace margelo::nitro::iap
55
+
56
+ namespace margelo::nitro {
57
+
58
+ // C++ SubscriptionPeriodValueIOS <> JS SubscriptionPeriodValueIOS (object)
59
+ template <>
60
+ struct JSIConverter<margelo::nitro::iap::SubscriptionPeriodValueIOS> final {
61
+ static inline margelo::nitro::iap::SubscriptionPeriodValueIOS fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
62
+ jsi::Object obj = arg.asObject(runtime);
63
+ return margelo::nitro::iap::SubscriptionPeriodValueIOS(
64
+ JSIConverter<margelo::nitro::iap::SubscriptionPeriodIOS>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "unit"))),
65
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))
66
+ );
67
+ }
68
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::SubscriptionPeriodValueIOS& arg) {
69
+ jsi::Object obj(runtime);
70
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "unit"), JSIConverter<margelo::nitro::iap::SubscriptionPeriodIOS>::toJSI(runtime, arg.unit));
71
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<double>::toJSI(runtime, arg.value));
72
+ return obj;
73
+ }
74
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
75
+ if (!value.isObject()) {
76
+ return false;
77
+ }
78
+ jsi::Object obj = value.getObject(runtime);
79
+ if (!nitro::isPlainObject(runtime, obj)) {
80
+ return false;
81
+ }
82
+ if (!JSIConverter<margelo::nitro::iap::SubscriptionPeriodIOS>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "unit")))) return false;
83
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
84
+ return true;
85
+ }
86
+ };
87
+
88
+ } // namespace margelo::nitro
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "3.0.1",
3
- "google": "3.1.0",
4
- "apple": "3.0.1"
2
+ "spec": "3.1.0",
3
+ "google": "3.2.0",
4
+ "apple": "3.1.0"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-iap",
3
- "version": "16.1.0",
3
+ "version": "16.2.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",
package/src/index.ts CHANGED
@@ -2258,8 +2258,10 @@ export const syncIOS: MutationField<'syncIOS'> = async () => {
2258
2258
 
2259
2259
  /**
2260
2260
  * Present the code redemption sheet for offer codes (iOS only)
2261
- * @returns The verified redeemed purchase on iOS 27+, or null after the
2262
- * legacy sheet is presented on earlier iOS versions.
2261
+ * @returns The verified redeemed purchase when built with Xcode 27+ and
2262
+ * running on Apple 27+. Earlier iOS/visionOS system sheets return null;
2263
+ * Catalyst 16–26 surfaces StoreKitError.unknown, and Catalyst 15 is a no-op
2264
+ * that returns null.
2263
2265
  * @platform iOS
2264
2266
  *
2265
2267
  * @see {@link https://openiap.dev/docs/apis/ios/present-code-redemption-sheet-ios}
@@ -128,22 +128,16 @@ export type BillingChoiceImageLayoutAndroid =
128
128
  | 'rectangular-two-by-two';
129
129
 
130
130
  export type BillingChoiceScreenTypeAndroid =
131
- | 'unspecified'
132
- | 'developer-rendered'
133
- | 'google-rendered';
131
+ 'unspecified' | 'developer-rendered' | 'google-rendered';
134
132
 
135
133
  export type DeveloperBillingTypeAndroid =
136
- | 'developer-billing-type-unspecified'
137
- | 'in-app'
138
- | 'external-link';
134
+ 'developer-billing-type-unspecified' | 'in-app' | 'external-link';
139
135
 
140
136
  export type InAppMessageCategoryAndroid =
141
- | 'unknown-in-app-message-category-id'
142
- | 'transactional';
137
+ 'unknown-in-app-message-category-id' | 'transactional';
143
138
 
144
139
  export type InAppMessageResponseCodeAndroid =
145
- | 'no-action-needed'
146
- | 'subscription-status-updated';
140
+ 'no-action-needed' | 'subscription-status-updated';
147
141
 
148
142
  // Developer Billing Launch Mode (Android 8.3.0+)
149
143
  // Defined locally for Nitro codegen
@@ -162,9 +156,7 @@ export type ExternalLinkLaunchModeAndroid =
162
156
  // External Link Type (Android 8.2.0+)
163
157
  // Defined locally for Nitro codegen
164
158
  export type ExternalLinkTypeAndroid =
165
- | 'unspecified'
166
- | 'link-to-digital-content-offer'
167
- | 'link-to-app-download';
159
+ 'unspecified' | 'link-to-digital-content-offer' | 'link-to-app-download';
168
160
 
169
161
  // ╔══════════════════════════════════════════════════════════════════════════╗
170
162
  // ║ PARAMS ║
@@ -836,8 +828,10 @@ export interface RnIap extends HybridObject<{ios: 'swift'; android: 'kotlin'}> {
836
828
 
837
829
  /**
838
830
  * Present the code redemption sheet for offer codes (iOS only)
839
- * @returns The verified redeemed purchase on iOS 27+, or null after the
840
- * legacy sheet is presented on earlier iOS versions.
831
+ * @returns The verified redeemed purchase when built with Xcode 27+ and
832
+ * running on Apple 27+. Earlier iOS/visionOS system sheets return null;
833
+ * Catalyst 16–26 surfaces StoreKitError.unknown, and Catalyst 15 is a no-op
834
+ * that returns null.
841
835
  * @platform iOS
842
836
  */
843
837
  presentCodeRedemptionSheetIOS(): Promise<NitroPurchase | null>;
package/src/types.ts CHANGED
@@ -46,6 +46,8 @@ export interface AdvancedCommerceInfoIOS {
46
46
  estimatedTax?: (string | null);
47
47
  /** The items purchased as part of this transaction */
48
48
  items: AdvancedCommerceItemIOS[];
49
+ /** Subscription period for this transaction */
50
+ period?: (SubscriptionPeriodValueIOS | null);
49
51
  /** Request reference identifier for tracking */
50
52
  requestReferenceId?: (string | null);
51
53
  /** Tax code for the transaction */
@@ -809,11 +811,15 @@ export interface Mutation {
809
811
  openRedeemOfferCodeAndroid: Promise<boolean>;
810
812
  /**
811
813
  * Show the App Store offer code redemption sheet.
812
- * On iOS 27+, Mac Catalyst 27+, and visionOS 27+, returns the verified
813
- * transaction produced by the redemption. Earlier iOS and Mac Catalyst
814
- * versions present the legacy sheet and return null; reconcile purchases
815
- * through the normal transaction listener or an explicit available-purchases
816
- * refresh.
814
+ * When built with Xcode 27+ and running on iOS 27+, Mac Catalyst 27+, or
815
+ * visionOS 27+, returns the verified transaction produced by the redemption.
816
+ * StoreKit 2's scene-based sheet returns null after presentation on iOS 16–26,
817
+ * visionOS 1–26, and those platforms on Apple 27 when built with an older SDK.
818
+ * iOS 15 uses the StoreKit 1 sheet and also returns null. On Mac Catalyst, the
819
+ * scene-based API throws StoreKitError.unknown, while the Catalyst 15 StoreKit 1
820
+ * call has no effect and returns null. Reconcile null results from a presented
821
+ * sheet through the normal transaction listener or an explicit
822
+ * available-purchases refresh.
817
823
  * See: https://openiap.dev/docs/apis/ios/present-code-redemption-sheet-ios
818
824
  */
819
825
  presentCodeRedemptionSheetIOS?: Promise<(PurchaseIOS | null)>;
@@ -1427,7 +1433,12 @@ export interface Query {
1427
1433
  */
1428
1434
  getPendingTransactionsIOS: Promise<PurchaseIOS[]>;
1429
1435
  /**
1430
- * Read the App Store-promoted product, if any (iOS 11+).
1436
+ * Read the App Store-promoted product, if any (iOS 15+).
1437
+ * OpenIAP consumes PurchaseIntent.intents on iOS 16.4+ and uses the
1438
+ * StoreKit 1 observer only on iOS 15–16.3. When PurchaseIntent carries an
1439
+ * externally redeemed win-back offer, OpenIAP preserves it for the next
1440
+ * matching requestPurchase unless the caller supplies an explicit win-back or
1441
+ * promotional offer.
1431
1442
  * See: https://openiap.dev/docs/apis/ios/get-promoted-product-ios
1432
1443
  */
1433
1444
  getPromotedProductIOS?: Promise<(ProductIOS | null)>;
@@ -1864,7 +1875,12 @@ export interface Subscription {
1864
1875
  * openiap-google 2.3.0 (requires Play Billing 9.1.0+).
1865
1876
  */
1866
1877
  developerProvidedBillingAndroid: DeveloperProvidedBillingDetailsAndroid;
1867
- /** Fires when the App Store surfaces a promoted product (iOS only) */
1878
+ /**
1879
+ * Fires when the App Store surfaces a promoted product (iOS only).
1880
+ * A win-back offer attached to PurchaseIntent is preserved for the next
1881
+ * matching requestPurchase unless the caller supplies an explicit win-back or
1882
+ * promotional offer.
1883
+ */
1868
1884
  promotedProductIOS: string;
1869
1885
  /** Fires when a purchase fails or is cancelled */
1870
1886
  purchaseError: PurchaseError;