react-native-purchases 7.22.0 → 7.24.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/RNPurchases.podspec
CHANGED
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 '7.
|
|
32
|
+
versionName '7.24.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:10.2.0'
|
|
125
125
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
126
126
|
}
|
|
@@ -23,6 +23,7 @@ import com.revenuecat.purchases.Store;
|
|
|
23
23
|
import com.revenuecat.purchases.common.PlatformInfo;
|
|
24
24
|
import com.revenuecat.purchases.hybridcommon.CommonKt;
|
|
25
25
|
import com.revenuecat.purchases.hybridcommon.ErrorContainer;
|
|
26
|
+
import com.revenuecat.purchases.hybridcommon.OnNullableResult;
|
|
26
27
|
import com.revenuecat.purchases.hybridcommon.OnResult;
|
|
27
28
|
import com.revenuecat.purchases.hybridcommon.OnResultAny;
|
|
28
29
|
import com.revenuecat.purchases.hybridcommon.OnResultList;
|
|
@@ -45,7 +46,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
45
46
|
private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
|
|
46
47
|
private static final String LOG_HANDLER_EVENT = "Purchases-LogHandlerEvent";
|
|
47
48
|
public static final String PLATFORM_NAME = "react-native";
|
|
48
|
-
public static final String PLUGIN_VERSION = "7.
|
|
49
|
+
public static final String PLUGIN_VERSION = "7.24.0";
|
|
49
50
|
|
|
50
51
|
private final ReactApplicationContext reactContext;
|
|
51
52
|
|
|
@@ -114,6 +115,16 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
114
115
|
CommonKt.getOfferings(getOnResult(promise));
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
@ReactMethod
|
|
119
|
+
public void getCurrentOfferingForPlacement(String placementIdentifier, final Promise promise) {
|
|
120
|
+
CommonKt.getCurrentOfferingForPlacement(placementIdentifier, getOnNullableResult(promise));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@ReactMethod
|
|
124
|
+
public void syncAttributesAndOfferingsIfNeeded(final Promise promise) {
|
|
125
|
+
CommonKt.syncAttributesAndOfferingsIfNeeded(getOnResult(promise));
|
|
126
|
+
}
|
|
127
|
+
|
|
117
128
|
@ReactMethod
|
|
118
129
|
public void getProductInfo(ReadableArray productIDs, String type, final Promise promise) {
|
|
119
130
|
ArrayList<String> productIDList = new ArrayList<>();
|
|
@@ -144,12 +155,17 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
144
155
|
final String type,
|
|
145
156
|
@Nullable final String discountTimestamp,
|
|
146
157
|
@Nullable final ReadableMap googleInfo,
|
|
147
|
-
@Nullable final
|
|
158
|
+
@Nullable final ReadableMap presentedOfferingContext,
|
|
148
159
|
final Promise promise) {
|
|
149
160
|
GoogleUpgradeInfo googleUpgradeInfo = getUpgradeInfo(googleProductChangeInfo);
|
|
150
161
|
|
|
151
162
|
Boolean googleIsPersonalized = googleInfo != null && googleInfo.hasKey("isPersonalizedPrice") ? googleInfo.getBoolean("isPersonalizedPrice") : null;
|
|
152
163
|
|
|
164
|
+
Map<String, Object> mapPresentedOfferingContext = null;
|
|
165
|
+
if (presentedOfferingContext != null) {
|
|
166
|
+
mapPresentedOfferingContext = presentedOfferingContext.toHashMap();
|
|
167
|
+
}
|
|
168
|
+
|
|
153
169
|
CommonKt.purchaseProduct(
|
|
154
170
|
getCurrentActivity(),
|
|
155
171
|
productIdentifier,
|
|
@@ -158,13 +174,13 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
158
174
|
googleUpgradeInfo.getOldProductIdentifier(),
|
|
159
175
|
googleUpgradeInfo.getProrationMode(),
|
|
160
176
|
googleIsPersonalized,
|
|
161
|
-
|
|
177
|
+
mapPresentedOfferingContext,
|
|
162
178
|
getOnResult(promise));
|
|
163
179
|
}
|
|
164
180
|
|
|
165
181
|
@ReactMethod
|
|
166
182
|
public void purchasePackage(final String packageIdentifier,
|
|
167
|
-
final
|
|
183
|
+
final ReadableMap presentedOfferingContext,
|
|
168
184
|
@Nullable final ReadableMap googleProductChangeInfo,
|
|
169
185
|
@Nullable final String discountTimestamp,
|
|
170
186
|
@Nullable final ReadableMap googleInfo,
|
|
@@ -173,10 +189,12 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
173
189
|
|
|
174
190
|
Boolean googleIsPersonalized = googleInfo != null && googleInfo.hasKey("isPersonalizedPrice") ? googleInfo.getBoolean("isPersonalizedPrice") : null;
|
|
175
191
|
|
|
192
|
+
Map<String, Object> mapPresentedOfferingContext = presentedOfferingContext.toHashMap();
|
|
193
|
+
|
|
176
194
|
CommonKt.purchasePackage(
|
|
177
195
|
getCurrentActivity(),
|
|
178
196
|
packageIdentifier,
|
|
179
|
-
|
|
197
|
+
mapPresentedOfferingContext,
|
|
180
198
|
googleUpgradeInfo.getOldProductIdentifier(),
|
|
181
199
|
googleUpgradeInfo.getProrationMode(),
|
|
182
200
|
googleIsPersonalized,
|
|
@@ -189,12 +207,17 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
189
207
|
@Nullable final ReadableMap upgradeInfo,
|
|
190
208
|
@Nullable final String discountTimestamp,
|
|
191
209
|
@Nullable final ReadableMap googleInfo,
|
|
192
|
-
@Nullable final
|
|
210
|
+
@Nullable final ReadableMap presentedOfferingContext,
|
|
193
211
|
final Promise promise) {
|
|
194
212
|
GoogleUpgradeInfo googleUpgradeInfo = getUpgradeInfo(upgradeInfo);
|
|
195
213
|
|
|
196
214
|
Boolean googleIsPersonalized = googleInfo != null && googleInfo.hasKey("isPersonalizedPrice") ? googleInfo.getBoolean("isPersonalizedPrice") : null;
|
|
197
215
|
|
|
216
|
+
Map<String, Object> mapPresentedOfferingContext = null;
|
|
217
|
+
if (presentedOfferingContext != null) {
|
|
218
|
+
mapPresentedOfferingContext = presentedOfferingContext.toHashMap();
|
|
219
|
+
}
|
|
220
|
+
|
|
198
221
|
CommonKt.purchaseSubscriptionOption(
|
|
199
222
|
getCurrentActivity(),
|
|
200
223
|
productIdentifer,
|
|
@@ -202,7 +225,7 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
202
225
|
googleUpgradeInfo.getOldProductIdentifier(),
|
|
203
226
|
googleUpgradeInfo.getProrationMode(),
|
|
204
227
|
googleIsPersonalized,
|
|
205
|
-
|
|
228
|
+
mapPresentedOfferingContext,
|
|
206
229
|
getOnResult(promise));
|
|
207
230
|
}
|
|
208
231
|
|
|
@@ -491,6 +514,26 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
491
514
|
};
|
|
492
515
|
}
|
|
493
516
|
|
|
517
|
+
@NotNull
|
|
518
|
+
private OnNullableResult getOnNullableResult(final Promise promise) {
|
|
519
|
+
return new OnNullableResult() {
|
|
520
|
+
@Override
|
|
521
|
+
public void onReceived(@Nullable Map<String, ?> map) {
|
|
522
|
+
if (map != null) {
|
|
523
|
+
promise.resolve(convertMapToWriteableMap(map));
|
|
524
|
+
} else {
|
|
525
|
+
promise.resolve(null);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
@Override
|
|
530
|
+
public void onError(ErrorContainer errorContainer) {
|
|
531
|
+
promise.reject(errorContainer.getCode() + "", errorContainer.getMessage(),
|
|
532
|
+
convertMapToWriteableMap(errorContainer.getInfo()));
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
|
|
494
537
|
private static GoogleUpgradeInfo getUpgradeInfo(ReadableMap upgradeInfo) {
|
|
495
538
|
String googleOldProductId = null;
|
|
496
539
|
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 } 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, PurchasesOffering } from "@revenuecat/purchases-typescript-internal";
|
|
2
|
+
export { PURCHASE_TYPE, BILLING_FEATURE, REFUND_REQUEST_STATUS, LOG_LEVEL, PurchasesConfiguration, CustomerInfoUpdateListener, ShouldPurchasePromoProductListener, MakePurchaseResult, LogHandler, LogInResult, } from "@revenuecat/purchases-typescript-internal";
|
|
3
3
|
export default class Purchases {
|
|
4
4
|
/**
|
|
5
5
|
* Supported SKU types.
|
|
@@ -97,7 +97,7 @@ export default class Purchases {
|
|
|
97
97
|
* Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults suite, otherwise it will use standardUserDefaults.
|
|
98
98
|
* Default is null, which will make the SDK use standardUserDefaults.
|
|
99
99
|
*/
|
|
100
|
-
static configure({ apiKey, appUserID, observerMode, userDefaultsSuiteName, usesStoreKit2IfAvailable, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode }: PurchasesConfiguration): void;
|
|
100
|
+
static configure({ apiKey, appUserID, observerMode, userDefaultsSuiteName, usesStoreKit2IfAvailable, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode, }: PurchasesConfiguration): void;
|
|
101
101
|
/**
|
|
102
102
|
* @deprecated, configure behavior through the RevenueCat dashboard instead.
|
|
103
103
|
* If an user tries to purchase a product that is active on the current app store account,
|
|
@@ -154,6 +154,22 @@ export default class Purchases {
|
|
|
154
154
|
* has not been called yet.
|
|
155
155
|
*/
|
|
156
156
|
static getOfferings(): Promise<PurchasesOfferings>;
|
|
157
|
+
/**
|
|
158
|
+
* Retrieves a current offering for a placement identifier, use this to access offerings defined by targeting
|
|
159
|
+
* placements configured in the RevenueCat dashboard.
|
|
160
|
+
* @param {String} placementIdentifier The placement identifier to fetch a current offeringn for
|
|
161
|
+
* @returns {Promise<PurchasesOffering | null>} Promise of an optional offering. The promise will be rejected if configure
|
|
162
|
+
* has not been called yet.
|
|
163
|
+
*/
|
|
164
|
+
static getCurrentOfferingForPlacement(placementIdentifier: string): Promise<PurchasesOffering | null>;
|
|
165
|
+
/**
|
|
166
|
+
* Syncs subscriber attributes and then fetches the configured offerings for this user. This method is intended to
|
|
167
|
+
* be called when using Targeting Rules with Custom Attributes. Any subscriber attributes should be set before
|
|
168
|
+
* calling this method to ensure the returned offerings are applied with the latest subscriber attributes.
|
|
169
|
+
* @returns {Promise<PurchasesOfferings>} Promise of entitlements structure. The promise will be rejected if configure
|
|
170
|
+
* has not been called yet.
|
|
171
|
+
*/
|
|
172
|
+
static syncAttributesAndOfferingsIfNeeded(): Promise<PurchasesOfferings>;
|
|
157
173
|
/**
|
|
158
174
|
* Fetch the product info
|
|
159
175
|
* @param {String[]} productIdentifiers Array of product identifiers
|
package/dist/purchases.js
CHANGED
|
@@ -84,9 +84,11 @@ var Purchases = /** @class */ (function () {
|
|
|
84
84
|
Purchases.configure = function (_a) {
|
|
85
85
|
var apiKey = _a.apiKey, _b = _a.appUserID, appUserID = _b === void 0 ? null : _b, _c = _a.observerMode, observerMode = _c === void 0 ? false : _c, userDefaultsSuiteName = _a.userDefaultsSuiteName, _d = _a.usesStoreKit2IfAvailable, usesStoreKit2IfAvailable = _d === void 0 ? false : _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;
|
|
86
86
|
if (apiKey === undefined || typeof apiKey !== "string") {
|
|
87
|
-
throw new Error(
|
|
87
|
+
throw new Error('Invalid API key. It must be called with an Object: configure({apiKey: "key"})');
|
|
88
88
|
}
|
|
89
|
-
if (appUserID !== null &&
|
|
89
|
+
if (appUserID !== null &&
|
|
90
|
+
typeof appUserID !== "undefined" &&
|
|
91
|
+
typeof appUserID !== "string") {
|
|
90
92
|
throw new Error("appUserID needs to be a string");
|
|
91
93
|
}
|
|
92
94
|
RNPurchases.setupPurchases(apiKey, appUserID, observerMode, userDefaultsSuiteName, usesStoreKit2IfAvailable, useAmazon, shouldShowInAppMessagesAutomatically, entitlementVerificationMode);
|
|
@@ -191,7 +193,8 @@ var Purchases = /** @class */ (function () {
|
|
|
191
193
|
*/
|
|
192
194
|
Purchases.removeShouldPurchasePromoProductListener = function (listenerToRemove) {
|
|
193
195
|
if (shouldPurchasePromoProductListeners.includes(listenerToRemove)) {
|
|
194
|
-
shouldPurchasePromoProductListeners =
|
|
196
|
+
shouldPurchasePromoProductListeners =
|
|
197
|
+
shouldPurchasePromoProductListeners.filter(function (listener) { return listenerToRemove !== listener; });
|
|
195
198
|
return true;
|
|
196
199
|
}
|
|
197
200
|
return false;
|
|
@@ -213,6 +216,44 @@ var Purchases = /** @class */ (function () {
|
|
|
213
216
|
});
|
|
214
217
|
});
|
|
215
218
|
};
|
|
219
|
+
/**
|
|
220
|
+
* Retrieves a current offering for a placement identifier, use this to access offerings defined by targeting
|
|
221
|
+
* placements configured in the RevenueCat dashboard.
|
|
222
|
+
* @param {String} placementIdentifier The placement identifier to fetch a current offeringn for
|
|
223
|
+
* @returns {Promise<PurchasesOffering | null>} Promise of an optional offering. The promise will be rejected if configure
|
|
224
|
+
* has not been called yet.
|
|
225
|
+
*/
|
|
226
|
+
Purchases.getCurrentOfferingForPlacement = function (placementIdentifier) {
|
|
227
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
228
|
+
return __generator(this, function (_a) {
|
|
229
|
+
switch (_a.label) {
|
|
230
|
+
case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
231
|
+
case 1:
|
|
232
|
+
_a.sent();
|
|
233
|
+
return [2 /*return*/, RNPurchases.getCurrentOfferingForPlacement(placementIdentifier)];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Syncs subscriber attributes and then fetches the configured offerings for this user. This method is intended to
|
|
240
|
+
* be called when using Targeting Rules with Custom Attributes. Any subscriber attributes should be set before
|
|
241
|
+
* calling this method to ensure the returned offerings are applied with the latest subscriber attributes.
|
|
242
|
+
* @returns {Promise<PurchasesOfferings>} Promise of entitlements structure. The promise will be rejected if configure
|
|
243
|
+
* has not been called yet.
|
|
244
|
+
*/
|
|
245
|
+
Purchases.syncAttributesAndOfferingsIfNeeded = function () {
|
|
246
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
247
|
+
return __generator(this, function (_a) {
|
|
248
|
+
switch (_a.label) {
|
|
249
|
+
case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
250
|
+
case 1:
|
|
251
|
+
_a.sent();
|
|
252
|
+
return [2 /*return*/, RNPurchases.syncAttributesAndOfferingsIfNeeded()];
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
};
|
|
216
257
|
/**
|
|
217
258
|
* Fetch the product info
|
|
218
259
|
* @param {String[]} productIdentifiers Array of product identifiers
|
|
@@ -253,7 +294,8 @@ var Purchases = /** @class */ (function () {
|
|
|
253
294
|
case 1:
|
|
254
295
|
_a.sent();
|
|
255
296
|
return [2 /*return*/, RNPurchases.purchaseProduct(productIdentifier, upgradeInfo, type, null, null, null).catch(function (error) {
|
|
256
|
-
error.userCancelled =
|
|
297
|
+
error.userCancelled =
|
|
298
|
+
error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
|
|
257
299
|
throw error;
|
|
258
300
|
})];
|
|
259
301
|
}
|
|
@@ -281,8 +323,11 @@ var Purchases = /** @class */ (function () {
|
|
|
281
323
|
case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
282
324
|
case 1:
|
|
283
325
|
_a.sent();
|
|
284
|
-
return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, googleProductChangeInfo, product.productCategory, null, googleIsPersonalizedPrice == null
|
|
285
|
-
|
|
326
|
+
return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, googleProductChangeInfo, product.productCategory, null, googleIsPersonalizedPrice == null
|
|
327
|
+
? null
|
|
328
|
+
: { isPersonalizedPrice: googleIsPersonalizedPrice }, product.presentedOfferingContext).catch(function (error) {
|
|
329
|
+
error.userCancelled =
|
|
330
|
+
error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
|
|
286
331
|
throw error;
|
|
287
332
|
})];
|
|
288
333
|
}
|
|
@@ -312,8 +357,9 @@ var Purchases = /** @class */ (function () {
|
|
|
312
357
|
if (typeof discount === "undefined" || discount == null) {
|
|
313
358
|
throw new Error("A discount is required");
|
|
314
359
|
}
|
|
315
|
-
return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, null, null, discount.timestamp.toString(), null, product.
|
|
316
|
-
error.userCancelled =
|
|
360
|
+
return [2 /*return*/, RNPurchases.purchaseProduct(product.identifier, null, null, discount.timestamp.toString(), null, product.presentedOfferingContext).catch(function (error) {
|
|
361
|
+
error.userCancelled =
|
|
362
|
+
error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
|
|
317
363
|
throw error;
|
|
318
364
|
})];
|
|
319
365
|
}
|
|
@@ -342,8 +388,11 @@ var Purchases = /** @class */ (function () {
|
|
|
342
388
|
case 0: return [4 /*yield*/, Purchases.throwIfNotConfigured()];
|
|
343
389
|
case 1:
|
|
344
390
|
_a.sent();
|
|
345
|
-
return [2 /*return*/, RNPurchases.purchasePackage(aPackage.identifier, aPackage.
|
|
346
|
-
|
|
391
|
+
return [2 /*return*/, RNPurchases.purchasePackage(aPackage.identifier, aPackage.presentedOfferingContext, googleProductChangeInfo || upgradeInfo, null, googleIsPersonalizedPrice == null
|
|
392
|
+
? null
|
|
393
|
+
: { isPersonalizedPrice: googleIsPersonalizedPrice }).catch(function (error) {
|
|
394
|
+
error.userCancelled =
|
|
395
|
+
error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
|
|
347
396
|
throw error;
|
|
348
397
|
})];
|
|
349
398
|
}
|
|
@@ -374,8 +423,11 @@ var Purchases = /** @class */ (function () {
|
|
|
374
423
|
return [4 /*yield*/, Purchases.throwIfIOSPlatform()];
|
|
375
424
|
case 2:
|
|
376
425
|
_a.sent();
|
|
377
|
-
return [2 /*return*/, RNPurchases.purchaseSubscriptionOption(subscriptionOption.productId, subscriptionOption.id, googleProductChangeInfo, null, googleIsPersonalizedPrice == null
|
|
378
|
-
|
|
426
|
+
return [2 /*return*/, RNPurchases.purchaseSubscriptionOption(subscriptionOption.productId, subscriptionOption.id, googleProductChangeInfo, null, googleIsPersonalizedPrice == null
|
|
427
|
+
? null
|
|
428
|
+
: { isPersonalizedPrice: googleIsPersonalizedPrice }, subscriptionOption.presentedOfferingContext).catch(function (error) {
|
|
429
|
+
error.userCancelled =
|
|
430
|
+
error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
|
|
379
431
|
throw error;
|
|
380
432
|
})];
|
|
381
433
|
}
|
|
@@ -403,7 +455,8 @@ var Purchases = /** @class */ (function () {
|
|
|
403
455
|
throw new Error("A discount is required");
|
|
404
456
|
}
|
|
405
457
|
return [2 /*return*/, RNPurchases.purchasePackage(aPackage.identifier, aPackage.offeringIdentifier, null, discount.timestamp.toString(), null).catch(function (error) {
|
|
406
|
-
error.userCancelled =
|
|
458
|
+
error.userCancelled =
|
|
459
|
+
error.code === purchases_typescript_internal_1.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR;
|
|
407
460
|
throw error;
|
|
408
461
|
})];
|
|
409
462
|
}
|
package/ios/RNPurchases.m
CHANGED
|
@@ -76,6 +76,24 @@ RCT_REMAP_METHOD(getOfferings,
|
|
|
76
76
|
reject:reject]];
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
RCT_REMAP_METHOD(syncAttributesAndOfferingsIfNeeded,
|
|
80
|
+
syncAttributesAndOfferingsIfNeededWithResolve:(RCTPromiseResolveBlock)resolve
|
|
81
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
82
|
+
[RCCommonFunctionality syncAttributesAndOfferingsIfNeededWithCompletionBlock:[self getResponseCompletionBlockWithResolve:resolve
|
|
83
|
+
reject:reject]];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
RCT_EXPORT_METHOD(getCurrentOfferingForPlacement:(NSString *)placementIdentifier
|
|
87
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
88
|
+
reject:(RCTPromiseRejectBlock)reject) {
|
|
89
|
+
|
|
90
|
+
[RCCommonFunctionality getCurrentOfferingForPlacement:placementIdentifier completionBlock:^(NSDictionary *offeringObject, RCErrorContainer *error) {
|
|
91
|
+
resolve(offeringObject);
|
|
92
|
+
}];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//syncAttributesAndOfferingsIfNeeded
|
|
96
|
+
|
|
79
97
|
RCT_EXPORT_METHOD(getProductInfo:(NSArray *)products
|
|
80
98
|
type:(NSString *)type
|
|
81
99
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
@@ -92,6 +110,7 @@ RCT_REMAP_METHOD(purchaseProduct,
|
|
|
92
110
|
signedDiscountTimestamp:(NSString *)signedDiscountTimestamp
|
|
93
111
|
googleInfo:(NSDictionary *)googleInfo
|
|
94
112
|
presentedOfferingIdentifier:(NSString *)presentedOfferingIdentifier
|
|
113
|
+
presentedOfferingContext:(NSDictionary *)presentedOfferingDictionary
|
|
95
114
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
96
115
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
97
116
|
[RCCommonFunctionality purchaseProduct:productIdentifier
|
|
@@ -102,14 +121,14 @@ RCT_REMAP_METHOD(purchaseProduct,
|
|
|
102
121
|
|
|
103
122
|
RCT_REMAP_METHOD(purchasePackage,
|
|
104
123
|
purchasePackage:(NSString *)packageIdentifier
|
|
105
|
-
|
|
124
|
+
presentedOfferingContext:(NSDictionary *)presentedOfferingContext
|
|
106
125
|
upgradeInfo:(NSDictionary *)upgradeInfo
|
|
107
126
|
signedDiscountTimestamp:(NSString *)signedDiscountTimestamp
|
|
108
127
|
googleInfo:(NSDictionary *)googleInfo
|
|
109
128
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
110
129
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
111
130
|
[RCCommonFunctionality purchasePackage:packageIdentifier
|
|
112
|
-
|
|
131
|
+
presentedOfferingContext:presentedOfferingContext
|
|
113
132
|
signedDiscountTimestamp:signedDiscountTimestamp
|
|
114
133
|
completionBlock:[self getResponseCompletionBlockWithResolve:resolve reject:reject]];
|
|
115
134
|
}
|
|
@@ -472,7 +491,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
|
|
|
472
491
|
}
|
|
473
492
|
|
|
474
493
|
- (NSString *)platformFlavorVersion {
|
|
475
|
-
return @"7.
|
|
494
|
+
return @"7.24.0";
|
|
476
495
|
}
|
|
477
496
|
|
|
478
497
|
@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": "7.
|
|
4
|
+
"version": "7.24.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",
|
|
@@ -66,24 +67,24 @@
|
|
|
66
67
|
"react-native": ">= 0.58.2"
|
|
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": "10.2.0"
|
|
103
104
|
}
|
|
104
105
|
}
|