forked from RevenueCat/react-native-purchases
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
636 lines (636 loc) · 29.8 KB
/
index.js
File metadata and controls
636 lines (636 loc) · 29.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isUTCDateStringFuture = exports.INTRO_ELIGIBILITY_STATUS = exports.PACKAGE_TYPE = exports.PRORATION_MODE = exports.PURCHASE_TYPE = exports.ATTRIBUTION_NETWORK = void 0;
// @ts-ignore
var react_native_1 = require("react-native");
var RNPurchases = react_native_1.NativeModules.RNPurchases;
var eventEmitter = new react_native_1.NativeEventEmitter(RNPurchases);
var ATTRIBUTION_NETWORK;
(function (ATTRIBUTION_NETWORK) {
ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK["APPLE_SEARCH_ADS"] = 0] = "APPLE_SEARCH_ADS";
ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK["ADJUST"] = 1] = "ADJUST";
ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK["APPSFLYER"] = 2] = "APPSFLYER";
ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK["BRANCH"] = 3] = "BRANCH";
ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK["TENJIN"] = 4] = "TENJIN";
ATTRIBUTION_NETWORK[ATTRIBUTION_NETWORK["FACEBOOK"] = 5] = "FACEBOOK";
})(ATTRIBUTION_NETWORK = exports.ATTRIBUTION_NETWORK || (exports.ATTRIBUTION_NETWORK = {}));
var PURCHASE_TYPE;
(function (PURCHASE_TYPE) {
/**
* A type of SKU for in-app products.
*/
PURCHASE_TYPE["INAPP"] = "inapp";
/**
* A type of SKU for subscriptions.
*/
PURCHASE_TYPE["SUBS"] = "subs";
})(PURCHASE_TYPE = exports.PURCHASE_TYPE || (exports.PURCHASE_TYPE = {}));
var PRORATION_MODE;
(function (PRORATION_MODE) {
PRORATION_MODE[PRORATION_MODE["UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY"] = 0] = "UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY";
/**
* Replacement takes effect immediately, and the remaining time will be
* prorated and credited to the user. This is the current default behavior.
*/
PRORATION_MODE[PRORATION_MODE["IMMEDIATE_WITH_TIME_PRORATION"] = 1] = "IMMEDIATE_WITH_TIME_PRORATION";
/**
* Replacement takes effect immediately, and the billing cycle remains the
* same. The price for the remaining period will be charged. This option is
* only available for subscription upgrade.
*/
PRORATION_MODE[PRORATION_MODE["IMMEDIATE_AND_CHARGE_PRORATED_PRICE"] = 2] = "IMMEDIATE_AND_CHARGE_PRORATED_PRICE";
/**
* Replacement takes effect immediately, and the new price will be charged on
* next recurrence time. The billing cycle stays the same.
*/
PRORATION_MODE[PRORATION_MODE["IMMEDIATE_WITHOUT_PRORATION"] = 3] = "IMMEDIATE_WITHOUT_PRORATION";
/**
* Replacement takes effect when the old plan expires, and the new price will
* be charged at the same time.
*/
PRORATION_MODE[PRORATION_MODE["DEFERRED"] = 4] = "DEFERRED";
})(PRORATION_MODE = exports.PRORATION_MODE || (exports.PRORATION_MODE = {}));
var PACKAGE_TYPE;
(function (PACKAGE_TYPE) {
/**
* A package that was defined with a custom identifier.
*/
PACKAGE_TYPE["UNKNOWN"] = "UNKNOWN";
/**
* A package that was defined with a custom identifier.
*/
PACKAGE_TYPE["CUSTOM"] = "CUSTOM";
/**
* A package configured with the predefined lifetime identifier.
*/
PACKAGE_TYPE["LIFETIME"] = "LIFETIME";
/**
* A package configured with the predefined annual identifier.
*/
PACKAGE_TYPE["ANNUAL"] = "ANNUAL";
/**
* A package configured with the predefined six month identifier.
*/
PACKAGE_TYPE["SIX_MONTH"] = "SIX_MONTH";
/**
* A package configured with the predefined three month identifier.
*/
PACKAGE_TYPE["THREE_MONTH"] = "THREE_MONTH";
/**
* A package configured with the predefined two month identifier.
*/
PACKAGE_TYPE["TWO_MONTH"] = "TWO_MONTH";
/**
* A package configured with the predefined monthly identifier.
*/
PACKAGE_TYPE["MONTHLY"] = "MONTHLY";
/**
* A package configured with the predefined weekly identifier.
*/
PACKAGE_TYPE["WEEKLY"] = "WEEKLY";
})(PACKAGE_TYPE = exports.PACKAGE_TYPE || (exports.PACKAGE_TYPE = {}));
var INTRO_ELIGIBILITY_STATUS;
(function (INTRO_ELIGIBILITY_STATUS) {
/**
* RevenueCat doesn't have enough information to determine eligibility.
*/
INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS["INTRO_ELIGIBILITY_STATUS_UNKNOWN"] = 0] = "INTRO_ELIGIBILITY_STATUS_UNKNOWN";
/**
* The user is not eligible for a free trial or intro pricing for this product.
*/
INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS["INTRO_ELIGIBILITY_STATUS_INELIGIBLE"] = 1] = "INTRO_ELIGIBILITY_STATUS_INELIGIBLE";
/**
* The user is eligible for a free trial or intro pricing for this product.
*/
INTRO_ELIGIBILITY_STATUS[INTRO_ELIGIBILITY_STATUS["INTRO_ELIGIBILITY_STATUS_ELIGIBLE"] = 2] = "INTRO_ELIGIBILITY_STATUS_ELIGIBLE";
})(INTRO_ELIGIBILITY_STATUS = exports.INTRO_ELIGIBILITY_STATUS || (exports.INTRO_ELIGIBILITY_STATUS = {}));
var purchaserInfoUpdateListeners = [];
var shouldPurchasePromoProductListeners = [];
exports.isUTCDateStringFuture = function (dateString) {
var date = new Date(dateString);
var dateUtcMillis = date.valueOf();
var now = new Date();
var nowUtcMillis = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds());
return nowUtcMillis < dateUtcMillis;
};
eventEmitter.addListener("Purchases-PurchaserInfoUpdated", function (purchaserInfo) {
purchaserInfoUpdateListeners.forEach(function (listener) { return listener(purchaserInfo); });
});
eventEmitter.addListener("Purchases-ShouldPurchasePromoProduct", function (_a) {
var callbackID = _a.callbackID;
shouldPurchasePromoProductListeners.forEach(function (listener) {
return listener(function () { return RNPurchases.makeDeferredPurchase(callbackID); });
});
});
var Purchases = /** @class */ (function () {
function Purchases() {
}
/**
* Sets up Purchases with your API key and an app user id.
* @param {String} apiKey RevenueCat API Key. Needs to be a String
* @param {String?} appUserID An optional unique id for identifying the user. Needs to be a string.
* @param {Boolean?} observerMode 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.
* @param {String?} userDefaultsSuiteName An optional string. iOS-only, will be ignored for Android.
* Set this if you would like the RevenueCat SDK to store its preferences in a different NSUserDefaults suite, otherwise it will use standardUserDefaults.
* Default is null, which will make the SDK use standardUserDefaults.
* @returns {Promise<void>} Returns when setup completes
*/
Purchases.setup = function (apiKey, appUserID, observerMode, userDefaultsSuiteName) {
if (observerMode === void 0) { observerMode = false; }
if (appUserID !== null && typeof appUserID !== "undefined" && typeof appUserID !== "string") {
throw new Error("appUserID needs to be a string");
}
return RNPurchases.setupPurchases(apiKey, appUserID, observerMode, userDefaultsSuiteName);
};
/**
* @param {Boolean} allowSharing Set this to true if you are passing in an appUserID but it is anonymous, this is true by default if you didn't pass an appUserID
* If an user tries to purchase a product that is active on the current app store account, we will treat it as a restore and alias
* the new ID with the previous id.
*/
Purchases.setAllowSharingStoreAccount = function (allowSharing) {
RNPurchases.setAllowSharingStoreAccount(allowSharing);
};
/**
* @param {Boolean} finishTransactions Set finishTransactions to false if you aren't using Purchases SDK to make the purchase
*/
Purchases.setFinishTransactions = function (finishTransactions) {
RNPurchases.setFinishTransactions(finishTransactions);
};
/**
* Sets a function to be called on updated purchaser info
* @param {PurchaserInfoUpdateListener} purchaserInfoUpdateListener PurchaserInfo update listener
*/
Purchases.addPurchaserInfoUpdateListener = function (purchaserInfoUpdateListener) {
if (typeof purchaserInfoUpdateListener !== "function") {
throw new Error("addPurchaserInfoUpdateListener needs a function");
}
purchaserInfoUpdateListeners.push(purchaserInfoUpdateListener);
};
/**
* Removes a given PurchaserInfoUpdateListener
* @param {PurchaserInfoUpdateListener} listenerToRemove PurchaserInfoUpdateListener reference of the listener to remove
* @returns {boolean} True if listener was removed, false otherwise
*/
Purchases.removePurchaserInfoUpdateListener = function (listenerToRemove) {
if (purchaserInfoUpdateListeners.includes(listenerToRemove)) {
purchaserInfoUpdateListeners = purchaserInfoUpdateListeners.filter(function (listener) { return listenerToRemove !== listener; });
return true;
}
return false;
};
/**
* Sets a function to be called on purchases initiated on the Apple App Store. This is only used in iOS.
* @param {ShouldPurchasePromoProductListener} shouldPurchasePromoProductListener Called when a user initiates a
* promotional in-app purchase from the App Store. If your app is able to handle a purchase at the current time, run
* the deferredPurchase function. If the app is not in a state to make a purchase: cache the deferredPurchase, then
* call the deferredPurchase when the app is ready to make the promotional purchase.
* If the purchase should never be made, you don't need to ever call the deferredPurchase and the app will not
* proceed with promotional purchases.
*/
Purchases.addShouldPurchasePromoProductListener = function (shouldPurchasePromoProductListener) {
if (typeof shouldPurchasePromoProductListener !== "function") {
throw new Error("addShouldPurchasePromoProductListener needs a function");
}
shouldPurchasePromoProductListeners.push(shouldPurchasePromoProductListener);
};
/**
* Removes a given ShouldPurchasePromoProductListener
* @param {ShouldPurchasePromoProductListener} listenerToRemove ShouldPurchasePromoProductListener reference of the listener to remove
* @returns {boolean} True if listener was removed, false otherwise
*/
Purchases.removeShouldPurchasePromoProductListener = function (listenerToRemove) {
if (shouldPurchasePromoProductListeners.includes(listenerToRemove)) {
shouldPurchasePromoProductListeners = shouldPurchasePromoProductListeners.filter(function (listener) { return listenerToRemove !== listener; });
return true;
}
return false;
};
/**
* @deprecated, use set<NetworkId> methods instead.
*
* Add a dict of attribution information
* @param {Dict} data Attribution data from AppsFlyer, Adjust, or Branch
* @param {ATTRIBUTION_NETWORKS} network Which network, see Purchases.ATTRIBUTION_NETWORKS
* @param {String?} networkUserId An optional unique id for identifying the user. Needs to be a string.
*/
Purchases.addAttributionData = function (data, network, networkUserId) {
RNPurchases.addAttributionData(data, network, networkUserId);
};
/**
* Gets the map of entitlements -> offerings -> products
* @returns {Promise<PurchasesOfferings>} Promise of entitlements structure
*/
Purchases.getOfferings = function () {
return RNPurchases.getOfferings();
};
/**
* Fetch the product info
* @param {String[]} productIdentifiers Array of product identifiers
* @param {String} type Optional type of products to fetch, can be inapp or subs. Subs by default
* @returns {Promise<PurchasesProduct[]>} A promise containing an array of products. The promise will be rejected if the products are not properly
* configured in RevenueCat or if there is another error retrieving them. Rejections return an error code, and a userInfo object with more information.
*/
Purchases.getProducts = function (productIdentifiers, type) {
if (type === void 0) { type = PURCHASE_TYPE.SUBS; }
return RNPurchases.getProductInfo(productIdentifiers, type);
};
/**
* Make a purchase
*
* @param {String} productIdentifier The product identifier of the product you want to purchase
* @param {UpgradeInfo} upgradeInfo Android only. Optional UpgradeInfo you wish to upgrade from containing the oldSKU
* and the optional prorationMode.
* @param {String} type Optional type of product, can be inapp or subs. Subs by default
* @returns {Promise<{ productIdentifier: string, purchaserInfo:PurchaserInfo }>} A promise of an object containing
* a purchaser info object and a product identifier. Rejections return an error code,
* a boolean indicating if the user cancelled the purchase, and an object with more information.
*/
Purchases.purchaseProduct = function (productIdentifier, upgradeInfo, type) {
if (type === void 0) { type = PURCHASE_TYPE.SUBS; }
return RNPurchases.purchaseProduct(productIdentifier, upgradeInfo, type, null).catch(function (error) {
error.userCancelled = error.code === "1";
throw error;
});
};
/**
* iOS only. Purchase a product applying a given discount.
*
* @param {PurchasesProduct} product The product you want to purchase
* @param {PurchasesPaymentDiscount} discount Discount to apply to this package. Retrieve this discount using getPaymentDiscount.
* @returns {Promise<{ productIdentifier: string, purchaserInfo:PurchaserInfo }>} A promise of an object containing
* a purchaser info object and a product identifier. Rejections return an error code,
* a boolean indicating if the user cancelled the purchase, and an object with more information.
*/
Purchases.purchaseDiscountedProduct = function (product, discount) {
if (typeof discount === "undefined" || discount == null) {
throw new Error("A discount is required");
}
return RNPurchases.purchaseProduct(product.identifier, null, null, discount.timestamp.toString()).catch(function (error) {
error.userCancelled = error.code === "1";
throw error;
});
};
/**
* Make a purchase
*
* @param {PurchasesPackage} aPackage The Package you wish to purchase. You can get the Packages by calling getOfferings
* @param {UpgradeInfo} upgradeInfo Android only. Optional UpgradeInfo you wish to upgrade from containing the oldSKU
* and the optional prorationMode.
* @returns {Promise<{ productIdentifier: string, purchaserInfo: PurchaserInfo }>} A promise of an object containing
* a purchaser info object and a product identifier. Rejections return an error code,
* a boolean indicating if the user cancelled the purchase, and an object with more information.
*/
Purchases.purchasePackage = function (aPackage, upgradeInfo) {
return RNPurchases.purchasePackage(aPackage.identifier, aPackage.offeringIdentifier, upgradeInfo, null).catch(function (error) {
error.userCancelled = error.code === "1";
throw error;
});
};
/**
* iOS only. Purchase a package applying a given discount.
*
* @param {PurchasesPackage} aPackage The Package you wish to purchase. You can get the Packages by calling getOfferings
* @param {PurchasesPaymentDiscount} discount Discount to apply to this package. Retrieve this discount using getPaymentDiscount.
* @returns {Promise<{ productIdentifier: string, purchaserInfo: PurchaserInfo }>} A promise of an object containing
* a purchaser info object and a product identifier. Rejections return an error code,
* a boolean indicating if the user cancelled the purchase, and an object with more information.
*/
Purchases.purchaseDiscountedPackage = function (aPackage, discount) {
if (typeof discount === "undefined" || discount == null) {
throw new Error("A discount is required");
}
return RNPurchases.purchasePackage(aPackage.identifier, aPackage.offeringIdentifier, null, discount.timestamp.toString()).catch(function (error) {
error.userCancelled = error.code === "1";
throw error;
});
};
/**
* Restores a user's previous purchases and links their appUserIDs to any user's also using those purchases.
* @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
*/
Purchases.restoreTransactions = function () {
return RNPurchases.restoreTransactions();
};
/**
* Get the appUserID
* @returns {Promise<string>} The app user id in a promise
*/
Purchases.getAppUserID = function () {
return RNPurchases.getAppUserID();
};
/**
* This function will alias two appUserIDs together.
* @param {String} newAppUserID The new appUserID that should be linked to the currently identified appUserID. Needs to be a string.
* @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
*/
Purchases.createAlias = function (newAppUserID) {
// noinspection SuspiciousTypeOfGuard
if (typeof newAppUserID !== "string") {
throw new Error("newAppUserID needs to be a string");
}
return RNPurchases.createAlias(newAppUserID);
};
/**
* This function will identify the current user with an appUserID. Typically this would be used after a logout to identify a new user without calling configure
* @param {String} newAppUserID The appUserID that should be linked to the currently user
* @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
*/
Purchases.identify = function (newAppUserID) {
// noinspection SuspiciousTypeOfGuard
if (typeof newAppUserID !== "string") {
throw new Error("newAppUserID needs to be a string");
}
return RNPurchases.identify(newAppUserID);
};
/**
* Resets the Purchases client clearing the saved appUserID. This will generate a random user id and save it in the cache.
* @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
*/
Purchases.reset = function () {
return RNPurchases.reset();
};
/**
* Enables/Disables debugs logs
* @param {Boolean} enabled Enable or not debug logs
*/
Purchases.setDebugLogsEnabled = function (enabled) {
return RNPurchases.setDebugLogsEnabled(enabled);
};
/**
* Gets current purchaser info
* @returns {Promise<PurchaserInfo>} A promise of a purchaser info object. Rejections return an error code, and a userInfo object with more information.
*/
Purchases.getPurchaserInfo = function () {
return RNPurchases.getPurchaserInfo();
};
/**
* This method will send all the purchases to the RevenueCat backend. Call this when using your own implementation
* for subscriptions anytime a sync is needed, like after a successful purchase.
*
* @warning This function should only be called if you're not calling makePurchase.
*/
Purchases.syncPurchases = function () {
RNPurchases.syncPurchases();
};
/**
* Enable automatic collection of Apple Search Ad attribution. Disabled by default
* @param {Boolean} enabled Enable or not automatic apple search ads attribution collection
*/
Purchases.setAutomaticAppleSearchAdsAttributionCollection = function (enabled) {
if (react_native_1.Platform.OS === "ios") {
RNPurchases.setAutomaticAppleSearchAdsAttributionCollection(enabled);
}
};
/**
* @returns { Promise<boolean> } If the `appUserID` has been generated by RevenueCat or not.
*/
Purchases.isAnonymous = function () {
return RNPurchases.isAnonymous();
};
/**
* iOS only. Computes whether or not a user is eligible for the introductory pricing period of a given product.
* You should use this method to determine whether or not you show the user the normal product price or the
* introductory price. This also applies to trials (trials are considered a type of introductory pricing).
*
* @note Subscription groups are automatically collected for determining eligibility. If RevenueCat can't
* definitively compute the eligibility, most likely because of missing group information, it will return
* `INTRO_ELIGIBILITY_STATUS_UNKNOWN`. The best course of action on unknown status is to display the non-intro
* pricing, to not create a misleading situation. To avoid this, make sure you are testing with the latest version of
* iOS so that the subscription group can be collected by the SDK. Android always returns INTRO_ELIGIBILITY_STATUS_UNKNOWN.
*
* @param productIdentifiers Array of product identifiers for which you want to compute eligibility
* @returns { Promise<[productId: string]: IntroEligibility> } A map of IntroEligility per productId
*/
Purchases.checkTrialOrIntroductoryPriceEligibility = function (productIdentifiers) {
return RNPurchases.checkTrialOrIntroductoryPriceEligibility(productIdentifiers);
};
/**
* iOS only. Use this function to retrieve the `PurchasesPaymentDiscount` for a given `PurchasesPackage`.
*
* @param product The `PurchasesProduct` the user intends to purchase.
* @param discount The `PurchasesDiscount` to apply to the product.
* @returns { Promise<PurchasesPaymentDiscount> } Returns when the `PurchasesPaymentDiscount` is returned. Null is returned for Android and incompatible iOS versions.
*/
Purchases.getPaymentDiscount = function (product, discount) {
if (react_native_1.Platform.OS === "android") {
return Promise.resolve(undefined);
}
if (typeof discount === "undefined" || discount == null) {
throw new Error("A discount is required");
}
return RNPurchases.getPaymentDiscount(product.identifier, discount.identifier);
};
/**
* Invalidates the cache for purchaser information.
*
* Most apps will not need to use this method; invalidating the cache can leave your app in an invalid state.
* Refer to https://docs.revenuecat.com/docs/purchaserinfo#section-get-user-information for more information on
* using the cache properly.
*
* This is useful for cases where purchaser information might have been updated outside of the app, like if a
* promotional subscription is granted through the RevenueCat dashboard.
*/
Purchases.invalidatePurchaserInfoCache = function () {
RNPurchases.invalidatePurchaserInfoCache();
};
/** iOS only. Presents a code redemption sheet, useful for redeeming offer codes
* Refer to https://docs.revenuecat.com/docs/ios-subscription-offers#offer-codes for more information on how
* to configure and use offer codes
*/
Purchases.presentCodeRedemptionSheet = function () {
if (react_native_1.Platform.OS === "ios") {
RNPurchases.presentCodeRedemptionSheet();
}
};
/**
* Subscriber attributes are useful for storing additional, structured information on a user.
* Since attributes are writable using a public key they should not be used for
* managing secure or sensitive information such as subscription status, coins, etc.
*
* Key names starting with "$" are reserved names used by RevenueCat. For a full list of key
* restrictions refer to our guide: https://docs.revenuecat.com/docs/subscriber-attributes
*
* @param attributes Map of attributes by key. Set the value as an empty string to delete an attribute.
*/
Purchases.setAttributes = function (attributes) {
RNPurchases.setAttributes(attributes);
};
/**
* Subscriber attribute associated with the email address for the user
*
* @param email Empty String or null will delete the subscriber attribute.
*/
Purchases.setEmail = function (email) {
RNPurchases.setEmail(email);
};
/**
* Subscriber attribute associated with the phone number for the user
*
* @param phoneNumber Empty String or null will delete the subscriber attribute.
*/
Purchases.setPhoneNumber = function (phoneNumber) {
RNPurchases.setPhoneNumber(phoneNumber);
};
/**
* Subscriber attribute associated with the display name for the user
*
* @param displayName Empty String or null will delete the subscriber attribute.
*/
Purchases.setDisplayName = function (displayName) {
RNPurchases.setDisplayName(displayName);
};
/**
* Subscriber attribute associated with the push token for the user
*
* @param pushToken null will delete the subscriber attribute.
*/
Purchases.setPushToken = function (pushToken) {
RNPurchases.setPushToken(pushToken);
};
/**
* Set this property to your proxy URL before configuring Purchases *only* if you've received a proxy key value from your RevenueCat contact.
*/
Purchases.setProxyURL = function (url) {
RNPurchases.setProxyURLString(url);
};
/**
* Automatically collect subscriber attributes associated with the device identifiers.
* $idfa, $idfv, $ip on iOS
* $gpsAdId, $androidId, $ip on Android
*/
Purchases.collectDeviceIdentifiers = function () {
RNPurchases.collectDeviceIdentifiers();
};
/**
* Subscriber attribute associated with the Adjust Id for the user
* Required for the RevenueCat Adjust integration
*
* @param adjustID Empty String or null will delete the subscriber attribute.
*/
Purchases.setAdjustID = function (adjustID) {
RNPurchases.setAdjustID(adjustID);
};
/**
* Subscriber attribute associated with the AppsFlyer Id for the user
* Required for the RevenueCat AppsFlyer integration
* @param appsflyerID Empty String or null will delete the subscriber attribute.
*/
Purchases.setAppsflyerID = function (appsflyerID) {
RNPurchases.setAppsflyerID(appsflyerID);
};
/**
* Subscriber attribute associated with the Facebook SDK Anonymous Id for the user
* Recommended for the RevenueCat Facebook integration
*
* @param fbAnonymousID Empty String or null will delete the subscriber attribute.
*/
Purchases.setFBAnonymousID = function (fbAnonymousID) {
RNPurchases.setFBAnonymousID(fbAnonymousID);
};
/**
* Subscriber attribute associated with the mParticle Id for the user
* Recommended for the RevenueCat mParticle integration
*
* @param mparticleID Empty String or null will delete the subscriber attribute.
*/
Purchases.setMparticleID = function (mparticleID) {
RNPurchases.setMparticleID(mparticleID);
};
/**
* Subscriber attribute associated with the OneSignal Player Id for the user
* Required for the RevenueCat OneSignal integration
*
* @param onesignalID Empty String or null will delete the subscriber attribute.
*/
Purchases.setOnesignalID = function (onesignalID) {
RNPurchases.setOnesignalID(onesignalID);
};
/**
* Subscriber attribute associated with the install media source for the user
*
* @param mediaSource Empty String or null will delete the subscriber attribute.
*/
Purchases.setMediaSource = function (mediaSource) {
RNPurchases.setMediaSource(mediaSource);
};
/**
* Subscriber attribute associated with the install campaign for the user
*
* @param campaign Empty String or null will delete the subscriber attribute.
*/
Purchases.setCampaign = function (campaign) {
RNPurchases.setCampaign(campaign);
};
/**
* Subscriber attribute associated with the install ad group for the user
*
* @param adGroup Empty String or null will delete the subscriber attribute.
*/
Purchases.setAdGroup = function (adGroup) {
RNPurchases.setAdGroup(adGroup);
};
/**
* Subscriber attribute associated with the install ad for the user
*
* @param ad Empty String or null will delete the subscriber attribute.
*/
Purchases.setAd = function (ad) {
RNPurchases.setAd(ad);
};
/**
* Subscriber attribute associated with the install keyword for the user
*
* @param keyword Empty String or null will delete the subscriber attribute.
*/
Purchases.setKeyword = function (keyword) {
RNPurchases.setKeyword(keyword);
};
/**
* Subscriber attribute associated with the install ad creative for the user
*
* @param creative Empty String or null will delete the subscriber attribute.
*/
Purchases.setCreative = function (creative) {
RNPurchases.setCreative(creative);
};
/**
* Enum for attribution networks
* @readonly
* @enum {number}
*/
Purchases.ATTRIBUTION_NETWORK = ATTRIBUTION_NETWORK;
/**
* @deprecated use ATTRIBUTION_NETWORK instead
*
* Enum for attribution networks
* @readonly
* @enum {number}
*/
Purchases.ATTRIBUTION_NETWORKS = ATTRIBUTION_NETWORK;
/**
* Supported SKU types.
* @readonly
* @enum {string}
*/
Purchases.PURCHASE_TYPE = PURCHASE_TYPE;
/**
* Replace SKU's ProrationMode.
* @readonly
* @enum {number}
*/
Purchases.PRORATION_MODE = PRORATION_MODE;
/**
* Enumeration of all possible Package types.
* @readonly
* @enum {string}
*/
Purchases.PACKAGE_TYPE = PACKAGE_TYPE;
/**
* Enum of different possible states for intro price eligibility status.
* @readonly
* @enum {number}
*/
Purchases.INTRO_ELIGIBILITY_STATUS = INTRO_ELIGIBILITY_STATUS;
return Purchases;
}());
exports.default = Purchases;