react-native-purchases 5.8.0 → 5.9.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 +1 -1
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java +16 -0
- package/dist/purchases.d.ts +29 -0
- package/dist/purchases.js +46 -1
- package/ios/RNPurchases.m +16 -2
- package/package.json +3 -4
- package/scripts/docs/index.html +1 -1
- package/scripts/setupJest.js +2 -0
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 '5.
|
|
32
|
+
versionName '5.9.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:4.12.
|
|
124
|
+
implementation 'com.revenuecat.purchases:purchases-hybrid-common:4.12.1'
|
|
125
125
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
126
126
|
}
|
|
@@ -42,6 +42,7 @@ import static com.revenuecat.purchases.react.RNPurchasesConverters.convertMapToW
|
|
|
42
42
|
public class RNPurchasesModule extends ReactContextBaseJavaModule implements UpdatedCustomerInfoListener {
|
|
43
43
|
|
|
44
44
|
private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";
|
|
45
|
+
private static final String LOG_HANDLER_EVENT = "Purchases-LogHandlerEvent";
|
|
45
46
|
public static final String PLATFORM_NAME = "react-native";
|
|
46
47
|
public static final String PLUGIN_VERSION = "4.6.0";
|
|
47
48
|
|
|
@@ -174,11 +175,26 @@ public class RNPurchasesModule extends ReactContextBaseJavaModule implements Upd
|
|
|
174
175
|
CommonKt.logIn(appUserID, getOnResult(promise));
|
|
175
176
|
}
|
|
176
177
|
|
|
178
|
+
@Deprecated // Use setLogLevel instead
|
|
177
179
|
@ReactMethod
|
|
178
180
|
public void setDebugLogsEnabled(boolean enabled) {
|
|
179
181
|
CommonKt.setDebugLogsEnabled(enabled);
|
|
180
182
|
}
|
|
181
183
|
|
|
184
|
+
@ReactMethod
|
|
185
|
+
public void setLogLevel(final String level) {
|
|
186
|
+
CommonKt.setLogLevel(level);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@ReactMethod
|
|
190
|
+
public void setLogHandler() {
|
|
191
|
+
CommonKt.setLogHandler(logDetails -> {
|
|
192
|
+
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
193
|
+
.emit(RNPurchasesModule.LOG_HANDLER_EVENT, convertMapToWriteableMap(logDetails));
|
|
194
|
+
return null;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
182
198
|
@ReactMethod
|
|
183
199
|
public void getCustomerInfo(final Promise promise) {
|
|
184
200
|
CommonKt.getCustomerInfo(getOnResult(promise));
|
package/dist/purchases.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type MakePurchaseResult = {
|
|
|
12
12
|
productIdentifier: string;
|
|
13
13
|
customerInfo: CustomerInfo;
|
|
14
14
|
};
|
|
15
|
+
export type LogHandler = (logLevel: LOG_LEVEL, message: string) => void;
|
|
15
16
|
export declare enum PURCHASE_TYPE {
|
|
16
17
|
/**
|
|
17
18
|
* A type of SKU for in-app products.
|
|
@@ -76,6 +77,13 @@ export interface LogInResult {
|
|
|
76
77
|
*/
|
|
77
78
|
readonly created: boolean;
|
|
78
79
|
}
|
|
80
|
+
export declare enum LOG_LEVEL {
|
|
81
|
+
VERBOSE = "VERBOSE",
|
|
82
|
+
DEBUG = "DEBUG",
|
|
83
|
+
INFO = "INFO",
|
|
84
|
+
WARN = "WARN",
|
|
85
|
+
ERROR = "ERROR"
|
|
86
|
+
}
|
|
79
87
|
/**
|
|
80
88
|
* Holds parameters to initialize the SDK.
|
|
81
89
|
*/
|
|
@@ -156,6 +164,12 @@ export default class Purchases {
|
|
|
156
164
|
* @enum {string}
|
|
157
165
|
*/
|
|
158
166
|
static PURCHASES_ERROR_CODE: typeof PURCHASES_ERROR_CODE;
|
|
167
|
+
/**
|
|
168
|
+
* List of valid log levels.
|
|
169
|
+
* @readonly
|
|
170
|
+
* @enum {string}
|
|
171
|
+
*/
|
|
172
|
+
static LOG_LEVEL: typeof LOG_LEVEL;
|
|
159
173
|
/**
|
|
160
174
|
* @internal
|
|
161
175
|
*/
|
|
@@ -319,8 +333,23 @@ export default class Purchases {
|
|
|
319
333
|
/**
|
|
320
334
|
* Enables/Disables debugs logs
|
|
321
335
|
* @param {boolean} enabled Enable or not debug logs
|
|
336
|
+
* @deprecated, use setLogLevel instead
|
|
322
337
|
*/
|
|
323
338
|
static setDebugLogsEnabled(enabled: boolean): Promise<void>;
|
|
339
|
+
/**
|
|
340
|
+
* Used to set the log level. Useful for debugging issues with the lovely team @RevenueCat.
|
|
341
|
+
* The default is {LOG_LEVEL.INFO} in release builds and {LOG_LEVEL.DEBUG} in debug builds.
|
|
342
|
+
* @param {LOG_LEVEL} level
|
|
343
|
+
*/
|
|
344
|
+
static setLogLevel(level: LOG_LEVEL): Promise<void>;
|
|
345
|
+
/**
|
|
346
|
+
* Set a custom log handler for redirecting logs to your own logging system.
|
|
347
|
+
* By default, this sends info, warning, and error messages.
|
|
348
|
+
* If you wish to receive Debug level messages, see [setLogLevel].
|
|
349
|
+
* @param {LogHandler} logHandler It will get called for each log event.
|
|
350
|
+
* Use this function to redirect the log to your own logging system
|
|
351
|
+
*/
|
|
352
|
+
static setLogHandler(logHandler: LogHandler): void;
|
|
324
353
|
/**
|
|
325
354
|
* Gets current customer info
|
|
326
355
|
* @returns {Promise<CustomerInfo>} A promise of a customer info object. Rejections return an error code, and an
|
package/dist/purchases.js
CHANGED
|
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.REFUND_REQUEST_STATUS = exports.BILLING_FEATURE = exports.PURCHASE_TYPE = void 0;
|
|
39
|
+
exports.LOG_LEVEL = exports.REFUND_REQUEST_STATUS = exports.BILLING_FEATURE = exports.PURCHASE_TYPE = void 0;
|
|
40
40
|
var react_native_1 = require("react-native");
|
|
41
41
|
var errors_1 = require("./errors");
|
|
42
42
|
var offerings_1 = require("./offerings");
|
|
@@ -45,6 +45,7 @@ var RNPurchases = react_native_1.NativeModules.RNPurchases;
|
|
|
45
45
|
var eventEmitter = new react_native_1.NativeEventEmitter(RNPurchases);
|
|
46
46
|
var customerInfoUpdateListeners = [];
|
|
47
47
|
var shouldPurchasePromoProductListeners = [];
|
|
48
|
+
var customLogHandler;
|
|
48
49
|
eventEmitter.addListener("Purchases-CustomerInfoUpdated", function (customerInfo) {
|
|
49
50
|
customerInfoUpdateListeners.forEach(function (listener) { return listener(customerInfo); });
|
|
50
51
|
});
|
|
@@ -54,6 +55,11 @@ eventEmitter.addListener("Purchases-ShouldPurchasePromoProduct", function (_a) {
|
|
|
54
55
|
return listener(function () { return RNPurchases.makeDeferredPurchase(callbackID); });
|
|
55
56
|
});
|
|
56
57
|
});
|
|
58
|
+
eventEmitter.addListener("Purchases-LogHandlerEvent", function (_a) {
|
|
59
|
+
var logLevel = _a.logLevel, message = _a.message;
|
|
60
|
+
var logLevelEnum = LOG_LEVEL[logLevel];
|
|
61
|
+
customLogHandler(logLevelEnum, message);
|
|
62
|
+
});
|
|
57
63
|
var PURCHASE_TYPE;
|
|
58
64
|
(function (PURCHASE_TYPE) {
|
|
59
65
|
/**
|
|
@@ -108,6 +114,14 @@ var REFUND_REQUEST_STATUS;
|
|
|
108
114
|
*/
|
|
109
115
|
REFUND_REQUEST_STATUS[REFUND_REQUEST_STATUS["ERROR"] = 2] = "ERROR";
|
|
110
116
|
})(REFUND_REQUEST_STATUS = exports.REFUND_REQUEST_STATUS || (exports.REFUND_REQUEST_STATUS = {}));
|
|
117
|
+
var LOG_LEVEL;
|
|
118
|
+
(function (LOG_LEVEL) {
|
|
119
|
+
LOG_LEVEL["VERBOSE"] = "VERBOSE";
|
|
120
|
+
LOG_LEVEL["DEBUG"] = "DEBUG";
|
|
121
|
+
LOG_LEVEL["INFO"] = "INFO";
|
|
122
|
+
LOG_LEVEL["WARN"] = "WARN";
|
|
123
|
+
LOG_LEVEL["ERROR"] = "ERROR";
|
|
124
|
+
})(LOG_LEVEL = exports.LOG_LEVEL || (exports.LOG_LEVEL = {}));
|
|
111
125
|
var Purchases = /** @class */ (function () {
|
|
112
126
|
function Purchases() {
|
|
113
127
|
}
|
|
@@ -464,6 +478,7 @@ var Purchases = /** @class */ (function () {
|
|
|
464
478
|
/**
|
|
465
479
|
* Enables/Disables debugs logs
|
|
466
480
|
* @param {boolean} enabled Enable or not debug logs
|
|
481
|
+
* @deprecated, use setLogLevel instead
|
|
467
482
|
*/
|
|
468
483
|
Purchases.setDebugLogsEnabled = function (enabled) {
|
|
469
484
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -473,6 +488,30 @@ var Purchases = /** @class */ (function () {
|
|
|
473
488
|
});
|
|
474
489
|
});
|
|
475
490
|
};
|
|
491
|
+
/**
|
|
492
|
+
* Used to set the log level. Useful for debugging issues with the lovely team @RevenueCat.
|
|
493
|
+
* The default is {LOG_LEVEL.INFO} in release builds and {LOG_LEVEL.DEBUG} in debug builds.
|
|
494
|
+
* @param {LOG_LEVEL} level
|
|
495
|
+
*/
|
|
496
|
+
Purchases.setLogLevel = function (level) {
|
|
497
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
498
|
+
return __generator(this, function (_a) {
|
|
499
|
+
RNPurchases.setLogLevel(level);
|
|
500
|
+
return [2 /*return*/];
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
};
|
|
504
|
+
/**
|
|
505
|
+
* Set a custom log handler for redirecting logs to your own logging system.
|
|
506
|
+
* By default, this sends info, warning, and error messages.
|
|
507
|
+
* If you wish to receive Debug level messages, see [setLogLevel].
|
|
508
|
+
* @param {LogHandler} logHandler It will get called for each log event.
|
|
509
|
+
* Use this function to redirect the log to your own logging system
|
|
510
|
+
*/
|
|
511
|
+
Purchases.setLogHandler = function (logHandler) {
|
|
512
|
+
customLogHandler = logHandler;
|
|
513
|
+
RNPurchases.setLogHandler();
|
|
514
|
+
};
|
|
476
515
|
/**
|
|
477
516
|
* Gets current customer info
|
|
478
517
|
* @returns {Promise<CustomerInfo>} A promise of a customer info object. Rejections return an error code, and an
|
|
@@ -1323,6 +1362,12 @@ var Purchases = /** @class */ (function () {
|
|
|
1323
1362
|
* @enum {string}
|
|
1324
1363
|
*/
|
|
1325
1364
|
Purchases.PURCHASES_ERROR_CODE = errors_1.PURCHASES_ERROR_CODE;
|
|
1365
|
+
/**
|
|
1366
|
+
* List of valid log levels.
|
|
1367
|
+
* @readonly
|
|
1368
|
+
* @enum {string}
|
|
1369
|
+
*/
|
|
1370
|
+
Purchases.LOG_LEVEL = LOG_LEVEL;
|
|
1326
1371
|
/**
|
|
1327
1372
|
* @internal
|
|
1328
1373
|
*/
|
package/ios/RNPurchases.m
CHANGED
|
@@ -20,6 +20,7 @@ typedef void (^StartPurchaseBlock)(PurchaseCompletedBlock);
|
|
|
20
20
|
|
|
21
21
|
NSString *RNPurchasesCustomerInfoUpdatedEvent = @"Purchases-CustomerInfoUpdated";
|
|
22
22
|
NSString *RNPurchasesShouldPurchasePromoProductEvent = @"Purchases-ShouldPurchasePromoProduct";
|
|
23
|
+
NSString *RNPurchasesLogHandlerEvent = @"Purchases-LogHandlerEvent";
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
@implementation RNPurchases
|
|
@@ -29,7 +30,9 @@ NSString *RNPurchasesShouldPurchasePromoProductEvent = @"Purchases-ShouldPurchas
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
- (NSArray<NSString *> *)supportedEvents {
|
|
32
|
-
return @[RNPurchasesCustomerInfoUpdatedEvent,
|
|
33
|
+
return @[RNPurchasesCustomerInfoUpdatedEvent,
|
|
34
|
+
RNPurchasesShouldPurchasePromoProductEvent,
|
|
35
|
+
RNPurchasesLogHandlerEvent];
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
RCT_EXPORT_MODULE();
|
|
@@ -139,6 +142,11 @@ RCT_REMAP_METHOD(setDebugLogsEnabled,
|
|
|
139
142
|
[RCCommonFunctionality setDebugLogsEnabled:enabled];
|
|
140
143
|
}
|
|
141
144
|
|
|
145
|
+
RCT_EXPORT_METHOD(setLogLevel:(NSString *)level)
|
|
146
|
+
{
|
|
147
|
+
[RCCommonFunctionality setLogLevel:level];
|
|
148
|
+
}
|
|
149
|
+
|
|
142
150
|
RCT_EXPORT_METHOD(setSimulatesAskToBuyInSandbox:(BOOL)simulatesAskToBuyInSandbox)
|
|
143
151
|
{
|
|
144
152
|
[RCCommonFunctionality setSimulatesAskToBuyInSandbox:simulatesAskToBuyInSandbox];
|
|
@@ -370,6 +378,12 @@ RCT_REMAP_METHOD(isConfigured,
|
|
|
370
378
|
resolve(@(RCPurchases.isConfigured));
|
|
371
379
|
}
|
|
372
380
|
|
|
381
|
+
RCT_EXPORT_METHOD(setLogHandler) {
|
|
382
|
+
[RCCommonFunctionality setLogHanderOnLogReceived:^(NSDictionary<NSString *,NSString *> * _Nonnull logDetails) {
|
|
383
|
+
[self sendEventWithName:RNPurchasesLogHandlerEvent body:logDetails];
|
|
384
|
+
}];
|
|
385
|
+
}
|
|
386
|
+
|
|
373
387
|
#pragma mark -
|
|
374
388
|
#pragma mark Delegate Methods
|
|
375
389
|
- (void)purchases:(RCPurchases *)purchases receivedUpdatedCustomerInfo:(RCCustomerInfo *)customerInfo {
|
|
@@ -425,7 +439,7 @@ readyForPromotedProduct:(RCStoreProduct *)product
|
|
|
425
439
|
}
|
|
426
440
|
|
|
427
441
|
- (NSString *)platformFlavorVersion {
|
|
428
|
-
return @"5.
|
|
442
|
+
return @"5.9.0";
|
|
429
443
|
}
|
|
430
444
|
|
|
431
445
|
@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": "5.
|
|
4
|
+
"version": "5.9.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",
|
|
@@ -32,9 +32,8 @@
|
|
|
32
32
|
"test": "jest",
|
|
33
33
|
"tslint": "tslint -c tslint.json 'src/*.ts'",
|
|
34
34
|
"prepare": "tsc",
|
|
35
|
-
"example": "yarn --cwd examples/
|
|
36
|
-
"
|
|
37
|
-
"bootstrap": "yarn example && yarn && yarn pods"
|
|
35
|
+
"example": "yarn --cwd examples/purchaseTesterTypescript",
|
|
36
|
+
"bootstrap": "yarn && yarn example && yarn example pods"
|
|
38
37
|
},
|
|
39
38
|
"repository": {
|
|
40
39
|
"type": "git",
|
package/scripts/docs/index.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<!DOCTYPE html>
|
|
3
3
|
<html>
|
|
4
4
|
<head>
|
|
5
|
-
<meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/5.
|
|
5
|
+
<meta http-equiv="refresh" content="0; url=https://revenuecat.github.io/react-native-purchases-docs/5.9.0/" />
|
|
6
6
|
</head>
|
|
7
7
|
<body>
|
|
8
8
|
</body>
|
package/scripts/setupJest.js
CHANGED
|
@@ -737,6 +737,8 @@ NativeModules.RNPurchases = {
|
|
|
737
737
|
restorePurchases: jest.fn(),
|
|
738
738
|
getAppUserID: jest.fn(),
|
|
739
739
|
setDebugLogsEnabled: jest.fn(),
|
|
740
|
+
setLogLevel: jest.fn(),
|
|
741
|
+
setLogHandler: jest.fn(),
|
|
740
742
|
getCustomerInfo: jest.fn(),
|
|
741
743
|
logIn: jest.fn(),
|
|
742
744
|
logOut: jest.fn(),
|