react-native-purchases 8.0.0-beta.1 → 8.0.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 +4 -54
- package/RNPurchases.podspec +2 -2
- package/android/build.gradle +2 -2
- package/android/gradle.properties +4 -4
- package/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java +70 -19
- package/dist/purchases.d.ts +51 -23
- package/dist/purchases.js +145 -72
- package/ios/RNPurchases.m +59 -40
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -53,61 +53,11 @@ Our full SDK reference [can be found here](https://revenuecat.github.io/react-na
|
|
|
53
53
|
|
|
54
54
|
## Installation
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
Expo supports in-app payments and is compatible with react-native-purchases. To use the library, [create a new project](https://docs.expo.dev/get-started/create-a-project/) and set up a [development build](https://docs.expo.dev/get-started/set-up-your-environment/?mode=development-build). A development build helps you iterate quickly and provides a complete development environment. After you've created the project, install the library:
|
|
57
57
|
|
|
58
|
-
> ❗️ If you're planning on ejecting from Expo, upgrade your expo version _first_, THEN eject. It'll save you a whole lot of hassle. ❗️
|
|
59
|
-
|
|
60
|
-
### 1. Add the library to the project
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
$ npm install react-native-purchases --save
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
or
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
$ yarn add react-native-purchases
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### 2. Link library to the project
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
$ react-native link react-native-purchases
|
|
76
58
|
```
|
|
77
|
-
|
|
78
|
-
### Additional iOS Setup
|
|
79
|
-
|
|
80
|
-
#### If your project uses Cocoapods
|
|
81
|
-
If your project already uses Cocoapods to install iOS dependencies, common in ExpoKit projects, linking the library should have added it to the podfile. If it hasn't, add the following to your project's podfile to reference the library from your node_modules folder:
|
|
82
|
-
|
|
83
|
-
```ruby
|
|
84
|
-
pod 'RNPurchases', :path => '../node_modules/react-native-purchases'
|
|
85
|
-
:inhibit_warnings => true
|
|
59
|
+
$ npx expo install react-native-purchases
|
|
86
60
|
```
|
|
87
61
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
#### Migrating from manual installation (if your project doesn't use CocoapodsCreate)
|
|
91
|
-
|
|
92
|
-
##### Remove the Framework Reference from your project
|
|
93
|
-
|
|
94
|
-
1. Remove `Purchases.framework` and `PurchasesHybridCommon.framework` from the libraries section of the project.
|
|
95
|
-
|
|
96
|
-
##### Remove iOS Frameworks to Embedded Binaries
|
|
97
|
-
1. In Xcode, in project manager, select your app target.
|
|
98
|
-
1. Select the general tab
|
|
99
|
-
1. Look for `Purchases.framework` and `PurchasesHybridCommon.framework` in the Embedded Binaries section and remove them.
|
|
100
|
-
|
|
101
|
-
Remove `$(PROJECT_DIR)/../node_modules/react-native-purchases/ios` from Framework Search paths in build settings
|
|
102
|
-
|
|
103
|
-
##### Remove Strip Frameworks Phase
|
|
104
|
-
During the old manual installation instructions, now deprecated, we indicated to add a build phase to strip fat frameworks.
|
|
105
|
-
1. In Xcode, in project manager, select your app target.
|
|
106
|
-
2. Open the `Build Phases` tab
|
|
107
|
-
3. Remove the added `Strip Frameworks` phase
|
|
108
|
-
4. Clean `Derived Data`
|
|
109
|
-
|
|
110
|
-
##### Link static library
|
|
111
|
-
The `react-native link` command should have added the `libRNPurchases.a` library to the _Linked Frameworks and Libraries_ section of your app target. If it hasn't add it like this:
|
|
112
|
-
|
|
113
|
-

|
|
62
|
+
### Bare workflow
|
|
63
|
+
If you are using [bare workflow](https://docs.expo.dev/bare/overview/) (that is, your project is created using `react-native init`), [install `expo`](https://docs.expo.dev/bare/installing-expo-modules/) into your project and [leverage Expo CLI](https://docs.expo.dev/bare/using-expo-cli/) to use Expo tooling and services.
|
package/RNPurchases.podspec
CHANGED
|
@@ -10,7 +10,7 @@ Pod::Spec.new do |spec|
|
|
|
10
10
|
spec.authors = package['author']
|
|
11
11
|
spec.homepage = "https://github.com/RevenueCat/react-native-purchases"
|
|
12
12
|
spec.license = package['license']
|
|
13
|
-
spec.
|
|
13
|
+
spec.platforms = {:ios => "13.0", :tvos => "13.0"}
|
|
14
14
|
|
|
15
15
|
spec.source = { :git => "https://github.com/RevenueCat/react-native-purchases.git" }
|
|
16
16
|
spec.source_files = "ios/**/*.{h,m,swift}"
|
|
@@ -25,6 +25,6 @@ Pod::Spec.new do |spec|
|
|
|
25
25
|
]
|
|
26
26
|
|
|
27
27
|
spec.dependency "React-Core"
|
|
28
|
-
spec.dependency "PurchasesHybridCommon", '
|
|
28
|
+
spec.dependency "PurchasesHybridCommon", '13.0.0'
|
|
29
29
|
spec.swift_version = '5.7'
|
|
30
30
|
end
|
package/android/build.gradle
CHANGED
|
@@ -29,7 +29,7 @@ android {
|
|
|
29
29
|
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
|
|
30
30
|
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
31
31
|
versionCode 1
|
|
32
|
-
versionName '8.0.0
|
|
32
|
+
versionName '8.0.0'
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
buildTypes {
|
|
@@ -121,6 +121,6 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
|
121
121
|
dependencies {
|
|
122
122
|
//noinspection GradleDynamicVersion
|
|
123
123
|
api 'com.facebook.react:react-native:+'
|
|
124
|
-
implementation 'com.revenuecat.purchases:purchases-hybrid-common:
|
|
124
|
+
implementation 'com.revenuecat.purchases:purchases-hybrid-common:13.0.0'
|
|
125
125
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
126
126
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
android.useAndroidX=true
|
|
2
|
-
Purchases_kotlinVersion=1.
|
|
3
|
-
Purchases_compileSdkVersion=
|
|
4
|
-
Purchases_targetSdkVersion=
|
|
5
|
-
Purchases_minSdkVersion=
|
|
2
|
+
Purchases_kotlinVersion=1.8.22
|
|
3
|
+
Purchases_compileSdkVersion=34
|
|
4
|
+
Purchases_targetSdkVersion=34
|
|
5
|
+
Purchases_minSdkVersion=21
|
|
@@ -19,10 +19,12 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
|
19
19
|
import com.revenuecat.purchases.CustomerInfo;
|
|
20
20
|
import com.revenuecat.purchases.DangerousSettings;
|
|
21
21
|
import com.revenuecat.purchases.Purchases;
|
|
22
|
+
import com.revenuecat.purchases.PurchasesAreCompletedBy;
|
|
22
23
|
import com.revenuecat.purchases.Store;
|
|
23
24
|
import com.revenuecat.purchases.common.PlatformInfo;
|
|
24
25
|
import com.revenuecat.purchases.hybridcommon.CommonKt;
|
|
25
26
|
import com.revenuecat.purchases.hybridcommon.ErrorContainer;
|
|
27
|
+
import com.revenuecat.purchases.hybridcommon.OnNullableResult;
|
|
26
28
|
import com.revenuecat.purchases.hybridcommon.OnResult;
|
|
27
29
|
import com.revenuecat.purchases.hybridcommon.OnResultAny;
|
|
28
30
|
import com.revenuecat.purchases.hybridcommon.OnResultList;
|
|
@@ -45,7 +47,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
45
47
|
private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
|
|
46
48
|
private static final String LOG_HANDLER_EVENT = "Purchases-LogHandlerEvent";
|
|
47
49
|
public static final String PLATFORM_NAME = "react-native";
|
|
48
|
-
public static final String PLUGIN_VERSION = "8.0.0
|
|
50
|
+
public static final String PLUGIN_VERSION = "8.0.0";
|
|
49
51
|
|
|
50
52
|
private final ReactApplicationContext reactContext;
|
|
51
53
|
|
|
@@ -81,10 +83,11 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
81
83
|
|
|
82
84
|
@ReactMethod
|
|
83
85
|
public void setupPurchases(String apiKey, @Nullable String appUserID,
|
|
84
|
-
|
|
86
|
+
@Nullable String purchasesAreCompletedBy, @Nullable String userDefaultsSuiteName,
|
|
85
87
|
@Nullable String storeKitVersion, boolean useAmazon,
|
|
86
88
|
boolean shouldShowInAppMessagesAutomatically,
|
|
87
|
-
@Nullable String entitlementVerificationMode
|
|
89
|
+
@Nullable String entitlementVerificationMode,
|
|
90
|
+
boolean pendingTransactionsForPrepaidPlansEnabled) {
|
|
88
91
|
PlatformInfo platformInfo = new PlatformInfo(PLATFORM_NAME, PLUGIN_VERSION);
|
|
89
92
|
Store store = Store.PLAY_STORE;
|
|
90
93
|
if (useAmazon) {
|
|
@@ -94,12 +97,13 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
94
97
|
reactContext,
|
|
95
98
|
apiKey,
|
|
96
99
|
appUserID,
|
|
97
|
-
|
|
100
|
+
purchasesAreCompletedBy,
|
|
98
101
|
platformInfo,
|
|
99
102
|
store,
|
|
100
103
|
new DangerousSettings(),
|
|
101
104
|
shouldShowInAppMessagesAutomatically,
|
|
102
|
-
entitlementVerificationMode
|
|
105
|
+
entitlementVerificationMode,
|
|
106
|
+
pendingTransactionsForPrepaidPlansEnabled
|
|
103
107
|
);
|
|
104
108
|
Purchases.getSharedInstance().setUpdatedCustomerInfoListener(this);
|
|
105
109
|
}
|
|
@@ -114,6 +118,16 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
114
118
|
CommonKt.getOfferings(getOnResult(promise));
|
|
115
119
|
}
|
|
116
120
|
|
|
121
|
+
@ReactMethod
|
|
122
|
+
public void getCurrentOfferingForPlacement(String placementIdentifier, final Promise promise) {
|
|
123
|
+
CommonKt.getCurrentOfferingForPlacement(placementIdentifier, getOnNullableResult(promise));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@ReactMethod
|
|
127
|
+
public void syncAttributesAndOfferingsIfNeeded(final Promise promise) {
|
|
128
|
+
CommonKt.syncAttributesAndOfferingsIfNeeded(getOnResult(promise));
|
|
129
|
+
}
|
|
130
|
+
|
|
117
131
|
@ReactMethod
|
|
118
132
|
public void getProductInfo(ReadableArray productIDs, String type, final Promise promise) {
|
|
119
133
|
ArrayList<String> productIDList = new ArrayList<>();
|
|
@@ -144,12 +158,17 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
144
158
|
final String type,
|
|
145
159
|
@Nullable final String discountTimestamp,
|
|
146
160
|
@Nullable final ReadableMap googleInfo,
|
|
147
|
-
@Nullable final
|
|
161
|
+
@Nullable final ReadableMap presentedOfferingContext,
|
|
148
162
|
final Promise promise) {
|
|
149
163
|
GoogleUpgradeInfo googleUpgradeInfo = getUpgradeInfo(googleProductChangeInfo);
|
|
150
164
|
|
|
151
165
|
Boolean googleIsPersonalized = googleInfo != null && googleInfo.hasKey("isPersonalizedPrice") ? googleInfo.getBoolean("isPersonalizedPrice") : null;
|
|
152
166
|
|
|
167
|
+
Map<String, Object> mapPresentedOfferingContext = null;
|
|
168
|
+
if (presentedOfferingContext != null) {
|
|
169
|
+
mapPresentedOfferingContext = presentedOfferingContext.toHashMap();
|
|
170
|
+
}
|
|
171
|
+
|
|
153
172
|
CommonKt.purchaseProduct(
|
|
154
173
|
getCurrentActivity(),
|
|
155
174
|
productIdentifier,
|
|
@@ -158,13 +177,13 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
158
177
|
googleUpgradeInfo.getOldProductIdentifier(),
|
|
159
178
|
googleUpgradeInfo.getProrationMode(),
|
|
160
179
|
googleIsPersonalized,
|
|
161
|
-
|
|
180
|
+
mapPresentedOfferingContext,
|
|
162
181
|
getOnResult(promise));
|
|
163
182
|
}
|
|
164
183
|
|
|
165
184
|
@ReactMethod
|
|
166
185
|
public void purchasePackage(final String packageIdentifier,
|
|
167
|
-
final
|
|
186
|
+
final ReadableMap presentedOfferingContext,
|
|
168
187
|
@Nullable final ReadableMap googleProductChangeInfo,
|
|
169
188
|
@Nullable final String discountTimestamp,
|
|
170
189
|
@Nullable final ReadableMap googleInfo,
|
|
@@ -173,10 +192,12 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
173
192
|
|
|
174
193
|
Boolean googleIsPersonalized = googleInfo != null && googleInfo.hasKey("isPersonalizedPrice") ? googleInfo.getBoolean("isPersonalizedPrice") : null;
|
|
175
194
|
|
|
195
|
+
Map<String, Object> mapPresentedOfferingContext = presentedOfferingContext.toHashMap();
|
|
196
|
+
|
|
176
197
|
CommonKt.purchasePackage(
|
|
177
198
|
getCurrentActivity(),
|
|
178
199
|
packageIdentifier,
|
|
179
|
-
|
|
200
|
+
mapPresentedOfferingContext,
|
|
180
201
|
googleUpgradeInfo.getOldProductIdentifier(),
|
|
181
202
|
googleUpgradeInfo.getProrationMode(),
|
|
182
203
|
googleIsPersonalized,
|
|
@@ -189,12 +210,17 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
189
210
|
@Nullable final ReadableMap upgradeInfo,
|
|
190
211
|
@Nullable final String discountTimestamp,
|
|
191
212
|
@Nullable final ReadableMap googleInfo,
|
|
192
|
-
@Nullable final
|
|
213
|
+
@Nullable final ReadableMap presentedOfferingContext,
|
|
193
214
|
final Promise promise) {
|
|
194
215
|
GoogleUpgradeInfo googleUpgradeInfo = getUpgradeInfo(upgradeInfo);
|
|
195
216
|
|
|
196
217
|
Boolean googleIsPersonalized = googleInfo != null && googleInfo.hasKey("isPersonalizedPrice") ? googleInfo.getBoolean("isPersonalizedPrice") : null;
|
|
197
218
|
|
|
219
|
+
Map<String, Object> mapPresentedOfferingContext = null;
|
|
220
|
+
if (presentedOfferingContext != null) {
|
|
221
|
+
mapPresentedOfferingContext = presentedOfferingContext.toHashMap();
|
|
222
|
+
}
|
|
223
|
+
|
|
198
224
|
CommonKt.purchaseSubscriptionOption(
|
|
199
225
|
getCurrentActivity(),
|
|
200
226
|
productIdentifer,
|
|
@@ -202,7 +228,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
202
228
|
googleUpgradeInfo.getOldProductIdentifier(),
|
|
203
229
|
googleUpgradeInfo.getProrationMode(),
|
|
204
230
|
googleIsPersonalized,
|
|
205
|
-
|
|
231
|
+
mapPresentedOfferingContext,
|
|
206
232
|
getOnResult(promise));
|
|
207
233
|
}
|
|
208
234
|
|
|
@@ -251,11 +277,6 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
251
277
|
CommonKt.getCustomerInfo(getOnResult(promise));
|
|
252
278
|
}
|
|
253
279
|
|
|
254
|
-
@ReactMethod
|
|
255
|
-
public void setFinishTransactions(boolean enabled) {
|
|
256
|
-
CommonKt.setFinishTransactions(enabled);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
280
|
@ReactMethod
|
|
260
281
|
public void syncPurchases() {
|
|
261
282
|
CommonKt.syncPurchases();
|
|
@@ -288,8 +309,9 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
288
309
|
}
|
|
289
310
|
|
|
290
311
|
@ReactMethod
|
|
291
|
-
public void setProxyURLString(String proxyURLString) {
|
|
312
|
+
public void setProxyURLString(String proxyURLString, Promise promise) {
|
|
292
313
|
CommonKt.setProxyURLString(proxyURLString);
|
|
314
|
+
promise.resolve(null); // Resolve the promise with no value
|
|
293
315
|
}
|
|
294
316
|
|
|
295
317
|
@ReactMethod
|
|
@@ -437,14 +459,23 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
437
459
|
}
|
|
438
460
|
|
|
439
461
|
@ReactMethod
|
|
440
|
-
public void
|
|
462
|
+
public void syncAmazonPurchase(String productID, String receiptID,
|
|
441
463
|
String amazonUserID, String isoCurrencyCode,
|
|
442
464
|
Double price, final Promise promise) {
|
|
443
|
-
Purchases.getSharedInstance().
|
|
465
|
+
Purchases.getSharedInstance().syncAmazonPurchase(productID, receiptID,
|
|
444
466
|
amazonUserID, isoCurrencyCode, price);
|
|
445
467
|
promise.resolve(null);
|
|
446
468
|
}
|
|
447
469
|
|
|
470
|
+
@ReactMethod
|
|
471
|
+
@Deprecated // Use syncAmazonPurchase instead
|
|
472
|
+
public void syncObserverModeAmazonPurchase(String productID, String receiptID,
|
|
473
|
+
String amazonUserID, String isoCurrencyCode,
|
|
474
|
+
Double price, final Promise promise) {
|
|
475
|
+
syncAmazonPurchase(productID, receiptID, amazonUserID, isoCurrencyCode, price, promise);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
|
|
448
479
|
@ReactMethod
|
|
449
480
|
public void showInAppMessages(ReadableArray messageTypes, final Promise promise) {
|
|
450
481
|
if (messageTypes == null) {
|
|
@@ -491,6 +522,26 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
491
522
|
};
|
|
492
523
|
}
|
|
493
524
|
|
|
525
|
+
@NotNull
|
|
526
|
+
private OnNullableResult getOnNullableResult(final Promise promise) {
|
|
527
|
+
return new OnNullableResult() {
|
|
528
|
+
@Override
|
|
529
|
+
public void onReceived(@Nullable Map<String, ?> map) {
|
|
530
|
+
if (map != null) {
|
|
531
|
+
promise.resolve(convertMapToWriteableMap(map));
|
|
532
|
+
} else {
|
|
533
|
+
promise.resolve(null);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
@Override
|
|
538
|
+
public void onError(ErrorContainer errorContainer) {
|
|
539
|
+
promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
|
|
540
|
+
convertMapToWriteableMap(errorContainer.getInfo()));
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
|
|
494
545
|
private static GoogleUpgradeInfo getUpgradeInfo(ReadableMap upgradeInfo) {
|
|
495
546
|
String googleOldProductId = null;
|
|
496
547
|
Integer googleProrationMode = null;
|
package/dist/purchases.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PURCHASES_ERROR_CODE, UninitializedPurchasesError, UnsupportedPlatformError, CustomerInfo, PurchasesEntitlementInfo, PRORATION_MODE, PACKAGE_TYPE, INTRO_ELIGIBILITY_STATUS, PurchasesOfferings, PurchasesStoreProduct, UpgradeInfo, PurchasesPromotionalOffer, PurchasesPackage, IntroEligibility, PurchasesStoreProductDiscount, SubscriptionOption, PRODUCT_CATEGORY, GoogleProductChangeInfo, PURCHASE_TYPE, BILLING_FEATURE, REFUND_REQUEST_STATUS, LOG_LEVEL, PurchasesConfiguration, CustomerInfoUpdateListener, ShouldPurchasePromoProductListener, MakePurchaseResult, LogHandler, LogInResult, IN_APP_MESSAGE_TYPE, ENTITLEMENT_VERIFICATION_MODE, VERIFICATION_RESULT, STOREKIT_VERSION, PurchasesStoreTransaction } from
|
|
2
|
-
export { PURCHASE_TYPE, BILLING_FEATURE, REFUND_REQUEST_STATUS, LOG_LEVEL, PurchasesConfiguration, CustomerInfoUpdateListener, ShouldPurchasePromoProductListener, MakePurchaseResult, LogHandler, LogInResult } from
|
|
1
|
+
import { PURCHASES_ERROR_CODE, UninitializedPurchasesError, UnsupportedPlatformError, CustomerInfo, PurchasesEntitlementInfo, PRORATION_MODE, PACKAGE_TYPE, INTRO_ELIGIBILITY_STATUS, PurchasesOfferings, PurchasesStoreProduct, UpgradeInfo, PurchasesPromotionalOffer, PurchasesPackage, IntroEligibility, PurchasesStoreProductDiscount, SubscriptionOption, PRODUCT_CATEGORY, GoogleProductChangeInfo, PURCHASE_TYPE, BILLING_FEATURE, REFUND_REQUEST_STATUS, LOG_LEVEL, PurchasesConfiguration, CustomerInfoUpdateListener, ShouldPurchasePromoProductListener, MakePurchaseResult, LogHandler, LogInResult, IN_APP_MESSAGE_TYPE, ENTITLEMENT_VERIFICATION_MODE, VERIFICATION_RESULT, STOREKIT_VERSION, PurchasesStoreTransaction, PurchasesOffering, PURCHASES_ARE_COMPLETED_BY_TYPE } from "@revenuecat/purchases-typescript-internal";
|
|
2
|
+
export { PURCHASE_TYPE, PurchasesAreCompletedBy, PurchasesAreCompletedByMyApp, PURCHASES_ARE_COMPLETED_BY_TYPE, BILLING_FEATURE, REFUND_REQUEST_STATUS, LOG_LEVEL, STOREKIT_VERSION, PurchasesConfiguration, CustomerInfoUpdateListener, ShouldPurchasePromoProductListener, MakePurchaseResult, LogHandler, LogInResult, } from "@revenuecat/purchases-typescript-internal";
|
|
3
3
|
export default class Purchases {
|
|
4
4
|
/**
|
|
5
5
|
* Supported SKU types.
|
|
@@ -82,6 +82,12 @@ export default class Purchases {
|
|
|
82
82
|
* @enum {string}
|
|
83
83
|
*/
|
|
84
84
|
static STOREKIT_VERSION: typeof STOREKIT_VERSION;
|
|
85
|
+
/**
|
|
86
|
+
* Enum of PurchasesAreCompletedByType.
|
|
87
|
+
* @readonly
|
|
88
|
+
* @enum {string}
|
|
89
|
+
*/
|
|
90
|
+
static PURCHASES_ARE_COMPLETED_BY_TYPE: typeof PURCHASES_ARE_COMPLETED_BY_TYPE;
|
|
85
91
|
/**
|
|
86
92
|
* @internal
|
|
87
93
|
*/
|
|
@@ -94,16 +100,18 @@ export default class Purchases {
|
|
|
94
100
|
* Sets up Purchases with your API key and an app user id.
|
|
95
101
|
* @param {String} apiKey RevenueCat API Key. Needs to be a String
|
|
96
102
|
* @param {String?} appUserID An optional unique id for identifying the user. Needs to be a string.
|
|
97
|
-
* @param {
|
|
98
|
-
* @param {STOREKIT_VERSION} [storeKitVersion=
|
|
99
|
-
* We recommend not using this parameter, letting RevenueCat decide for you which StoreKit implementation to use.
|
|
103
|
+
* @param {PurchasesAreCompletedBy} [purchasesAreCompletedBy=PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT] Set this to an instance of PurchasesAreCompletedByMyApp if you have your own IAP implementation and want to use only RevenueCat's backend. Default is PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT.
|
|
104
|
+
* @param {STOREKIT_VERSION} [storeKitVersion=DEFAULT] iOS-only. Defaults to STOREKIT_2. StoreKit 2 is only available on iOS 16+. StoreKit 1 will be used for previous iOS versions regardless of this setting.
|
|
100
105
|
* @param {ENTITLEMENT_VERIFICATION_MODE} [entitlementVerificationMode=ENTITLEMENT_VERIFICATION_MODE.DISABLED] Sets the entitlement verifciation mode to use. For more details, check https://rev.cat/trusted-entitlements
|
|
101
106
|
* @param {boolean} [useAmazon=false] An optional boolean. Android-only. Set this to TRUE to enable Amazon on compatible devices.
|
|
102
107
|
* @param {String?} userDefaultsSuiteName An optional string. iOS-only, will be ignored for Android.
|
|
103
108
|
* Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults suite, otherwise it will use standardUserDefaults.
|
|
104
109
|
* Default is null, which will make the SDK use standardUserDefaults.
|
|
110
|
+
* @param {boolean} [pendingTransactionsForPrepaidPlansEnabled=false] An optional boolean. Android-only. Set this to TRUE to enable pending transactions for prepaid subscriptions in Google Play.
|
|
111
|
+
*
|
|
112
|
+
* @warning If you use purchasesAreCompletedBy=PurchasesAreCompletedByMyApp, you must also provide a value for storeKitVersion.
|
|
105
113
|
*/
|
|
106
|
-
static configure({ apiKey, appUserID,
|
|
114
|
+
static configure({ apiKey, appUserID, purchasesAreCompletedBy, userDefaultsSuiteName, storeKitVersion, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode, pendingTransactionsForPrepaidPlansEnabled, }: PurchasesConfiguration): void;
|
|
107
115
|
/**
|
|
108
116
|
* @deprecated, configure behavior through the RevenueCat dashboard instead.
|
|
109
117
|
* If an user tries to purchase a product that is active on the current app store account,
|
|
@@ -113,12 +121,6 @@ export default class Purchases {
|
|
|
113
121
|
* @returns {Promise<void>} The promise will be rejected if configure has not been called yet.
|
|
114
122
|
*/
|
|
115
123
|
static setAllowSharingStoreAccount(allowSharing: boolean): Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* @param {boolean} finishTransactions Set finishTransactions to false if you aren't using Purchases SDK to
|
|
118
|
-
* make the purchase
|
|
119
|
-
* @returns {Promise<void>} The promise will be rejected if configure has not been called yet.
|
|
120
|
-
*/
|
|
121
|
-
static setFinishTransactions(finishTransactions: boolean): Promise<void>;
|
|
122
124
|
/**
|
|
123
125
|
* iOS only.
|
|
124
126
|
* @param {boolean} simulatesAskToBuyInSandbox Set this property to true *only* when testing the ask-to-buy / SCA
|
|
@@ -160,6 +162,22 @@ export default class Purchases {
|
|
|
160
162
|
* has not been called yet.
|
|
161
163
|
*/
|
|
162
164
|
static getOfferings(): Promise<PurchasesOfferings>;
|
|
165
|
+
/**
|
|
166
|
+
* Retrieves a current offering for a placement identifier, use this to access offerings defined by targeting
|
|
167
|
+
* placements configured in the RevenueCat dashboard.
|
|
168
|
+
* @param {String} placementIdentifier The placement identifier to fetch a current offeringn for
|
|
169
|
+
* @returns {Promise<PurchasesOffering | null>} Promise of an optional offering. The promise will be rejected if configure
|
|
170
|
+
* has not been called yet.
|
|
171
|
+
*/
|
|
172
|
+
static getCurrentOfferingForPlacement(placementIdentifier: string): Promise<PurchasesOffering | null>;
|
|
173
|
+
/**
|
|
174
|
+
* Syncs subscriber attributes and then fetches the configured offerings for this user. This method is intended to
|
|
175
|
+
* be called when using Targeting Rules with Custom Attributes. Any subscriber attributes should be set before
|
|
176
|
+
* calling this method to ensure the returned offerings are applied with the latest subscriber attributes.
|
|
177
|
+
* @returns {Promise<PurchasesOfferings>} Promise of entitlements structure. The promise will be rejected if configure
|
|
178
|
+
* has not been called yet.
|
|
179
|
+
*/
|
|
180
|
+
static syncAttributesAndOfferingsIfNeeded(): Promise<PurchasesOfferings>;
|
|
163
181
|
/**
|
|
164
182
|
* Fetch the product info
|
|
165
183
|
* @param {String[]} productIdentifiers Array of product identifiers
|
|
@@ -328,6 +346,23 @@ export default class Purchases {
|
|
|
328
346
|
* @returns {Promise<void>} The promise will be rejected if configure has not been called yet or if there's an error
|
|
329
347
|
* syncing purchases.
|
|
330
348
|
*/
|
|
349
|
+
static syncAmazonPurchase(productID: string, receiptID: string, amazonUserID: string, isoCurrencyCode?: string | null, price?: number | null): Promise<void>;
|
|
350
|
+
/**
|
|
351
|
+
* @deprecated, use syncAmazonPurchase instead.
|
|
352
|
+
*
|
|
353
|
+
* This method will send a purchase to the RevenueCat backend. This function should only be called if you are
|
|
354
|
+
* in Amazon observer mode or performing a client side migration of your current users to RevenueCat.
|
|
355
|
+
*
|
|
356
|
+
* The receipt IDs are cached if successfully posted so they are not posted more than once.
|
|
357
|
+
*
|
|
358
|
+
* @param {string} productID Product ID associated to the purchase.
|
|
359
|
+
* @param {string} receiptID ReceiptId that represents the Amazon purchase.
|
|
360
|
+
* @param {string} amazonUserID Amazon's userID. This parameter will be ignored when syncing a Google purchase.
|
|
361
|
+
* @param {(string|null|undefined)} isoCurrencyCode Product's currency code in ISO 4217 format.
|
|
362
|
+
* @param {(number|null|undefined)} price Product's price.
|
|
363
|
+
* @returns {Promise<void>} The promise will be rejected if configure has not been called yet or if there's an error
|
|
364
|
+
* syncing purchases.
|
|
365
|
+
*/
|
|
331
366
|
static syncObserverModeAmazonPurchase(productID: string, receiptID: string, amazonUserID: string, isoCurrencyCode?: string | null, price?: number | null): Promise<void>;
|
|
332
367
|
/**
|
|
333
368
|
* iOS only. Always returns an error on iOS < 15.
|
|
@@ -337,21 +372,14 @@ export default class Purchases {
|
|
|
337
372
|
*
|
|
338
373
|
* You only need to use this method with *new* purchases. Subscription updates are observed automatically.
|
|
339
374
|
*
|
|
340
|
-
* Important: This should only be used if you have
|
|
375
|
+
* Important: This should only be used if you have set PurchasesAreCompletedBy to MY_APP during SDK configuration.
|
|
341
376
|
*
|
|
342
377
|
* @warning You need to finish the transaction yourself after calling this method.
|
|
343
378
|
*
|
|
344
379
|
* @param {string} productID Product ID that was just purchased
|
|
345
380
|
* @returns {Promise<PurchasesStoreTransaction>} If there was a transacton found and handled for the provided product ID.
|
|
346
381
|
*/
|
|
347
|
-
static
|
|
348
|
-
/**
|
|
349
|
-
* @deprecated, use enableAdServicesAttributionTokenCollection instead.
|
|
350
|
-
* Enable automatic collection of Apple Search Ad attribution. Disabled by default
|
|
351
|
-
* @param {boolean} enabled Enable or not automatic apple search ads attribution collection
|
|
352
|
-
* @returns {Promise<void>} The promise will be rejected if configure has not been called yet.
|
|
353
|
-
*/
|
|
354
|
-
static setAutomaticAppleSearchAdsAttributionCollection(enabled: boolean): Promise<void>;
|
|
382
|
+
static recordPurchase(productID: string): Promise<PurchasesStoreTransaction>;
|
|
355
383
|
/**
|
|
356
384
|
* Enable automatic collection of Apple Search Ad attribution on iOS. Disabled by default
|
|
357
385
|
* @returns {Promise<void>} The promise will be rejected if configure has not been called yet.
|
|
@@ -460,8 +488,7 @@ export default class Purchases {
|
|
|
460
488
|
/**
|
|
461
489
|
* Set this property to your proxy URL before configuring Purchases *only* if you've received a proxy key value
|
|
462
490
|
* from your RevenueCat contact.
|
|
463
|
-
* @returns {Promise<void>} The promise
|
|
464
|
-
* setting the proxy url.
|
|
491
|
+
* @returns {Promise<void>} The promise to be returned after setting the proxy has been completed.
|
|
465
492
|
*/
|
|
466
493
|
static setProxyURL(url: string): Promise<void>;
|
|
467
494
|
/**
|
|
@@ -673,5 +700,6 @@ export default class Purchases {
|
|
|
673
700
|
private static throwIfNotConfigured;
|
|
674
701
|
private static throwIfAndroidPlatform;
|
|
675
702
|
private static throwIfIOSPlatform;
|
|
703
|
+
private static isPurchasesAreCompletedByMyApp;
|
|
676
704
|
private static convertIntToRefundRequestStatus;
|
|
677
705
|
}
|
package/dist/purchases.js
CHANGED
|
@@ -36,15 +36,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.LOG_LEVEL = exports.REFUND_REQUEST_STATUS = exports.BILLING_FEATURE = exports.PURCHASE_TYPE = void 0;
|
|
39
|
+
exports.STOREKIT_VERSION = exports.LOG_LEVEL = exports.REFUND_REQUEST_STATUS = exports.BILLING_FEATURE = exports.PURCHASES_ARE_COMPLETED_BY_TYPE = exports.PURCHASE_TYPE = void 0;
|
|
40
40
|
var react_native_1 = require("react-native");
|
|
41
41
|
var purchases_typescript_internal_1 = require("@revenuecat/purchases-typescript-internal");
|
|
42
42
|
// This export is kept to keep backwards compatibility to any possible users using this file directly
|
|
43
43
|
var purchases_typescript_internal_2 = require("@revenuecat/purchases-typescript-internal");
|
|
44
44
|
Object.defineProperty(exports, "PURCHASE_TYPE", { enumerable: true, get: function () { return purchases_typescript_internal_2.PURCHASE_TYPE; } });
|
|
45
|
+
Object.defineProperty(exports, "PURCHASES_ARE_COMPLETED_BY_TYPE", { enumerable: true, get: function () { return purchases_typescript_internal_2.PURCHASES_ARE_COMPLETED_BY_TYPE; } });
|
|
45
46
|
Object.defineProperty(exports, "BILLING_FEATURE", { enumerable: true, get: function () { return purchases_typescript_internal_2.BILLING_FEATURE; } });
|
|
46
47
|
Object.defineProperty(exports, "REFUND_REQUEST_STATUS", { enumerable: true, get: function () { return purchases_typescript_internal_2.REFUND_REQUEST_STATUS; } });
|
|
47
48
|
Object.defineProperty(exports, "LOG_LEVEL", { enumerable: true, get: function () { return purchases_typescript_internal_2.LOG_LEVEL; } });
|
|
49
|
+
Object.defineProperty(exports, "STOREKIT_VERSION", { enumerable: true, get: function () { return purchases_typescript_internal_2.STOREKIT_VERSION; } });
|
|
48
50
|
var react_native_2 = require("react-native");
|
|
49
51
|
var RNPurchases = react_native_1.NativeModules.RNPurchases;
|
|
50
52
|
var eventEmitter = new react_native_1.NativeEventEmitter(RNPurchases);
|
|
@@ -72,24 +74,41 @@ var Purchases = /** @class */ (function () {
|
|
|
72
74
|
* Sets up Purchases with your API key and an app user id.
|
|
73
75
|
* @param {String} apiKey RevenueCat API Key. Needs to be a String
|
|
74
76
|
* @param {String?} appUserID An optional unique id for identifying the user. Needs to be a string.
|
|
75
|
-
* @param {
|
|
76
|
-
* @param {STOREKIT_VERSION} [storeKitVersion=
|
|
77
|
-
* We recommend not using this parameter, letting RevenueCat decide for you which StoreKit implementation to use.
|
|
77
|
+
* @param {PurchasesAreCompletedBy} [purchasesAreCompletedBy=PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT] Set this to an instance of PurchasesAreCompletedByMyApp if you have your own IAP implementation and want to use only RevenueCat's backend. Default is PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT.
|
|
78
|
+
* @param {STOREKIT_VERSION} [storeKitVersion=DEFAULT] iOS-only. Defaults to STOREKIT_2. StoreKit 2 is only available on iOS 16+. StoreKit 1 will be used for previous iOS versions regardless of this setting.
|
|
78
79
|
* @param {ENTITLEMENT_VERIFICATION_MODE} [entitlementVerificationMode=ENTITLEMENT_VERIFICATION_MODE.DISABLED] Sets the entitlement verifciation mode to use. For more details, check https://rev.cat/trusted-entitlements
|
|
79
80
|
* @param {boolean} [useAmazon=false] An optional boolean. Android-only. Set this to TRUE to enable Amazon on compatible devices.
|
|
80
81
|
* @param {String?} userDefaultsSuiteName An optional string. iOS-only, will be ignored for Android.
|
|
81
82
|
* Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults suite, otherwise it will use standardUserDefaults.
|
|
82
83
|
* Default is null, which will make the SDK use standardUserDefaults.
|
|
84
|
+
* @param {boolean} [pendingTransactionsForPrepaidPlansEnabled=false] An optional boolean. Android-only. Set this to TRUE to enable pending transactions for prepaid subscriptions in Google Play.
|
|
85
|
+
*
|
|
86
|
+
* @warning If you use purchasesAreCompletedBy=PurchasesAreCompletedByMyApp, you must also provide a value for storeKitVersion.
|
|
83
87
|
*/
|
|
84
88
|
Purchases.configure = function (_a) {
|
|
85
|
-
var apiKey = _a.apiKey, _b = _a.appUserID, appUserID = _b === void 0 ? null : _b, _c = _a.
|
|
89
|
+
var apiKey = _a.apiKey, _b = _a.appUserID, appUserID = _b === void 0 ? null : _b, _c = _a.purchasesAreCompletedBy, purchasesAreCompletedBy = _c === void 0 ? purchases_typescript_internal_1.PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT : _c, userDefaultsSuiteName = _a.userDefaultsSuiteName, _d = _a.storeKitVersion, storeKitVersion = _d === void 0 ? purchases_typescript_internal_1.STOREKIT_VERSION.DEFAULT : _d, _e = _a.useAmazon, useAmazon = _e === void 0 ? false : _e, _f = _a.shouldShowInAppMessagesAutomatically, shouldShowInAppMessagesAutomatically = _f === void 0 ? true : _f, _g = _a.entitlementVerificationMode, entitlementVerificationMode = _g === void 0 ? purchases_typescript_internal_1.ENTITLEMENT_VERIFICATION_MODE.DISABLED : _g, _h = _a.pendingTransactionsForPrepaidPlansEnabled, pendingTransactionsForPrepaidPlansEnabled = _h === void 0 ? false : _h;
|
|
86
90
|
if (apiKey === undefined || typeof apiKey !== "string") {
|
|
87
|
-
throw new Error(
|
|
91
|
+
throw new Error('Invalid API key. It must be called with an Object: configure({apiKey: "key"})');
|
|
88
92
|
}
|
|
89
|
-
if (appUserID !== null &&
|
|
93
|
+
if (appUserID !== null &&
|
|
94
|
+
typeof appUserID !== "undefined" &&
|
|
95
|
+
typeof appUserID !== "string") {
|
|
90
96
|
throw new Error("appUserID needs to be a string");
|
|
91
97
|
}
|
|
92
|
-
|
|
98
|
+
var purchasesCompletedByToUse = purchases_typescript_internal_1.PURCHASES_ARE_COMPLETED_BY_TYPE.REVENUECAT;
|
|
99
|
+
var storeKitVersionToUse = storeKitVersion;
|
|
100
|
+
if (Purchases.isPurchasesAreCompletedByMyApp(purchasesAreCompletedBy)) {
|
|
101
|
+
purchasesCompletedByToUse = purchases_typescript_internal_1.PURCHASES_ARE_COMPLETED_BY_TYPE.MY_APP;
|
|
102
|
+
storeKitVersionToUse = purchasesAreCompletedBy.storeKitVersion;
|
|
103
|
+
if (storeKitVersionToUse !== storeKitVersion) {
|
|
104
|
+
// Typically, console messages aren't used in TS libraries, but in this case it's worth calling out the difference in
|
|
105
|
+
// StoreKit versions, and since the difference isn't possible farther down the call chain, we should go ahead
|
|
106
|
+
// and log it here.
|
|
107
|
+
// tslint:disable-next-line:no-console
|
|
108
|
+
console.warn("Warning: The storeKitVersion in purchasesAreCompletedBy does not match the function's storeKitVersion parameter. We will use the value found in purchasesAreCompletedBy.");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
RNPurchases.setupPurchases(apiKey, appUserID, purchasesCompletedByToUse, userDefaultsSuiteName, storeKitVersionToUse, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode, pendingTransactionsForPrepaidPlansEnabled);
|
|
93
112
|
};
|
|
94
113
|
/**
|
|
95
114
|
* @deprecated, configure behavior through the RevenueCat dashboard instead.
|
|
@@ -112,24 +131,6 @@ var Purchases = /** @class */ (function () {
|
|
|
112
131
|
});
|
|
113
132
|
});
|
|
114
133
|
};
|
|
115
|
-
/**
|
|
116
|
-
* @param {boolean} finishTransactions Set finishTransactions to false if you aren't using Purchases SDK to
|
|
117
|
-
* make the purchase
|
|
118
|
-
* @returns {Promise<void>} The promise will be rejected if configure has not been called yet.
|
|
119
|
-
*/
|
|
120
|
-
Purchases.setFinishTransactions = function (finishTransactions) {
|
|
121
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
-
return __generator(this, function (_a) {
|
|
123
|
-
switch (_a.label) {
|
|
124
|
-
case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
125
|
-
case 1:
|
|
126
|
-
_a.sent();
|
|
127
|
-
RNPurchases.setFinishTransactions(finishTransactions);
|
|
128
|
-
return [2 /*return*/];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
134
|
/**
|
|
134
135
|
* iOS only.
|
|
135
136
|
* @param {boolean} simulatesAskToBuyInSandbox Set this property to true *only* when testing the ask-to-buy / SCA
|
|
@@ -191,7 +192,8 @@ var Purchases = /** @class */ (function () {
|
|
|
191
192
|
*/
|
|
192
193
|
Purchases.removeShouldPurchasePromoProductListener = function (listenerToRemove) {
|
|
193
194
|
if (shouldPurchasePromoProductListeners.includes(listenerToRemove)) {
|
|
194
|
-
shouldPurchasePromoProductListeners =
|
|
195
|
+
shouldPurchasePromoProductListeners =
|
|
196
|
+
shouldPurchasePromoProductListeners.filter(function (listener) { return listenerToRemove !== listener; });
|
|
195
197
|
return true;
|
|
196
198
|
}
|
|
197
199
|
return false;
|
|
@@ -213,6 +215,44 @@ var Purchases = /** @class */ (function () {
|
|
|
213
215
|
});
|
|
214
216
|
});
|
|
215
217
|
};
|
|
218
|
+
/**
|
|
219
|
+
* Retrieves a current offering for a placement identifier, use this to access offerings defined by targeting
|
|
220
|
+
* placements configured in the RevenueCat dashboard.
|
|
221
|
+
* @param {String} placementIdentifier The placement identifier to fetch a current offeringn for
|
|
222
|
+
* @returns {Promise<PurchasesOffering | null>} Promise of an optional offering. The promise will be rejected if configure
|
|
223
|
+
* has not been called yet.
|
|
224
|
+
*/
|
|
225
|
+
Purchases.getCurrentOfferingForPlacement = function (placementIdentifier) {
|
|
226
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
227
|
+
return __generator(this, function (_a) {
|
|
228
|
+
switch (_a.label) {
|
|
229
|
+
case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
230
|
+
case 1:
|
|
231
|
+
_a.sent();
|
|
232
|
+
return [2 /*return*/, RNPurchases.getCurrentOfferingForPlacement(placementIdentifier)];
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Syncs subscriber attributes and then fetches the configured offerings for this user. This method is intended to
|
|
239
|
+
* be called when using Targeting Rules with Custom Attributes. Any subscriber attributes should be set before
|
|
240
|
+
* calling this method to ensure the returned offerings are applied with the latest subscriber attributes.
|
|
241
|
+
* @returns {Promise<PurchasesOfferings>} Promise of entitlements structure. The promise will be rejected if configure
|
|
242
|
+
* has not been called yet.
|
|
243
|
+
*/
|
|
244
|
+
Purchases.syncAttributesAndOfferingsIfNeeded = function () {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
+
return __generator(this, function (_a) {
|
|
247
|
+
switch (_a.label) {
|
|
248
|
+
case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
249
|
+
case 1:
|
|
250
|
+
_a.sent();
|
|
251
|
+
return [2 /*return*/, RNPurchases.syncAttributesAndOfferingsIfNeeded()];
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
};
|
|
216
256
|
/**
|
|
217
257
|
* Fetch the product info
|
|
218
258
|
* @param {String[]} productIdentifiers Array of product identifiers
|
|
@@ -222,9 +262,9 @@ var Purchases = /** @class */ (function () {
|
|
|
222
262
|
* Rejections return an error code, and a userInfo object with more information. The promise will also be rejected
|
|
223
263
|
* if configure has not been called yet.
|
|
224
264
|
*/
|
|
225
|
-
Purchases.getProducts = function (
|
|
226
|
-
|
|
227
|
-
|
|
265
|
+
Purchases.getProducts = function (productIdentifiers_1) {
|
|
266
|
+
return __awaiter(this, arguments, void 0, function (productIdentifiers, type) {
|
|
267
|
+
if (type === void 0) { type = purchases_typescript_internal_1.PRODUCT_CATEGORY.SUBSCRIPTION; }
|
|
228
268
|
return __generator(this, function (_a) {
|
|
229
269
|
switch (_a.label) {
|
|
230
270
|
case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
@@ -244,16 +284,17 @@ var Purchases = /** @class */ (function () {
|
|
|
244
284
|
* @param {String} type Optional type of product, can be inapp or subs. Subs by default
|
|
245
285
|
* @deprecated, use purchaseStoreProduct instead
|
|
246
286
|
*/
|
|
247
|
-
Purchases.purchaseProduct = function (
|
|
248
|
-
|
|
249
|
-
|
|
287
|
+
Purchases.purchaseProduct = function (productIdentifier_1, upgradeInfo_1) {
|
|
288
|
+
return __awaiter(this, arguments, void 0, function (productIdentifier, upgradeInfo, type) {
|
|
289
|
+
if (type === void 0) { type = purchases_typescript_internal_1.PURCHASE_TYPE.SUBS; }
|
|
250
290
|
return __generator(this, function (_a) {
|
|
251
291
|
switch (_a.label) {
|
|
252
292
|
case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
253
293
|
case 1:
|
|
254
294
|
_a.sent();
|
|
255
295
|
return [2 /*return*/, RNPurchases.purchaseProduct(productIdentifier, upgradeInfo, type, null, null, null).catch(function (error) {
|
|
256
|
-
error.userCancelled =
|
|
296
|
+
error.userCancelled =
|
|
297
|
+
error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
|
|
257
298
|
throw error;
|
|
258
299
|
})];
|
|
259
300
|
}
|
|
@@ -281,8 +322,11 @@ var Purchases = /** @class */ (function () {
|
|
|
281
322
|
case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
282
323
|
case 1:
|
|
283
324
|
_a.sent();
|
|
284
|
-
return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, googleProductChangeInfo, product.productCategory, null, googleIsPersonalizedPrice == null
|
|
285
|
-
|
|
325
|
+
return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, googleProductChangeInfo, product.productCategory, null, googleIsPersonalizedPrice == null
|
|
326
|
+
? null
|
|
327
|
+
: { isPersonalizedPrice: googleIsPersonalizedPrice }, product.presentedOfferingContext).catch(function (error) {
|
|
328
|
+
error.userCancelled =
|
|
329
|
+
error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
|
|
286
330
|
throw error;
|
|
287
331
|
})];
|
|
288
332
|
}
|
|
@@ -312,8 +356,9 @@ var Purchases = /** @class */ (function () {
|
|
|
312
356
|
if (typeof discount === "undefined" || discount == null) {
|
|
313
357
|
throw new Error("A discount is required");
|
|
314
358
|
}
|
|
315
|
-
return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, null, null, discount.timestamp.toString(), null, product.
|
|
316
|
-
error.userCancelled =
|
|
359
|
+
return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, null, null, discount.timestamp.toString(), null, product.presentedOfferingContext).catch(function (error) {
|
|
360
|
+
error.userCancelled =
|
|
361
|
+
error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
|
|
317
362
|
throw error;
|
|
318
363
|
})];
|
|
319
364
|
}
|
|
@@ -342,8 +387,11 @@ var Purchases = /** @class */ (function () {
|
|
|
342
387
|
case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
343
388
|
case 1:
|
|
344
389
|
_a.sent();
|
|
345
|
-
return [2 /*return*/, RNPurchases.purchasePackage(aPackage.identifier, aPackage.
|
|
346
|
-
|
|
390
|
+
return [2 /*return*/, RNPurchases.purchasePackage(aPackage.identifier, aPackage.presentedOfferingContext, googleProductChangeInfo || upgradeInfo, null, googleIsPersonalizedPrice == null
|
|
391
|
+
? null
|
|
392
|
+
: { isPersonalizedPrice: googleIsPersonalizedPrice }).catch(function (error) {
|
|
393
|
+
error.userCancelled =
|
|
394
|
+
error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
|
|
347
395
|
throw error;
|
|
348
396
|
})];
|
|
349
397
|
}
|
|
@@ -374,8 +422,11 @@ var Purchases = /** @class */ (function () {
|
|
|
374
422
|
return [4 /*yield*/, Purchases.throwIfIOSPlatform()];
|
|
375
423
|
case 2:
|
|
376
424
|
_a.sent();
|
|
377
|
-
return [2 /*return*/, RNPurchases.purchaseSubscriptionOption(subscriptionOption.productId, subscriptionOption.id, googleProductChangeInfo, null, googleIsPersonalizedPrice == null
|
|
378
|
-
|
|
425
|
+
return [2 /*return*/, RNPurchases.purchaseSubscriptionOption(subscriptionOption.productId, subscriptionOption.id, googleProductChangeInfo, null, googleIsPersonalizedPrice == null
|
|
426
|
+
? null
|
|
427
|
+
: { isPersonalizedPrice: googleIsPersonalizedPrice }, subscriptionOption.presentedOfferingContext).catch(function (error) {
|
|
428
|
+
error.userCancelled =
|
|
429
|
+
error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
|
|
379
430
|
throw error;
|
|
380
431
|
})];
|
|
381
432
|
}
|
|
@@ -402,8 +453,9 @@ var Purchases = /** @class */ (function () {
|
|
|
402
453
|
if (typeof discount === "undefined" || discount == null) {
|
|
403
454
|
throw new Error("A discount is required");
|
|
404
455
|
}
|
|
405
|
-
return [2 /*return*/, RNPurchases.purchasePackage(aPackage.identifier, aPackage.
|
|
406
|
-
error.userCancelled =
|
|
456
|
+
return [2 /*return*/, RNPurchases.purchasePackage(aPackage.identifier, aPackage.presentedOfferingContext, null, discount.timestamp.toString(), null).catch(function (error) {
|
|
457
|
+
error.userCancelled =
|
|
458
|
+
error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
|
|
407
459
|
throw error;
|
|
408
460
|
})];
|
|
409
461
|
}
|
|
@@ -575,6 +627,38 @@ var Purchases = /** @class */ (function () {
|
|
|
575
627
|
* @returns {Promise<void>} The promise will be rejected if configure has not been called yet or if there's an error
|
|
576
628
|
* syncing purchases.
|
|
577
629
|
*/
|
|
630
|
+
Purchases.syncAmazonPurchase = function (productID, receiptID, amazonUserID, isoCurrencyCode, price) {
|
|
631
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
632
|
+
return __generator(this, function (_a) {
|
|
633
|
+
switch (_a.label) {
|
|
634
|
+
case 0: return [4 /*yield*/, Purchases.throwIfIOSPlatform()];
|
|
635
|
+
case 1:
|
|
636
|
+
_a.sent();
|
|
637
|
+
return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
638
|
+
case 2:
|
|
639
|
+
_a.sent();
|
|
640
|
+
RNPurchases.syncAmazonPurchase(productID, receiptID, amazonUserID, isoCurrencyCode, price);
|
|
641
|
+
return [2 /*return*/];
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
});
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* @deprecated, use syncAmazonPurchase instead.
|
|
648
|
+
*
|
|
649
|
+
* This method will send a purchase to the RevenueCat backend. This function should only be called if you are
|
|
650
|
+
* in Amazon observer mode or performing a client side migration of your current users to RevenueCat.
|
|
651
|
+
*
|
|
652
|
+
* The receipt IDs are cached if successfully posted so they are not posted more than once.
|
|
653
|
+
*
|
|
654
|
+
* @param {string} productID Product ID associated to the purchase.
|
|
655
|
+
* @param {string} receiptID ReceiptId that represents the Amazon purchase.
|
|
656
|
+
* @param {string} amazonUserID Amazon's userID. This parameter will be ignored when syncing a Google purchase.
|
|
657
|
+
* @param {(string|null|undefined)} isoCurrencyCode Product's currency code in ISO 4217 format.
|
|
658
|
+
* @param {(number|null|undefined)} price Product's price.
|
|
659
|
+
* @returns {Promise<void>} The promise will be rejected if configure has not been called yet or if there's an error
|
|
660
|
+
* syncing purchases.
|
|
661
|
+
*/
|
|
578
662
|
Purchases.syncObserverModeAmazonPurchase = function (productID, receiptID, amazonUserID, isoCurrencyCode, price) {
|
|
579
663
|
return __awaiter(this, void 0, void 0, function () {
|
|
580
664
|
return __generator(this, function (_a) {
|
|
@@ -599,14 +683,14 @@ var Purchases = /** @class */ (function () {
|
|
|
599
683
|
*
|
|
600
684
|
* You only need to use this method with *new* purchases. Subscription updates are observed automatically.
|
|
601
685
|
*
|
|
602
|
-
* Important: This should only be used if you have
|
|
686
|
+
* Important: This should only be used if you have set PurchasesAreCompletedBy to MY_APP during SDK configuration.
|
|
603
687
|
*
|
|
604
688
|
* @warning You need to finish the transaction yourself after calling this method.
|
|
605
689
|
*
|
|
606
690
|
* @param {string} productID Product ID that was just purchased
|
|
607
691
|
* @returns {Promise<PurchasesStoreTransaction>} If there was a transacton found and handled for the provided product ID.
|
|
608
692
|
*/
|
|
609
|
-
Purchases.
|
|
693
|
+
Purchases.recordPurchase = function (productID) {
|
|
610
694
|
return __awaiter(this, void 0, void 0, function () {
|
|
611
695
|
return __generator(this, function (_a) {
|
|
612
696
|
switch (_a.label) {
|
|
@@ -616,24 +700,8 @@ var Purchases = /** @class */ (function () {
|
|
|
616
700
|
return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
617
701
|
case 2:
|
|
618
702
|
_a.sent();
|
|
619
|
-
return [2 /*return*/, RNPurchases.
|
|
620
|
-
}
|
|
621
|
-
});
|
|
622
|
-
});
|
|
623
|
-
};
|
|
624
|
-
/**
|
|
625
|
-
* @deprecated, use enableAdServicesAttributionTokenCollection instead.
|
|
626
|
-
* Enable automatic collection of Apple Search Ad attribution. Disabled by default
|
|
627
|
-
* @param {boolean} enabled Enable or not automatic apple search ads attribution collection
|
|
628
|
-
* @returns {Promise<void>} The promise will be rejected if configure has not been called yet.
|
|
629
|
-
*/
|
|
630
|
-
Purchases.setAutomaticAppleSearchAdsAttributionCollection = function (enabled) {
|
|
631
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
632
|
-
return __generator(this, function (_a) {
|
|
633
|
-
if (react_native_2.Platform.OS === "ios") {
|
|
634
|
-
RNPurchases.setAutomaticAppleSearchAdsAttributionCollection(enabled);
|
|
703
|
+
return [2 /*return*/, RNPurchases.recordPurchaseForProductID(productID)];
|
|
635
704
|
}
|
|
636
|
-
return [2 /*return*/];
|
|
637
705
|
});
|
|
638
706
|
});
|
|
639
707
|
};
|
|
@@ -882,19 +950,12 @@ var Purchases = /** @class */ (function () {
|
|
|
882
950
|
/**
|
|
883
951
|
* Set this property to your proxy URL before configuring Purchases *only* if you've received a proxy key value
|
|
884
952
|
* from your RevenueCat contact.
|
|
885
|
-
* @returns {Promise<void>} The promise
|
|
886
|
-
* setting the proxy url.
|
|
953
|
+
* @returns {Promise<void>} The promise to be returned after setting the proxy has been completed.
|
|
887
954
|
*/
|
|
888
955
|
Purchases.setProxyURL = function (url) {
|
|
889
956
|
return __awaiter(this, void 0, void 0, function () {
|
|
890
957
|
return __generator(this, function (_a) {
|
|
891
|
-
|
|
892
|
-
case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
893
|
-
case 1:
|
|
894
|
-
_a.sent();
|
|
895
|
-
RNPurchases.setProxyURLString(url);
|
|
896
|
-
return [2 /*return*/];
|
|
897
|
-
}
|
|
958
|
+
return [2 /*return*/, RNPurchases.setProxyURLString(url)];
|
|
898
959
|
});
|
|
899
960
|
});
|
|
900
961
|
};
|
|
@@ -1411,6 +1472,12 @@ var Purchases = /** @class */ (function () {
|
|
|
1411
1472
|
});
|
|
1412
1473
|
});
|
|
1413
1474
|
};
|
|
1475
|
+
Purchases.isPurchasesAreCompletedByMyApp = function (obj) {
|
|
1476
|
+
return (typeof obj === "object" &&
|
|
1477
|
+
obj !== null &&
|
|
1478
|
+
obj.type ===
|
|
1479
|
+
purchases_typescript_internal_1.PURCHASES_ARE_COMPLETED_BY_TYPE.MY_APP);
|
|
1480
|
+
};
|
|
1414
1481
|
Purchases.convertIntToRefundRequestStatus = function (refundRequestStatusInt) {
|
|
1415
1482
|
switch (refundRequestStatusInt) {
|
|
1416
1483
|
case 0:
|
|
@@ -1502,6 +1569,12 @@ var Purchases = /** @class */ (function () {
|
|
|
1502
1569
|
* @enum {string}
|
|
1503
1570
|
*/
|
|
1504
1571
|
Purchases.STOREKIT_VERSION = purchases_typescript_internal_1.STOREKIT_VERSION;
|
|
1572
|
+
/**
|
|
1573
|
+
* Enum of PurchasesAreCompletedByType.
|
|
1574
|
+
* @readonly
|
|
1575
|
+
* @enum {string}
|
|
1576
|
+
*/
|
|
1577
|
+
Purchases.PURCHASES_ARE_COMPLETED_BY_TYPE = purchases_typescript_internal_1.PURCHASES_ARE_COMPLETED_BY_TYPE;
|
|
1505
1578
|
/**
|
|
1506
1579
|
* @internal
|
|
1507
1580
|
*/
|
package/ios/RNPurchases.m
CHANGED
|
@@ -39,15 +39,16 @@ RCT_EXPORT_MODULE();
|
|
|
39
39
|
|
|
40
40
|
RCT_EXPORT_METHOD(setupPurchases:(NSString *)apiKey
|
|
41
41
|
appUserID:(nullable NSString *)appUserID
|
|
42
|
-
|
|
42
|
+
purchasesAreCompletedBy:(nullable NSString *)purchasesAreCompletedBy
|
|
43
43
|
userDefaultsSuiteName:(nullable NSString *)userDefaultsSuiteName
|
|
44
44
|
storeKitVersion:(nullable NSString *)storeKitVersion
|
|
45
45
|
useAmazon:(BOOL)useAmazon
|
|
46
46
|
shouldShowInAppMessagesAutomatically:(BOOL)shouldShowInAppMessagesAutomatically
|
|
47
|
-
entitlementVerificationMode:(nullable NSString *)entitlementVerificationMode
|
|
47
|
+
entitlementVerificationMode:(nullable NSString *)entitlementVerificationMode
|
|
48
|
+
pendingTransactionsForPrepaidPlansEnabled:(BOOL)pendingTransactionsForPrepaidPlansEnabled) {
|
|
48
49
|
RCPurchases *purchases = [RCPurchases configureWithAPIKey:apiKey
|
|
49
50
|
appUserID:appUserID
|
|
50
|
-
|
|
51
|
+
purchasesAreCompletedBy:purchasesAreCompletedBy
|
|
51
52
|
userDefaultsSuiteName:userDefaultsSuiteName
|
|
52
53
|
platformFlavor:self.platformFlavor
|
|
53
54
|
platformFlavorVersion:self.platformFlavorVersion
|
|
@@ -65,10 +66,6 @@ RCT_EXPORT_METHOD(setAllowSharingStoreAccount:(BOOL)allowSharingStoreAccount) {
|
|
|
65
66
|
#pragma GCC diagnostic pop
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
RCT_EXPORT_METHOD(setFinishTransactions:(BOOL)finishTransactions) {
|
|
69
|
-
[RCCommonFunctionality setFinishTransactions:finishTransactions];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
69
|
RCT_REMAP_METHOD(getOfferings,
|
|
73
70
|
getOfferingsWithResolve:(RCTPromiseResolveBlock)resolve
|
|
74
71
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -76,6 +73,24 @@ RCT_REMAP_METHOD(getOfferings,
|
|
|
76
73
|
reject:reject]];
|
|
77
74
|
}
|
|
78
75
|
|
|
76
|
+
RCT_REMAP_METHOD(syncAttributesAndOfferingsIfNeeded,
|
|
77
|
+
syncAttributesAndOfferingsIfNeededWithResolve:(RCTPromiseResolveBlock)resolve
|
|
78
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
79
|
+
[RCCommonFunctionality syncAttributesAndOfferingsIfNeededWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve
|
|
80
|
+
reject:reject]];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
RCT_EXPORT_METHOD(getCurrentOfferingForPlacement:(NSString *)placementIdentifier
|
|
84
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
85
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
86
|
+
|
|
87
|
+
[RCCommonFunctionality getCurrentOfferingForPlacement:placementIdentifier completionBlock:^(NSDictionary *offeringObject, RCErrorContainer *error) {
|
|
88
|
+
resolve(offeringObject);
|
|
89
|
+
}];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//syncAttributesAndOfferingsIfNeeded
|
|
93
|
+
|
|
79
94
|
RCT_EXPORT_METHOD(getProductInfo:(NSArray *)products
|
|
80
95
|
type:(NSString *)type
|
|
81
96
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
@@ -91,7 +106,7 @@ RCT_REMAP_METHOD(purchaseProduct,
|
|
|
91
106
|
type:(NSString *)type
|
|
92
107
|
signedDiscountTimestamp:(NSString *)signedDiscountTimestamp
|
|
93
108
|
googleInfo:(NSDictionary *)googleInfo
|
|
94
|
-
|
|
109
|
+
presentedOfferingContext:(NSDictionary *)presentedOfferingDictionary
|
|
95
110
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
96
111
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
97
112
|
[RCCommonFunctionality purchaseProduct:productIdentifier
|
|
@@ -102,14 +117,14 @@ RCT_REMAP_METHOD(purchaseProduct,
|
|
|
102
117
|
|
|
103
118
|
RCT_REMAP_METHOD(purchasePackage,
|
|
104
119
|
purchasePackage:(NSString *)packageIdentifier
|
|
105
|
-
|
|
120
|
+
presentedOfferingContext:(NSDictionary *)presentedOfferingContext
|
|
106
121
|
upgradeInfo:(NSDictionary *)upgradeInfo
|
|
107
122
|
signedDiscountTimestamp:(NSString *)signedDiscountTimestamp
|
|
108
123
|
googleInfo:(NSDictionary *)googleInfo
|
|
109
124
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
110
125
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
111
126
|
[RCCommonFunctionality purchasePackage:packageIdentifier
|
|
112
|
-
|
|
127
|
+
presentedOfferingContext:presentedOfferingContext
|
|
113
128
|
signedDiscountTimestamp:signedDiscountTimestamp
|
|
114
129
|
completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
|
|
115
130
|
}
|
|
@@ -165,18 +180,17 @@ RCT_REMAP_METHOD(getCustomerInfo,
|
|
|
165
180
|
[RCCommonFunctionality getCustomerInfoWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
|
|
166
181
|
}
|
|
167
182
|
|
|
168
|
-
RCT_EXPORT_METHOD(setAutomaticAppleSearchAdsAttributionCollection:(BOOL)automaticAppleSearchAdsAttributionCollection)
|
|
169
|
-
{
|
|
170
|
-
[RCCommonFunctionality setAutomaticAppleSearchAdsAttributionCollection:automaticAppleSearchAdsAttributionCollection];
|
|
171
|
-
}
|
|
172
|
-
|
|
173
183
|
RCT_EXPORT_METHOD(enableAdServicesAttributionTokenCollection)
|
|
174
184
|
{
|
|
185
|
+
#if !TARGET_OS_TV
|
|
175
186
|
if (@available(iOS 14.3, macOS 11.1, macCatalyst 14.3, *)) {
|
|
176
187
|
[RCCommonFunctionality enableAdServicesAttributionTokenCollection];
|
|
177
188
|
} else {
|
|
178
189
|
NSLog(@"[Purchases] Warning: tried to enable AdServices attribution token collection, but it's only available on iOS 14.3 or greater or macOS 11.1 or greater.");
|
|
179
190
|
}
|
|
191
|
+
#else
|
|
192
|
+
NSLog(@"[Purchases] Warning: AdServices attribution token collection is not available on tvOS.");
|
|
193
|
+
#endif
|
|
180
194
|
}
|
|
181
195
|
|
|
182
196
|
RCT_REMAP_METHOD(isAnonymous,
|
|
@@ -217,14 +231,14 @@ RCT_REMAP_METHOD(getPromotionalOffer,
|
|
|
217
231
|
}
|
|
218
232
|
|
|
219
233
|
RCT_EXPORT_METHOD(presentCodeRedemptionSheet) {
|
|
220
|
-
#if TARGET_OS_MACCATALYST
|
|
221
|
-
logUnavailablePresentCodeRedemptionSheet();
|
|
222
|
-
#else
|
|
234
|
+
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
|
|
223
235
|
if (@available(iOS 14.0, *)) {
|
|
224
236
|
[RCCommonFunctionality presentCodeRedemptionSheet];
|
|
225
237
|
} else {
|
|
226
238
|
logUnavailablePresentCodeRedemptionSheet();
|
|
227
239
|
}
|
|
240
|
+
#else
|
|
241
|
+
logUnavailablePresentCodeRedemptionSheet();
|
|
228
242
|
#endif
|
|
229
243
|
}
|
|
230
244
|
|
|
@@ -232,26 +246,13 @@ static void logUnavailablePresentCodeRedemptionSheet() {
|
|
|
232
246
|
NSLog(@"[Purchases] Warning: tried to present codeRedemptionSheet, but it's only available on iOS 14.0 or greater.");
|
|
233
247
|
}
|
|
234
248
|
|
|
235
|
-
RCT_EXPORT_METHOD(handleObserverModeTransactionForProductID:(nonnull NSString *)productID
|
|
236
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
237
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
238
|
-
if (@available(iOS 15.0, *)) {
|
|
239
|
-
[RCCommonFunctionality handleObserverModeTransactionForProductID:productID
|
|
240
|
-
completion:[self getResponseCompletionBlockWithResolve:resolve
|
|
241
|
-
reject:reject]];
|
|
242
|
-
} else {
|
|
243
|
-
NSString* description = @"Tried to handle Observer Mode transaction, but it's only available on iOS 15.0 or greater.";
|
|
244
|
-
NSError* error = [[NSError alloc] initWithDomain: RCPurchasesErrorCodeDomain
|
|
245
|
-
code: RCUnsupportedError
|
|
246
|
-
userInfo: @{NSLocalizedDescriptionKey : description}];
|
|
247
|
-
reject([NSString stringWithFormat:@"%ld", (long) error.code], [error localizedDescription], error);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
249
|
#pragma mark - Subscriber Attributes
|
|
252
250
|
|
|
253
|
-
RCT_EXPORT_METHOD(setProxyURLString:(nullable NSString *)proxyURLString
|
|
251
|
+
RCT_EXPORT_METHOD(setProxyURLString:(nullable NSString *)proxyURLString
|
|
252
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
253
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
254
254
|
[RCCommonFunctionality setProxyURLString:proxyURLString];
|
|
255
|
+
resolve(nil); // Resolve the promise with no value
|
|
255
256
|
}
|
|
256
257
|
|
|
257
258
|
RCT_EXPORT_METHOD(setAttributes:(NSDictionary *)attributes) {
|
|
@@ -351,7 +352,7 @@ RCT_REMAP_METHOD(canMakePayments,
|
|
|
351
352
|
|
|
352
353
|
RCT_EXPORT_METHOD(beginRefundRequestForActiveEntitlement:(RCTPromiseResolveBlock)resolve
|
|
353
354
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
354
|
-
#if TARGET_OS_IPHONE
|
|
355
|
+
#if TARGET_OS_IPHONE && !TARGET_OS_TV
|
|
355
356
|
if (@available(iOS 15.0, *)) {
|
|
356
357
|
[RCCommonFunctionality beginRefundRequestForActiveEntitlementCompletion:[self getBeginRefundResponseCompletionBlockWithResolve:resolve
|
|
357
358
|
reject:reject]];
|
|
@@ -366,7 +367,7 @@ RCT_EXPORT_METHOD(beginRefundRequestForActiveEntitlement:(RCTPromiseResolveBlock
|
|
|
366
367
|
RCT_EXPORT_METHOD(beginRefundRequestForEntitlementId:(NSString *)entitlementIdentifier
|
|
367
368
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
368
369
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
369
|
-
#if TARGET_OS_IPHONE
|
|
370
|
+
#if TARGET_OS_IPHONE && !TARGET_OS_TV
|
|
370
371
|
if (@available(iOS 15.0, *)) {
|
|
371
372
|
[RCCommonFunctionality beginRefundRequestEntitlementId:entitlementIdentifier
|
|
372
373
|
completionBlock:[self getBeginRefundResponseCompletionBlockWithResolve:resolve
|
|
@@ -382,7 +383,7 @@ RCT_EXPORT_METHOD(beginRefundRequestForEntitlementId:(NSString *)entitlementIden
|
|
|
382
383
|
RCT_EXPORT_METHOD(beginRefundRequestForProductId:(NSString *)productIdentifier
|
|
383
384
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
384
385
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
385
|
-
#if TARGET_OS_IPHONE
|
|
386
|
+
#if TARGET_OS_IPHONE && !TARGET_OS_TV
|
|
386
387
|
if (@available(iOS 15.0, *)) {
|
|
387
388
|
[RCCommonFunctionality beginRefundRequestProductId:productIdentifier
|
|
388
389
|
completionBlock:[self getBeginRefundResponseCompletionBlockWithResolve:resolve
|
|
@@ -398,7 +399,7 @@ RCT_EXPORT_METHOD(beginRefundRequestForProductId:(NSString *)productIdentifier
|
|
|
398
399
|
RCT_EXPORT_METHOD(showInAppMessages:(NSArray<NSNumber *> *)messageTypes
|
|
399
400
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
400
401
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
401
|
-
#if TARGET_OS_IPHONE
|
|
402
|
+
#if TARGET_OS_IPHONE && !TARGET_OS_TV
|
|
402
403
|
if (@available(iOS 16.0, *)) {
|
|
403
404
|
if (messageTypes == nil) {
|
|
404
405
|
[RCCommonFunctionality showStoreMessagesCompletion:^{
|
|
@@ -432,6 +433,24 @@ RCT_EXPORT_METHOD(setLogHandler) {
|
|
|
432
433
|
}];
|
|
433
434
|
}
|
|
434
435
|
|
|
436
|
+
#pragma mark -
|
|
437
|
+
#pragma mark PurchasesAreCompletedBy Helper Functions
|
|
438
|
+
RCT_EXPORT_METHOD(recordPurchaseForProductID:(nonnull NSString *)productID
|
|
439
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
440
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
441
|
+
if (@available(iOS 15.0, *)) {
|
|
442
|
+
[RCCommonFunctionality recordPurchaseForProductID:productID
|
|
443
|
+
completion:[self getResponseCompletionBlockWithResolve:resolve
|
|
444
|
+
reject:reject]];
|
|
445
|
+
} else {
|
|
446
|
+
NSString* description = @"Tried to handle transaction made by your app, but this functionality is only available on iOS 15.0 or greater.";
|
|
447
|
+
NSError* error = [[NSError alloc] initWithDomain: RCPurchasesErrorCodeDomain
|
|
448
|
+
code: RCUnsupportedError
|
|
449
|
+
userInfo: @{NSLocalizedDescriptionKey : description}];
|
|
450
|
+
reject([NSString stringWithFormat:@"%ld", (long) error.code], [error localizedDescription], error);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
435
454
|
#pragma mark -
|
|
436
455
|
#pragma mark Delegate Methods
|
|
437
456
|
- (void)purchases:(RCPurchases *)purchases receivedUpdatedCustomerInfo:(RCCustomerInfo *)customerInfo {
|
|
@@ -488,7 +507,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
|
|
|
488
507
|
}
|
|
489
508
|
|
|
490
509
|
- (NSString *)platformFlavorVersion {
|
|
491
|
-
return @"8.0.0
|
|
510
|
+
return @"8.0.0";
|
|
492
511
|
}
|
|
493
512
|
|
|
494
513
|
@end
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-purchases",
|
|
3
3
|
"title": "React Native Purchases",
|
|
4
|
-
"version": "8.0.0
|
|
4
|
+
"version": "8.0.0",
|
|
5
5
|
"description": "React Native in-app purchases and subscriptions made easy. Supports iOS and Android. ",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"examples/purchaseTesterTypescript",
|
|
45
45
|
"react-native-purchases-ui"
|
|
46
46
|
],
|
|
47
|
+
"packageManager": "yarn@3.6.1",
|
|
47
48
|
"repository": {
|
|
48
49
|
"type": "git",
|
|
49
50
|
"url": "git+https://github.com/revenuecat/react-native-purchases.git",
|
|
@@ -63,27 +64,27 @@
|
|
|
63
64
|
"readmeFilename": "README.md",
|
|
64
65
|
"peerDependencies": {
|
|
65
66
|
"react": ">= 16.6.3",
|
|
66
|
-
"react-native": "
|
|
67
|
+
"react-native": "*"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
|
-
"@types/jest": "^
|
|
70
|
-
"@types/react": "
|
|
70
|
+
"@types/jest": "^29.5.12",
|
|
71
|
+
"@types/react": "^18.2.44",
|
|
71
72
|
"@types/react-dom": "~18.2.0",
|
|
72
|
-
"jest": "^
|
|
73
|
+
"jest": "^29.7.0",
|
|
73
74
|
"jest-react-native": "^18.0.0",
|
|
74
75
|
"pod-install": "^0.1.0",
|
|
75
76
|
"prettier": "^2.0.5",
|
|
76
77
|
"react": "18.2.0",
|
|
77
|
-
"react-native": "0.73.
|
|
78
|
-
"ts-jest": "^
|
|
78
|
+
"react-native": "0.73.5",
|
|
79
|
+
"ts-jest": "^29.1.2",
|
|
79
80
|
"tslint": "^5.20.0",
|
|
80
81
|
"tslint-config-prettier": "^1.18.0",
|
|
81
|
-
"typedoc": "^0.
|
|
82
|
-
"typescript": "^
|
|
82
|
+
"typedoc": "^0.25.11",
|
|
83
|
+
"typescript": "^5.2.2"
|
|
83
84
|
},
|
|
84
85
|
"resolutions": {
|
|
85
|
-
"@types/react": "18.2.
|
|
86
|
-
"@types/react-native": "0.73.
|
|
86
|
+
"@types/react": "^18.2.44",
|
|
87
|
+
"@types/react-native": "0.73.5",
|
|
87
88
|
"@types/react-dom": "18.2.0"
|
|
88
89
|
},
|
|
89
90
|
"jest": {
|
|
@@ -99,6 +100,6 @@
|
|
|
99
100
|
]
|
|
100
101
|
},
|
|
101
102
|
"dependencies": {
|
|
102
|
-
"@revenuecat/purchases-typescript-internal": "
|
|
103
|
+
"@revenuecat/purchases-typescript-internal": "13.0.0"
|
|
103
104
|
}
|
|
104
105
|
}
|