react-native-purchases 4.6.1 → 5.0.0-beta.1
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 +10 -18
- package/RNPurchases.podspec +2 -2
- package/android/build.gradle +2 -2
- package/android/build.gradle.bck +126 -0
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java +18 -42
- package/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java.bck +374 -0
- package/dist/{purchaserInfo.d.ts → customerInfo.d.ts} +4 -5
- package/dist/{purchaserInfo.js → customerInfo.js} +0 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/offerings.d.ts +11 -43
- package/dist/offerings.js +4 -0
- package/dist/purchases.d.ts +52 -114
- package/dist/purchases.js +52 -160
- package/ios/RNPurchases.h +2 -2
- package/ios/RNPurchases.m +39 -72
- package/ios/RNPurchases.m.bck +342 -0
- package/package.json +4 -6
- package/scripts/{build.js → build.js.bck} +0 -0
- package/scripts/setupJest.js +5 -9
- package/scripts/download-purchases-common.sh +0 -39
- package/scripts/download-purchases-framework.sh +0 -39
package/dist/purchases.d.ts
CHANGED
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import { PURCHASES_ERROR_CODE, UninitializedPurchasesError } from "./errors";
|
|
2
|
-
import {
|
|
3
|
-
import { PRORATION_MODE, PACKAGE_TYPE, INTRO_ELIGIBILITY_STATUS, PurchasesOfferings,
|
|
2
|
+
import { CustomerInfo } from "./customerInfo";
|
|
3
|
+
import { PRORATION_MODE, PACKAGE_TYPE, INTRO_ELIGIBILITY_STATUS, PurchasesOfferings, PurchasesStoreProduct, UpgradeInfo, PurchasesPromotionalOffer, PurchasesPackage, IntroEligibility, PurchasesStoreProductDiscount } from "./offerings";
|
|
4
4
|
/**
|
|
5
|
-
* Listener used on updated
|
|
6
|
-
* @callback
|
|
7
|
-
* @param {Object}
|
|
5
|
+
* Listener used on updated customer info
|
|
6
|
+
* @callback CustomerInfoUpdateListener
|
|
7
|
+
* @param {Object} customerInfo Object containing info for the customer
|
|
8
8
|
*/
|
|
9
|
-
export declare type
|
|
9
|
+
export declare type CustomerInfoUpdateListener = (customerInfo: CustomerInfo) => void;
|
|
10
10
|
export declare type ShouldPurchasePromoProductListener = (deferredPurchase: () => Promise<MakePurchaseResult>) => void;
|
|
11
11
|
export declare type MakePurchaseResult = {
|
|
12
12
|
productIdentifier: string;
|
|
13
|
-
|
|
13
|
+
customerInfo: CustomerInfo;
|
|
14
14
|
};
|
|
15
|
-
export declare enum ATTRIBUTION_NETWORK {
|
|
16
|
-
APPLE_SEARCH_ADS = 0,
|
|
17
|
-
ADJUST = 1,
|
|
18
|
-
APPSFLYER = 2,
|
|
19
|
-
BRANCH = 3,
|
|
20
|
-
TENJIN = 4,
|
|
21
|
-
FACEBOOK = 5
|
|
22
|
-
}
|
|
23
15
|
export declare enum PURCHASE_TYPE {
|
|
24
16
|
/**
|
|
25
17
|
* A type of SKU for in-app products.
|
|
@@ -62,29 +54,15 @@ export declare enum BILLING_FEATURE {
|
|
|
62
54
|
*/
|
|
63
55
|
export interface LogInResult {
|
|
64
56
|
/**
|
|
65
|
-
* The
|
|
57
|
+
* The Customer Info for the user.
|
|
66
58
|
*/
|
|
67
|
-
readonly
|
|
59
|
+
readonly customerInfo: CustomerInfo;
|
|
68
60
|
/**
|
|
69
61
|
* True if the call resulted in a new user getting created in the RevenueCat backend.
|
|
70
62
|
*/
|
|
71
63
|
readonly created: boolean;
|
|
72
64
|
}
|
|
73
65
|
export default class Purchases {
|
|
74
|
-
/**
|
|
75
|
-
* Enum for attribution networks
|
|
76
|
-
* @readonly
|
|
77
|
-
* @enum {number}
|
|
78
|
-
*/
|
|
79
|
-
static ATTRIBUTION_NETWORK: typeof ATTRIBUTION_NETWORK;
|
|
80
|
-
/**
|
|
81
|
-
* @deprecated use ATTRIBUTION_NETWORK instead
|
|
82
|
-
*
|
|
83
|
-
* Enum for attribution networks
|
|
84
|
-
* @readonly
|
|
85
|
-
* @enum {number}
|
|
86
|
-
*/
|
|
87
|
-
static ATTRIBUTION_NETWORKS: typeof ATTRIBUTION_NETWORK;
|
|
88
66
|
/**
|
|
89
67
|
* Supported SKU types.
|
|
90
68
|
* @readonly
|
|
@@ -128,12 +106,13 @@ export default class Purchases {
|
|
|
128
106
|
* Sets up Purchases with your API key and an app user id.
|
|
129
107
|
* @param {String} apiKey RevenueCat API Key. Needs to be a String
|
|
130
108
|
* @param {String?} appUserID An optional unique id for identifying the user. Needs to be a string.
|
|
131
|
-
* @param {boolean
|
|
109
|
+
* @param {boolean} [observerMode=false] An optional boolean. Set this to TRUE if you have your own IAP implementation and want to use only RevenueCat's backend. Default is FALSE.
|
|
110
|
+
* @param {boolean} [usesStoreKit2IfAvailable=false] An optional boolean. iOS-only. Set this to TRUE to enable StoreKit2 on compatible devices.
|
|
132
111
|
* @param {String?} userDefaultsSuiteName An optional string. iOS-only, will be ignored for Android.
|
|
133
112
|
* Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults suite, otherwise it will use standardUserDefaults.
|
|
134
113
|
* Default is null, which will make the SDK use standardUserDefaults.
|
|
135
114
|
*/
|
|
136
|
-
static
|
|
115
|
+
static configure(apiKey: string, appUserID?: string | null, observerMode?: boolean, userDefaultsSuiteName?: string, usesStoreKit2IfAvailable?: boolean): void;
|
|
137
116
|
/**
|
|
138
117
|
* @deprecated, configure behavior through the RevenueCat dashboard instead.
|
|
139
118
|
* If an user tries to purchase a product that is active on the current app store account,
|
|
@@ -157,16 +136,16 @@ export default class Purchases {
|
|
|
157
136
|
*/
|
|
158
137
|
static setSimulatesAskToBuyInSandbox(simulatesAskToBuyInSandbox: boolean): Promise<void>;
|
|
159
138
|
/**
|
|
160
|
-
* Sets a function to be called on updated
|
|
161
|
-
* @param {
|
|
139
|
+
* Sets a function to be called on updated customer info
|
|
140
|
+
* @param {CustomerInfoUpdateListener} customerInfoUpdateListener CustomerInfo update listener
|
|
162
141
|
*/
|
|
163
|
-
static
|
|
142
|
+
static addCustomerInfoUpdateListener(customerInfoUpdateListener: CustomerInfoUpdateListener): void;
|
|
164
143
|
/**
|
|
165
|
-
* Removes a given
|
|
166
|
-
* @param {
|
|
144
|
+
* Removes a given CustomerInfoUpdateListener
|
|
145
|
+
* @param {CustomerInfoUpdateListener} listenerToRemove CustomerInfoUpdateListener reference of the listener to remove
|
|
167
146
|
* @returns {boolean} True if listener was removed, false otherwise
|
|
168
147
|
*/
|
|
169
|
-
static
|
|
148
|
+
static removeCustomerInfoUpdateListener(listenerToRemove: CustomerInfoUpdateListener): boolean;
|
|
170
149
|
/**
|
|
171
150
|
* Sets a function to be called on purchases initiated on the Apple App Store. This is only used in iOS.
|
|
172
151
|
* @param {ShouldPurchasePromoProductListener} shouldPurchasePromoProductListener Called when a user initiates a
|
|
@@ -184,18 +163,6 @@ export default class Purchases {
|
|
|
184
163
|
* @returns {boolean} True if listener was removed, false otherwise
|
|
185
164
|
*/
|
|
186
165
|
static removeShouldPurchasePromoProductListener(listenerToRemove: ShouldPurchasePromoProductListener): boolean;
|
|
187
|
-
/**
|
|
188
|
-
* @deprecated, use set<NetworkId> methods instead.
|
|
189
|
-
*
|
|
190
|
-
* Add a dict of attribution information
|
|
191
|
-
* @param {Dict} data Attribution data from AppsFlyer, Adjust, or Branch
|
|
192
|
-
* @param {ATTRIBUTION_NETWORKS} network Which network, see Purchases.ATTRIBUTION_NETWORKS
|
|
193
|
-
* @param {String?} networkUserId An optional unique id for identifying the user. Needs to be a string.
|
|
194
|
-
* @returns {Promise<void>} The promise will be rejected if setup has not been called yet.
|
|
195
|
-
*/
|
|
196
|
-
static addAttributionData(data: {
|
|
197
|
-
[key: string]: any;
|
|
198
|
-
}, network: ATTRIBUTION_NETWORK, networkUserId?: string): Promise<void>;
|
|
199
166
|
/**
|
|
200
167
|
* Gets the map of entitlements -> offerings -> products
|
|
201
168
|
* @returns {Promise<PurchasesOfferings>} Promise of entitlements structure. The promise will be rejected if setup
|
|
@@ -206,12 +173,12 @@ export default class Purchases {
|
|
|
206
173
|
* Fetch the product info
|
|
207
174
|
* @param {String[]} productIdentifiers Array of product identifiers
|
|
208
175
|
* @param {String} type Optional type of products to fetch, can be inapp or subs. Subs by default
|
|
209
|
-
* @returns {Promise<
|
|
176
|
+
* @returns {Promise<PurchasesStoreProduct[]>} A promise containing an array of products. The promise will be rejected
|
|
210
177
|
* if the products are not properly configured in RevenueCat or if there is another error retrieving them.
|
|
211
178
|
* Rejections return an error code, and a userInfo object with more information. The promise will also be rejected
|
|
212
179
|
* if setup has not been called yet.
|
|
213
180
|
*/
|
|
214
|
-
static getProducts(productIdentifiers: string[], type?: PURCHASE_TYPE): Promise<
|
|
181
|
+
static getProducts(productIdentifiers: string[], type?: PURCHASE_TYPE): Promise<PurchasesStoreProduct[]>;
|
|
215
182
|
/**
|
|
216
183
|
* Make a purchase
|
|
217
184
|
*
|
|
@@ -219,8 +186,8 @@ export default class Purchases {
|
|
|
219
186
|
* @param {UpgradeInfo} upgradeInfo Android only. Optional UpgradeInfo you wish to upgrade from containing the oldSKU
|
|
220
187
|
* and the optional prorationMode.
|
|
221
188
|
* @param {String} type Optional type of product, can be inapp or subs. Subs by default
|
|
222
|
-
* @returns {Promise<{ productIdentifier: string,
|
|
223
|
-
* a
|
|
189
|
+
* @returns {Promise<{ productIdentifier: string, customerInfo:CustomerInfo }>} A promise of an object containing
|
|
190
|
+
* a customer info object and a product identifier. Rejections return an error code,
|
|
224
191
|
* a boolean indicating if the user cancelled the purchase, and an object with more information. The promise will
|
|
225
192
|
* also be rejected if setup has not been called yet.
|
|
226
193
|
*/
|
|
@@ -228,22 +195,22 @@ export default class Purchases {
|
|
|
228
195
|
/**
|
|
229
196
|
* iOS only. Purchase a product applying a given discount.
|
|
230
197
|
*
|
|
231
|
-
* @param {
|
|
232
|
-
* @param {
|
|
233
|
-
* @returns {Promise<{ productIdentifier: string,
|
|
234
|
-
* a
|
|
198
|
+
* @param {PurchasesStoreProduct} product The product you want to purchase
|
|
199
|
+
* @param {PurchasesPromotionalOffer} discount Discount to apply to this package. Retrieve this discount using getPromotionalOffer.
|
|
200
|
+
* @returns {Promise<{ productIdentifier: string, customerInfo:CustomerInfo }>} A promise of an object containing
|
|
201
|
+
* a customer info object and a product identifier. Rejections return an error code,
|
|
235
202
|
* a boolean indicating if the user cancelled the purchase, and an object with more information. The promise will be
|
|
236
203
|
* rejected if setup has not been called yet.
|
|
237
204
|
*/
|
|
238
|
-
static purchaseDiscountedProduct(product:
|
|
205
|
+
static purchaseDiscountedProduct(product: PurchasesStoreProduct, discount: PurchasesPromotionalOffer): Promise<MakePurchaseResult>;
|
|
239
206
|
/**
|
|
240
207
|
* Make a purchase
|
|
241
208
|
*
|
|
242
209
|
* @param {PurchasesPackage} aPackage The Package you wish to purchase. You can get the Packages by calling getOfferings
|
|
243
210
|
* @param {UpgradeInfo} upgradeInfo Android only. Optional UpgradeInfo you wish to upgrade from containing the oldSKU
|
|
244
211
|
* and the optional prorationMode.
|
|
245
|
-
* @returns {Promise<{ productIdentifier: string,
|
|
246
|
-
* a
|
|
212
|
+
* @returns {Promise<{ productIdentifier: string, customerInfo: CustomerInfo }>} A promise of an object containing
|
|
213
|
+
* a customer info object and a product identifier. Rejections return an error code, a boolean indicating if the
|
|
247
214
|
* user cancelled the purchase, and an object with more information. The promise will be also be rejected if setup
|
|
248
215
|
* has not been called yet.
|
|
249
216
|
*/
|
|
@@ -252,19 +219,19 @@ export default class Purchases {
|
|
|
252
219
|
* iOS only. Purchase a package applying a given discount.
|
|
253
220
|
*
|
|
254
221
|
* @param {PurchasesPackage} aPackage The Package you wish to purchase. You can get the Packages by calling getOfferings
|
|
255
|
-
* @param {
|
|
256
|
-
* @returns {Promise<{ productIdentifier: string,
|
|
257
|
-
* a
|
|
222
|
+
* @param {PurchasesPromotionalOffer} discount Discount to apply to this package. Retrieve this discount using getPromotionalOffer.
|
|
223
|
+
* @returns {Promise<{ productIdentifier: string, customerInfo: CustomerInfo }>} A promise of an object containing
|
|
224
|
+
* a customer info object and a product identifier. Rejections return an error code, a boolean indicating if the
|
|
258
225
|
* user cancelled the purchase, and an object with more information. The promise will be also be rejected if setup
|
|
259
226
|
* has not been called yet.
|
|
260
227
|
*/
|
|
261
|
-
static purchaseDiscountedPackage(aPackage: PurchasesPackage, discount:
|
|
228
|
+
static purchaseDiscountedPackage(aPackage: PurchasesPackage, discount: PurchasesPromotionalOffer): Promise<MakePurchaseResult>;
|
|
262
229
|
/**
|
|
263
230
|
* Restores a user's previous purchases and links their appUserIDs to any user's also using those purchases.
|
|
264
|
-
* @returns {Promise<
|
|
231
|
+
* @returns {Promise<CustomerInfo>} A promise of a customer info object. Rejections return an error code, and an
|
|
265
232
|
* userInfo object with more information. The promise will be also be rejected if setup has not been called yet.
|
|
266
233
|
*/
|
|
267
|
-
static restoreTransactions(): Promise<
|
|
234
|
+
static restoreTransactions(): Promise<CustomerInfo>;
|
|
268
235
|
/**
|
|
269
236
|
* Get the appUserID
|
|
270
237
|
* @returns {Promise<string>} The app user id in a promise
|
|
@@ -274,59 +241,30 @@ export default class Purchases {
|
|
|
274
241
|
* This function will logIn the current user with an appUserID. Typically this would be used after a log in
|
|
275
242
|
* to identify a user without calling configure.
|
|
276
243
|
* @param {String} appUserID The appUserID that should be linked to the currently user
|
|
277
|
-
* @returns {Promise<LogInResult>} A promise of an object that contains the
|
|
244
|
+
* @returns {Promise<LogInResult>} A promise of an object that contains the customerInfo after logging in, as well
|
|
278
245
|
* as a boolean indicating whether the user has just been created for the first time in the RevenueCat backend. The
|
|
279
246
|
* promise will be rejected if setup has not been called yet or if there's an issue logging in.
|
|
280
247
|
*/
|
|
281
248
|
static logIn(appUserID: string): Promise<LogInResult>;
|
|
282
249
|
/**
|
|
283
250
|
* Logs out the Purchases client clearing the saved appUserID. This will generate a random user id and save it in the cache.
|
|
284
|
-
* @returns {Promise<
|
|
251
|
+
* @returns {Promise<CustomerInfo>} A promise of a customer info object. Rejections return an error code,
|
|
285
252
|
* and a userInfo object with more information. The promise will be rejected if setup has not been called yet or if
|
|
286
253
|
* there's an issue logging out.
|
|
287
254
|
*/
|
|
288
|
-
static logOut(): Promise<
|
|
289
|
-
/**
|
|
290
|
-
* @deprecated, use logIn instead.
|
|
291
|
-
* This function will alias two appUserIDs together.
|
|
292
|
-
* @param {String} newAppUserID The new appUserID that should be linked to the currently identified appUserID.
|
|
293
|
-
* Needs to be a string.
|
|
294
|
-
* @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a
|
|
295
|
-
* userInfo object with more information. The promise will be rejected if setup has not been called yet or if
|
|
296
|
-
* there's an issue creating the alias.
|
|
297
|
-
*/
|
|
298
|
-
static createAlias(newAppUserID: string): Promise<PurchaserInfo>;
|
|
299
|
-
/**
|
|
300
|
-
* @deprecated, use logIn instead.
|
|
301
|
-
* This function will identify the current user with an appUserID. Typically this would be used after a logout to
|
|
302
|
-
* identify a new user without calling configure
|
|
303
|
-
* @param {String} newAppUserID The appUserID that should be linked to the currently user
|
|
304
|
-
* @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and an
|
|
305
|
-
* userInfo object with more information. The promise will be rejected if setup has not been called yet or if
|
|
306
|
-
* there's an issue identifying the user.
|
|
307
|
-
*/
|
|
308
|
-
static identify(newAppUserID: string): Promise<PurchaserInfo>;
|
|
309
|
-
/**
|
|
310
|
-
* @deprecated, use logOut instead.
|
|
311
|
-
* Resets the Purchases client clearing the saved appUserID. This will generate a random user id and save it in the
|
|
312
|
-
* cache.
|
|
313
|
-
* @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and an
|
|
314
|
-
* userInfo object with more information. The promise will be rejected if setup has not been called yet or if
|
|
315
|
-
* there's an issue resetting the user.
|
|
316
|
-
*/
|
|
317
|
-
static reset(): Promise<PurchaserInfo>;
|
|
255
|
+
static logOut(): Promise<CustomerInfo>;
|
|
318
256
|
/**
|
|
319
257
|
* Enables/Disables debugs logs
|
|
320
258
|
* @param {boolean} enabled Enable or not debug logs
|
|
321
259
|
*/
|
|
322
260
|
static setDebugLogsEnabled(enabled: boolean): Promise<void>;
|
|
323
261
|
/**
|
|
324
|
-
* Gets current
|
|
325
|
-
* @returns {Promise<
|
|
262
|
+
* Gets current customer info
|
|
263
|
+
* @returns {Promise<CustomerInfo>} A promise of a customer info object. Rejections return an error code, and an
|
|
326
264
|
* userInfo object with more information. The promise will be rejected if setup has not been called yet or if
|
|
327
|
-
* there's an issue getting the
|
|
265
|
+
* there's an issue getting the customer information.
|
|
328
266
|
*/
|
|
329
|
-
static
|
|
267
|
+
static getCustomerInfo(): Promise<CustomerInfo>;
|
|
330
268
|
/**
|
|
331
269
|
* This method will send all the purchases to the RevenueCat backend. Call this when using your own implementation
|
|
332
270
|
* for subscriptions anytime a sync is needed, like after a successful purchase.
|
|
@@ -366,28 +304,28 @@ export default class Purchases {
|
|
|
366
304
|
[productId: string]: IntroEligibility;
|
|
367
305
|
}>;
|
|
368
306
|
/**
|
|
369
|
-
* iOS only. Use this function to retrieve the `
|
|
307
|
+
* iOS only. Use this function to retrieve the `PurchasesPromotionalOffer` for a given `PurchasesPackage`.
|
|
370
308
|
*
|
|
371
309
|
* @param product The `PurchasesProduct` the user intends to purchase.
|
|
372
310
|
* @param discount The `PurchasesDiscount` to apply to the product.
|
|
373
|
-
* @returns { Promise<
|
|
311
|
+
* @returns { Promise<PurchasesPromotionalOffer> } Returns when the `PurchasesPaymentDiscount` is returned.
|
|
374
312
|
* Null is returned for Android and incompatible iOS versions. The promise will be rejected if setup has not been
|
|
375
313
|
* called yet or if there's an error getting the payment discount.
|
|
376
314
|
*/
|
|
377
|
-
static
|
|
315
|
+
static getPromotionalOffer(product: PurchasesStoreProduct, discount: PurchasesStoreProductDiscount): Promise<PurchasesPromotionalOffer | undefined>;
|
|
378
316
|
/**
|
|
379
|
-
* Invalidates the cache for
|
|
317
|
+
* Invalidates the cache for customer information.
|
|
380
318
|
*
|
|
381
319
|
* Most apps will not need to use this method; invalidating the cache can leave your app in an invalid state.
|
|
382
|
-
* Refer to https://docs.revenuecat.com/docs/
|
|
320
|
+
* Refer to https://docs.revenuecat.com/docs/customer-info#section-get-user-information for more information on
|
|
383
321
|
* using the cache properly.
|
|
384
322
|
*
|
|
385
|
-
* This is useful for cases where
|
|
323
|
+
* This is useful for cases where customer information might have been updated outside of the app, like if a
|
|
386
324
|
* promotional subscription is granted through the RevenueCat dashboard.
|
|
387
325
|
* @returns {Promise<void>} The promise will be rejected if setup has not been called yet or there's an error
|
|
388
|
-
* invalidating the
|
|
326
|
+
* invalidating the customer info cache.
|
|
389
327
|
*/
|
|
390
|
-
static
|
|
328
|
+
static invalidateCustomerInfoCache(): Promise<void>;
|
|
391
329
|
/** iOS only. Presents a code redemption sheet, useful for redeeming offer codes
|
|
392
330
|
* Refer to https://docs.revenuecat.com/docs/ios-subscription-offers#offer-codes for more information on how
|
|
393
331
|
* to configure and use offer codes
|
|
@@ -565,9 +503,9 @@ export default class Purchases {
|
|
|
565
503
|
* Note: Billing features are only relevant to Google Play Android users.
|
|
566
504
|
* For other stores and platforms, billing features won't be checked.
|
|
567
505
|
*
|
|
568
|
-
* @param
|
|
506
|
+
* @param features An array of feature types to check for support. Feature types must be one of
|
|
569
507
|
* [BILLING_FEATURE]. By default, is an empty list and no specific feature support will be checked.
|
|
570
|
-
* @returns {Promise<
|
|
508
|
+
* @returns {Promise<boolean>} promise with boolean response. True if billing is supported, false otherwise.
|
|
571
509
|
*/
|
|
572
510
|
static canMakePayments(features?: BILLING_FEATURE[]): Promise<boolean>;
|
|
573
511
|
/**
|